IT IS ALIVE
2
run src.bat
Normal file
@ -0,0 +1,2 @@
|
||||
@ECHO OFF
|
||||
"C:\Program Files\LOVE\love.exe" "%cd%/src"
|
BIN
source-images/fighter1/original.png
Normal file
After Width: | Height: | Size: 334 B |
BIN
source-images/fighter1/redesign-alpha.png
Normal file
After Width: | Height: | Size: 543 B |
BIN
source-images/fighter1/redesign.png
Normal file
After Width: | Height: | Size: 355 B |
BIN
source-images/fighter1/redesign.xcf
Normal file
BIN
source-images/fighter1/shieldhit/original.png
Normal file
After Width: | Height: | Size: 459 B |
BIN
source-images/fighter1/shieldhit/redesign-transparent.png
Normal file
After Width: | Height: | Size: 441 B |
BIN
source-images/fighter1/shieldhit/redesign-transparent.xcf
Normal file
BIN
source-images/fighter1/shieldhit/redesign.png
Normal file
After Width: | Height: | Size: 431 B |
BIN
source-images/fighter1/shieldhit/redesign.xcf
Normal file
BIN
source-images/fighter1/shieldhit/redesign2-transparent.png
Normal file
After Width: | Height: | Size: 479 B |
BIN
source-images/fighter1/shieldhit/redesign2-transparent.xcf
Normal file
BIN
source-images/fighter1/shieldhit/redesign2.png
Normal file
After Width: | Height: | Size: 450 B |
BIN
source-images/fighter1/shieldhit/redesign2.xcf
Normal file
35
src/conf.lua
Normal file
@ -0,0 +1,35 @@
|
||||
function love.conf(t)
|
||||
t.identity = nil -- The name of the save directory (string)
|
||||
--t.version = "0.9.0" -- The LÖVE version this game was made for (string)
|
||||
t.console = true -- Attach a console (boolean, Windows only)
|
||||
|
||||
t.window.title = "SpaceLove" -- The window title (string)
|
||||
t.window.icon = nil -- Filepath to an image to use as the window's icon (string)
|
||||
t.window.width = 1280 -- The window width (number)
|
||||
t.window.height = 720 -- The window height (number)
|
||||
t.window.borderless = false -- Remove all border visuals from the window (boolean)
|
||||
t.window.resizable = false -- Let the window be user-resizable (boolean)
|
||||
--t.window.minwidth = 1 -- Minimum window width if the window is resizable (number)
|
||||
--t.window.minheight = 1 -- Minimum window height if the window is resizable (number)
|
||||
t.window.fullscreen = false -- Enable fullscreen (boolean)
|
||||
t.window.fullscreentype = "normal" -- Standard fullscreen or desktop fullscreen mode (string)
|
||||
t.window.vsync = true -- Enable vertical sync (boolean)
|
||||
t.window.fsaa = 0 -- The number of samples to use with multi-sampled antialiasing (number)
|
||||
t.window.display = 1 -- Index of the monitor to show the window in (number)
|
||||
t.window.highdpi = false -- Enable high-dpi mode for the window on a Retina display (boolean). Added in 0.9.1
|
||||
t.window.srgb = false -- Enable sRGB gamma correction when drawing to the screen (boolean). Added in 0.9.1
|
||||
|
||||
t.modules.audio = true -- Enable the audio module (boolean)
|
||||
t.modules.event = true -- Enable the event module (boolean)
|
||||
t.modules.graphics = true -- Enable the graphics module (boolean)
|
||||
t.modules.image = true -- Enable the image module (boolean)
|
||||
t.modules.joystick = true -- Enable the joystick module (boolean)
|
||||
t.modules.keyboard = true -- Enable the keyboard module (boolean)
|
||||
t.modules.math = true -- Enable the math module (boolean)
|
||||
t.modules.mouse = true -- Enable the mouse module (boolean)
|
||||
t.modules.physics = true -- Enable the physics module (boolean)
|
||||
t.modules.sound = true -- Enable the sound module (boolean)
|
||||
t.modules.system = true -- Enable the system module (boolean)
|
||||
t.modules.timer = true -- Enable the timer module (boolean)
|
||||
t.modules.window = true -- Enable the window module (boolean)
|
||||
end
|
BIN
src/images/fighter1.png
Normal file
After Width: | Height: | Size: 543 B |
BIN
src/images/shieldhit1.png
Normal file
After Width: | Height: | Size: 450 B |
125
src/main.lua
Normal file
@ -0,0 +1,125 @@
|
||||
local Player = {
|
||||
image = nil,
|
||||
shieldhit = nil,
|
||||
imgHalfWidth = nil,
|
||||
imgHalfHeight = nil,
|
||||
x = nil,
|
||||
y = nil,
|
||||
v = {
|
||||
x = nil, y = nil,
|
||||
},
|
||||
currentRotation = nil,
|
||||
rotationSpeed = nil,
|
||||
rotationImpulse = nil,
|
||||
rotationDrag = nil,
|
||||
rotationLowerLimit = nil,
|
||||
degreeLock = nil,
|
||||
forwardThrust = nil,
|
||||
reverseThrust = nil,
|
||||
sideThrust = nil,
|
||||
maximumSpeed = nil,
|
||||
accelerate = nil,
|
||||
}
|
||||
|
||||
function Player.accelerate(direction, amount, dt)
|
||||
-- apply acceleration
|
||||
Player.v.x = Player.v.x + amount * math.cos(direction) * dt
|
||||
Player.v.y = Player.v.y + amount * math.sin(direction) * dt
|
||||
|
||||
-- check if above maximum speed
|
||||
local magnitude = math.sqrt(Player.v.x * Player.v.x + Player.v.y * Player.v.y)
|
||||
if magnitude > Player.maximumSpeed then
|
||||
Player.accelerate(math.tan(Player.v.y, Player.v.x) + math.pi, magnitude - Player.maximumSpeed, dt)
|
||||
end
|
||||
end
|
||||
|
||||
function love.load()
|
||||
--position and speed
|
||||
Player.x = love.graphics.getWidth() / 2
|
||||
Player.y = love.graphics.getHeight() / 2
|
||||
Player.v.x = 0
|
||||
Player.v.y = 0
|
||||
Player.currentRotation = 0
|
||||
Player.rotationSpeed = 0
|
||||
|
||||
--image
|
||||
Player.image = love.graphics.newImage("images/fighter1.png")
|
||||
Player.imgHalfWidth = Player.image:getWidth() / 2
|
||||
Player.imgHalfHeight = Player.image:getHeight() / 2
|
||||
Player.imgScale = 1.5
|
||||
--shieldhit image
|
||||
Player.shieldhit = love.graphics.newImage("images/shieldhit1.png")
|
||||
Player.shieldHalfWidth = Player.shieldhit:getWidth() / 2
|
||||
Player.shieldHalfHeight = Player.shieldhit:getHeight() / 2
|
||||
Player.shieldScale = 1.6
|
||||
|
||||
--engine
|
||||
Player.forwardThrust = 2600
|
||||
Player.reverseThrust = 1300
|
||||
Player.sideThrust = 800
|
||||
Player.spaceDrag = 0.95
|
||||
Player.speedLowerLimit = 20
|
||||
Player.maximumSpeed = 40000
|
||||
|
||||
--maneuverability
|
||||
Player.rotationImpulse = 33
|
||||
Player.rotationDrag = 0.93
|
||||
Player.rotationLowerLimit = 0.5
|
||||
Player.degreeLock = 7.5 * math.pi / 180
|
||||
end
|
||||
|
||||
function love.update(dt)
|
||||
-- Player rotation input
|
||||
if love.keyboard.isDown('q') or love.keyboard.isDown('a') then
|
||||
Player.rotationSpeed = Player.rotationSpeed - Player.rotationImpulse * dt
|
||||
elseif love.keyboard.isDown('e') or love.keyboard.isDown('d') then
|
||||
Player.rotationSpeed = Player.rotationSpeed + Player.rotationImpulse * dt
|
||||
end
|
||||
|
||||
-- Player rotationSpeed adjustment
|
||||
Player.rotationSpeed = Player.rotationSpeed * Player.rotationDrag
|
||||
if Player.rotationSpeed < Player.rotationLowerLimit and Player.rotationSpeed > 0 then Player.rotationSpeed = 0 end
|
||||
if Player.rotationSpeed > -Player.rotationLowerLimit and Player.rotationSpeed < 0 then Player.rotationSpeed = 0 end
|
||||
|
||||
-- Player currentRotation applied
|
||||
Player.currentRotation = Player.currentRotation + Player.rotationSpeed * dt
|
||||
|
||||
-- Player movement input
|
||||
if love.keyboard.isDown('w') then
|
||||
Player.accelerate(Player.currentRotation - (Player.currentRotation % Player.degreeLock) - math.pi/2, Player.forwardThrust, dt)
|
||||
elseif love.keyboard.isDown('s') then
|
||||
Player.accelerate(Player.currentRotation - (Player.currentRotation % Player.degreeLock) + math.pi/2, Player.reverseThrust, dt)
|
||||
end
|
||||
if love.keyboard.isDown('j') then
|
||||
Player.accelerate(Player.currentRotation - (Player.currentRotation % Player.degreeLock) - math.pi, Player.sideThrust, dt)
|
||||
elseif love.keyboard.isDown('l') then
|
||||
Player.accelerate(Player.currentRotation - (Player.currentRotation % Player.degreeLock), Player.sideThrust, dt)
|
||||
end
|
||||
|
||||
-- Player current speed adjustment
|
||||
Player.v.x = Player.v.x * Player.spaceDrag
|
||||
Player.v.y = Player.v.y * Player.spaceDrag
|
||||
local speed = math.sqrt(Player.v.x * Player.v.x + Player.v.y * Player.v.y)
|
||||
--Player.accelerate(math.tan(Player.v.y, Player.v.x) + math.pi, speed * Player.spaceDrag, dt)
|
||||
--[[
|
||||
if Player.v.x < Player.speedLowerLimit and Player.v.x > 0 then Player.v.x = 0 end
|
||||
if Player.v.x > -Player.speedLowerLimit and Player.v.x < 0 then Player.v.x = 0 end
|
||||
if Player.v.y < Player.speedLowerLimit and Player.v.y > 0 then Player.v.y = 0 end
|
||||
if Player.v.y > -Player.speedLowerLimit and Player.v.y < 0 then Player.v.y = 0 end
|
||||
--]]
|
||||
if speed < Player.speedLowerLimit then
|
||||
Player.accelerate(math.tan(Player.v.y, Player.v.x) + math.pi, speed, dt)
|
||||
end
|
||||
|
||||
-- Player current speed applied
|
||||
Player.x = Player.x + Player.v.x * dt
|
||||
Player.y = Player.y + Player.v.y * dt
|
||||
|
||||
-- emergency exit
|
||||
if love.keyboard.isDown('escape') then love.event.quit() end
|
||||
end
|
||||
|
||||
function love.draw()
|
||||
love.graphics.draw(Player.image, Player.x - Player.imgHalfWidth, Player.y - Player.imgHalfHeight, Player.currentRotation - (Player.currentRotation % Player.degreeLock), Player.imgScale, Player.imgScale, Player.imgHalfWidth, Player.imgHalfHeight)
|
||||
--love.graphics.draw(Player.shieldhit, Player.x - Player.shieldHalfWidth, Player.y - Player.shieldHalfHeight, Player.currentRotation - (Player.currentRotation % Player.degreeLock), Player.shieldScale, Player.shieldScale, Player.shieldHalfWidth, Player.shieldHalfHeight)
|
||||
end
|