debug organized, thrusters use fuel
This commit is contained in:
61
src/Debug.lua
Normal file
61
src/Debug.lua
Normal file
@@ -0,0 +1,61 @@
|
||||
local Debug = {}
|
||||
local debug = {
|
||||
-- values to use: above, below, none
|
||||
hitRadius = "above", -- (magenta) where player can be hit
|
||||
middleLines = "below", -- (red) midlines of screen
|
||||
playerCenter = "none", -- (pink) center of player
|
||||
fpsCounter = "above", -- (white) current fps in top left
|
||||
fuelNumber = "above", -- (white) fuel/max fuel in numerical form
|
||||
}
|
||||
|
||||
function Debug:drawAbove()
|
||||
for k,v in pairs(debug) do
|
||||
if v == "above" then
|
||||
Debug[k]()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Debug:drawBelow()
|
||||
for k,v in pairs(debug) do
|
||||
if v == "below" then
|
||||
Debug[k]()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Debug:hitRadius()
|
||||
love.graphics.setLineWidth(1)
|
||||
love.graphics.setColor(255, 0, 255) -- as much as I love this orange: 188, 128, 90, THIS NEEDS TO STAND OUT
|
||||
love.graphics.arc("line", player.Ship.x, player.Ship.y, player.Ship.Hull.hitRadius, 0, math.pi*2, 20)
|
||||
end
|
||||
|
||||
function Debug:middleLines()
|
||||
love.graphics.setLineWidth(0.5)
|
||||
love.graphics.setColor(200, 0, 0)
|
||||
love.graphics.line(love.graphics.getWidth() / 2, 0, love.graphics.getWidth() / 2, love.graphics.getHeight())
|
||||
love.graphics.line(0, love.graphics.getHeight() / 2, love.graphics.getWidth(), love.graphics.getHeight() / 2)
|
||||
end
|
||||
|
||||
function Debug:playerCenter()
|
||||
love.graphics.setColor(255, 100, 100)
|
||||
love.graphics.arc("fill", player.Ship.x, player.Ship.y, 3, 0, math.pi*2, 20)
|
||||
end
|
||||
|
||||
function Debug:fpsCounter()
|
||||
love.graphics.setFont(Render.debugFont)
|
||||
love.graphics.setColor(255, 255, 255)
|
||||
love.graphics.print("FPS: "..love.timer.getFPS(), 3, 2)
|
||||
end
|
||||
|
||||
function Debug:fuelNumber()
|
||||
love.graphics.setFont(Render.debugFont)
|
||||
local text = "Fuel: "..math.floor(player.Ship.Hull.fuelAmount).."/"..player.Ship.Hull.fuelCapacity
|
||||
local width = Render.debugFont:getWidth(text)
|
||||
love.graphics.setColor(100, 0, 0)
|
||||
love.graphics.rectangle("fill", 1, love.graphics.getHeight() - 13, width+3, love.graphics.getHeight() -2)
|
||||
love.graphics.setColor(255, 255, 255)
|
||||
love.graphics.print(text, 2, love.graphics.getHeight() - 13)
|
||||
end
|
||||
|
||||
return Debug
|
@@ -2,9 +2,7 @@ local class = require "lib.middleclass"
|
||||
|
||||
local Engine = class('Engine')
|
||||
|
||||
-- have hull limit rotationImpulse? yeah probably (take damage if above Hull's rotationImpulseLimit, but do warn about this so people don't usually do it)
|
||||
-- have a fuel effeciency multiplayer here
|
||||
function Engine:initialize(maximumSpeed, spaceDrag, speedLowerLimit, degreeLock, rotationImpulse, rotationDrag, rotationLowerLimit, Thrusters)
|
||||
function Engine:initialize(maximumSpeed, spaceDrag, speedLowerLimit, degreeLock, rotationImpulse, rotationDrag, rotationLowerLimit)
|
||||
self.maximumSpeed = maximumSpeed or 0 and console.d("Engine created with no maximumSpeed.")
|
||||
self.spaceDrag = spaceDrag or 0 and console.d("Engine created with no spaceDrag.")
|
||||
self.speedLowerLimit = speedLowerLimit or 0 and console.d("Engine created with no speedLowerLimit.")
|
||||
@@ -12,18 +10,6 @@ function Engine:initialize(maximumSpeed, spaceDrag, speedLowerLimit, degreeLock,
|
||||
self.rotationImpulse = rotationImpulse or 0 and console.e("Engine created with no rotationImpulse.")
|
||||
self.rotationDrag = rotationDrag or 0 and console.d("Engine created with no rotationDrag.")
|
||||
self.rotationLowerLimit = rotationLowerLimit or 0 and console.d("Engine created with no rotationLowerLimit.")
|
||||
|
||||
self.Thrusters = Thrusters or {} and console.d("Engine created with no Thrusters.")
|
||||
end
|
||||
|
||||
--[[
|
||||
function Thruster:draw(shipX, shipY, shipRotation)
|
||||
love.graphics.setColor(self.thrusterColor)
|
||||
love.graphics.line(shipX + self.thrusterX*math.cos(shipRotation) - self.thrusterY*math.sin(shipRotation),
|
||||
shipY + self.thrusterX*math.sin(shipRotation) + self.thrusterY*math.cos(shipRotation),
|
||||
shipX + self.thrusterX*math.cos(shipRotation) - (self.thrusterY+self.thrusterLength)*math.sin(shipRotation),
|
||||
shipY + self.thrusterX*math.sin(shipRotation) + (self.thrusterY+self.thrusterLength)*math.cos(shipRotation))
|
||||
end
|
||||
]]
|
||||
|
||||
return Engine
|
||||
|
@@ -2,12 +2,18 @@ local class = require "lib.middleclass"
|
||||
|
||||
local Hull = class('Hull')
|
||||
|
||||
function Hull:initialize(imgFile, imgScale, imgColor)
|
||||
function Hull:initialize(imgFile, imgScale, hitRadius, fuelCapacity, imgColor)
|
||||
-- image stuff
|
||||
self.image = love.graphics.newImage(imgFile) or love.graphics.newImage("images/no_hull.png") and console.e("Hull created with no image.")
|
||||
self.imgHalfWidth = self.image:getWidth() / 2
|
||||
self.imgHalfHeight = self.image:getHeight() / 2
|
||||
self.imgScale = imgScale or 1 and console.d("Hull created with no scale.")
|
||||
self.imgColor = imgColor or {255, 255, 255} and console.d("Hull created with no color (this is fine and normal).")
|
||||
|
||||
-- physics stuff
|
||||
self.hitRadius = hitRadius or self.image:getWidth() * 0.9 and console.d("Hull created with no hitRadius.") --defaults to 90% imgWidth
|
||||
self.fuelCapacity = fuelCapacity or 1000 and console.d("Hull created with no fuelCapacity.")
|
||||
self.fuelAmount = fuelCapacity or 1000
|
||||
end
|
||||
|
||||
return Hull
|
||||
|
44
src/Ship.lua
44
src/Ship.lua
@@ -34,13 +34,8 @@ local directions = {
|
||||
}
|
||||
|
||||
function Ship:accelerate(direction, dt)
|
||||
-- get amount of thrust based on which Thrusters fire that way
|
||||
local thrust = 0
|
||||
for i=1,#self.Thrusters do
|
||||
if self.Thrusters[i].direction == direction then
|
||||
thrust = thrust + self.Thrusters[i].thrust
|
||||
end
|
||||
end
|
||||
local thrust = Ship.static:fireThrusters(self, direction)
|
||||
if not thrust then return end -- if false, exit, out of fuel
|
||||
|
||||
-- here is where we actually apply acceleration
|
||||
self.v.x = self.v.x + thrust * math.cos(self.currentRotation - (self.currentRotation % self.Engine.degreeLock) + directions[direction]) * dt
|
||||
@@ -57,4 +52,39 @@ function Ship:accelerate(direction, dt)
|
||||
end
|
||||
end
|
||||
|
||||
function Ship:rotate(direction, dt)
|
||||
local haveFuel = Ship.static:fireThrusters(self, direction)
|
||||
if direction == "rotateleft" and haveFuel then
|
||||
self.rotationSpeed = self.rotationSpeed - self.Engine.rotationImpulse * dt
|
||||
elseif direction == "rotateright" and haveFuel then
|
||||
self.rotationSpeed = self.rotationSpeed + self.Engine.rotationImpulse * dt
|
||||
end
|
||||
end
|
||||
|
||||
-- Returns thrust generated or FALSE if ran out of fuel.
|
||||
function Ship.static:fireThrusters(self, direction)
|
||||
-- get amount of thrust and fuel usage based on which Thrusters fire in direction
|
||||
local thrust, fuelUsage = 0, 0
|
||||
--if direction == "rotateleft" or direction == "rotateright" then
|
||||
--look in the Engine..why do we need to do that?
|
||||
--else
|
||||
for i=1,#self.Thrusters do
|
||||
if self.Thrusters[i].direction == direction then
|
||||
thrust = thrust + self.Thrusters[i].thrust
|
||||
fuelUsage = fuelUsage + self.Thrusters[i].thrust * self.Thrusters[i].fuelEfficiency / 600 --60 for framerate, and 1/10 a 'unit'
|
||||
end
|
||||
end
|
||||
|
||||
-- use fuel, then check if out
|
||||
self.Hull.fuelAmount = self.Hull.fuelAmount - fuelUsage
|
||||
if self.Hull.fuelAmount < 0 then
|
||||
self.Hull.fuelAmount = 0
|
||||
console.d("Ran out of fuel!")
|
||||
return false
|
||||
end
|
||||
|
||||
-- finally return thrust amount
|
||||
return thrust
|
||||
end
|
||||
|
||||
return Ship
|
||||
|
@@ -1,23 +1,22 @@
|
||||
local forward = -math.pi/2
|
||||
local backward = math.pi/2
|
||||
local left = math.pi
|
||||
local right = 0
|
||||
|
||||
local class = require "lib.middleclass"
|
||||
|
||||
local Thruster = class('Thruster')
|
||||
|
||||
function Thruster:initialize(thrust, direction, thrusterX, thrusterY, thrusterColor, thrusterLength)
|
||||
function Thruster:initialize(thrust, direction, thrusterX, thrusterY, thrusterColor, thrusterLength, fuelEfficiency)
|
||||
self.thrust = thrust or 0 and console.e("Thruster created with no thrust.")
|
||||
self.direction = direction or 0 and console.d("Thruster created with no direction.")
|
||||
|
||||
self.thrusterX = thrusterX or nil and console.e("Thruster created with incomplete location.")
|
||||
self.thrusterY = thrusterY or nil and console.e("Thruster created with incomplete location.")
|
||||
self.thrusterColor = thrusterColor or {255, 255, 255} and console.d("Thruster created with no color.")
|
||||
self.thrusterLength = thrusterLength or 2 and console.d("Thruster created with no length.")
|
||||
|
||||
self.fuelEfficiency = fuelEfficiency or 1 and console.d("Thruster created with no fuelEfficiency.")
|
||||
end
|
||||
|
||||
function Thruster:draw(shipX, shipY, shipRotation)
|
||||
love.graphics.setColor(self.thrusterColor)
|
||||
love.graphics.setLineWidth(2)
|
||||
if self.direction == "forward" then
|
||||
love.graphics.line(shipX + self.thrusterX*math.cos(shipRotation) - self.thrusterY*math.sin(shipRotation),
|
||||
shipY + self.thrusterX*math.sin(shipRotation) + self.thrusterY*math.cos(shipRotation),
|
||||
|
62
src/conf.lua
62
src/conf.lua
@@ -1,35 +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.identity = "SpaceLove" -- 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.window.title = "SpaceLove v0.0.0.whatever" -- 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)
|
||||
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
|
||||
|
139
src/main.lua
139
src/main.lua
@@ -1,9 +1,3 @@
|
||||
local player
|
||||
local Render = {
|
||||
jitter = false,
|
||||
jitterLevel = 2,
|
||||
}
|
||||
|
||||
--very very temporary
|
||||
console = {
|
||||
e = function() end,
|
||||
@@ -11,61 +5,61 @@ console = {
|
||||
}
|
||||
|
||||
-- Classes
|
||||
local Player = require "player"
|
||||
local Player = require "Player"
|
||||
local Ship = require "Ship"
|
||||
local Hull = require "Hull"
|
||||
local Shield = require "Shield"
|
||||
local Engine = require "Engine"
|
||||
local Thruster = require "Thruster"
|
||||
|
||||
function love.load()
|
||||
-- Create the player
|
||||
player = Player(Ship(
|
||||
Hull("images/fighter1.png", 1.5),
|
||||
Shield("images/shieldhit1.png", 1.6),
|
||||
Engine(40000, 0.95, 10, 7.5, 33, 0.93, 0.5,
|
||||
{
|
||||
Thruster(0, "rotateleft", 4.4, -16, {250, 200, 200}, 0.4),
|
||||
Thruster(0, "rotateleft", -11, 14.3, {255, 230, 230}, 0.6),
|
||||
Thruster(0, "rotateleft", 13, 11, {250, 200, 200}, 0.6),
|
||||
Thruster(0, "rotateright", -4.8, -16, {250, 200, 200}, 0.4),
|
||||
Thruster(0, "rotateright", 10.4, 14.3, {255, 230, 230}, 0.6),
|
||||
Thruster(0, "rotateright", -13.6, 11, {250, 200, 200}, 0.6),
|
||||
}),
|
||||
{
|
||||
Thruster(1300, "forward", -8.5, 16.5, {160, 250, 255}, 2.4),
|
||||
Thruster(1300, "forward", 8.5, 16.5, {160, 250, 255}, 2.4),
|
||||
Thruster(650, "backward", -13, 1.8, {200, 240, 255}, 1.8),
|
||||
Thruster(650, "backward", 13, 1.8, {200, 240, 255}, 1.8),
|
||||
Thruster(320, "left", 6, -4.4, {220, 230, 250}, 0.6),
|
||||
Thruster(540, "left", 17.5, 5.5, {220, 230, 250}, 1.2),
|
||||
Thruster(320, "right", -6, -4.4, {220, 230, 250}, 0.6),
|
||||
Thruster(540, "right", -17.5, 5.5, {220, 230, 250}, 1.2),
|
||||
},
|
||||
{
|
||||
x = love.graphics.getWidth() / 2,
|
||||
y = love.graphics.getHeight() / 2,
|
||||
v = {
|
||||
x = 0,
|
||||
y = 0
|
||||
},
|
||||
currentRotation = 0,
|
||||
rotationSpeed = 0
|
||||
}
|
||||
))
|
||||
local Debug = require "Debug"
|
||||
|
||||
--font!
|
||||
love.graphics.setNewFont("fonts/Audimat Mono Regular.ttf", 16)
|
||||
--line width!
|
||||
love.graphics.setLineWidth(2)
|
||||
end
|
||||
-- GLOBALS
|
||||
Render = {
|
||||
jitter = false,
|
||||
jitterLevel = 2,
|
||||
debugFont = love.graphics.newFont(10),
|
||||
hudFont = love.graphics.newFont("fonts/Audimat Mono Regular.ttf", 16),
|
||||
}
|
||||
|
||||
player = Player(Ship(
|
||||
Hull("images/fighter1.png", 1.5, 16, 10000),
|
||||
Shield("images/shieldhit1.png", 1.6),
|
||||
Engine(40000, 0.95, 10, 7.5, 33, 0.93, 0.5),
|
||||
{
|
||||
Thruster(1300, "forward", -8.5, 16.5, {160, 250, 255}, 2.4, 0.7),
|
||||
Thruster(1300, "forward", 8.5, 16.5, {160, 250, 255}, 2.4, 0.7),
|
||||
Thruster(650, "backward", -13, 1.8, {200, 240, 255}, 1.8, 0.8),
|
||||
Thruster(650, "backward", 13, 1.8, {200, 240, 255}, 1.8, 0.8),
|
||||
Thruster(320, "left", 6, -4.4, {220, 230, 250}, 0.6, 1),
|
||||
Thruster(540, "left", 17.5, 5.5, {220, 230, 250}, 1.2, 0.9),
|
||||
Thruster(320, "right", -6, -4.4, {220, 230, 250}, 0.6, 1),
|
||||
Thruster(540, "right", -17.5, 5.5, {220, 230, 250}, 1.2, 0.9),
|
||||
Thruster(90, "rotateleft", 4.4, -16, {250, 200, 200}, 0.4, 1.1),
|
||||
Thruster(110, "rotateleft", -11, 14.3, {255, 230, 230}, 0.6, 1),
|
||||
Thruster(110, "rotateleft", 13, 11, {250, 200, 200}, 0.6, 1),
|
||||
Thruster(90, "rotateright", -4.8, -16, {250, 200, 200}, 0.4, 1.1),
|
||||
Thruster(110, "rotateright", 10.4, 14.3, {255, 230, 230}, 0.6, 1),
|
||||
Thruster(110, "rotateright", -13.6, 11, {250, 200, 200}, 0.6, 1),
|
||||
},
|
||||
{
|
||||
x = love.graphics.getWidth() / 2,
|
||||
y = love.graphics.getHeight() / 2,
|
||||
v = {
|
||||
x = 0,
|
||||
y = 0
|
||||
},
|
||||
currentRotation = 0,
|
||||
rotationSpeed = 0
|
||||
}
|
||||
))
|
||||
|
||||
function love.update(dt)
|
||||
-- player rotation input
|
||||
if love.keyboard.isDown('q') or love.keyboard.isDown('a') then
|
||||
player.Ship.rotationSpeed = player.Ship.rotationSpeed - player.Ship.Engine.rotationImpulse * dt
|
||||
player.Ship:rotate("rotateleft", dt)
|
||||
elseif love.keyboard.isDown('e') or love.keyboard.isDown('d') then
|
||||
player.Ship.rotationSpeed = player.Ship.rotationSpeed + player.Ship.Engine.rotationImpulse * dt
|
||||
player.Ship:rotate("rotateright", dt)
|
||||
end
|
||||
|
||||
-- player rotationSpeed adjustment
|
||||
@@ -114,16 +108,8 @@ function love.update(dt)
|
||||
end
|
||||
|
||||
function love.draw()
|
||||
-- FPS in title
|
||||
--change this to be a line displayed on screen
|
||||
love.window.setTitle("FPS: "..love.timer.getFPS())
|
||||
|
||||
-- Red Lines for debug purposes
|
||||
---[[
|
||||
love.graphics.setColor(255, 0, 0)
|
||||
love.graphics.line(love.graphics.getWidth() / 2, 0, love.graphics.getWidth() / 2, love.graphics.getHeight())
|
||||
love.graphics.line(0, love.graphics.getHeight() / 2, love.graphics.getWidth(), love.graphics.getHeight() / 2)
|
||||
--]]
|
||||
-- Debug below!
|
||||
Debug:drawBelow()
|
||||
|
||||
-- Ship draw
|
||||
love.graphics.setColor(255, 255, 255)
|
||||
@@ -138,56 +124,55 @@ function love.draw()
|
||||
--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)
|
||||
|
||||
-- Thruster draws
|
||||
if love.keyboard.isDown('w') then
|
||||
if love.keyboard.isDown('w') and player.Ship.Hull.fuelAmount > 0 then
|
||||
for i=1,#player.Ship.Thrusters do
|
||||
if player.Ship.Thrusters[i].direction == "forward" then
|
||||
player.Ship.Thrusters[i]:draw(player.Ship.x, player.Ship.y, player.Ship.currentRotation - (player.Ship.currentRotation % player.Ship.Engine.degreeLock))
|
||||
end
|
||||
end
|
||||
elseif love.keyboard.isDown('s') then
|
||||
elseif love.keyboard.isDown('s') and player.Ship.Hull.fuelAmount > 0 then
|
||||
for i=1,#player.Ship.Thrusters do
|
||||
if player.Ship.Thrusters[i].direction == "backward" then
|
||||
player.Ship.Thrusters[i]:draw(player.Ship.x, player.Ship.y, player.Ship.currentRotation - (player.Ship.currentRotation % player.Ship.Engine.degreeLock))
|
||||
end
|
||||
end
|
||||
end
|
||||
if love.keyboard.isDown('j') then
|
||||
if love.keyboard.isDown('j') and player.Ship.Hull.fuelAmount > 0 then
|
||||
for i=1,#player.Ship.Thrusters do
|
||||
if player.Ship.Thrusters[i].direction == "left" then
|
||||
player.Ship.Thrusters[i]:draw(player.Ship.x, player.Ship.y, player.Ship.currentRotation - (player.Ship.currentRotation % player.Ship.Engine.degreeLock))
|
||||
end
|
||||
end
|
||||
elseif love.keyboard.isDown('l') then
|
||||
elseif love.keyboard.isDown('l') and player.Ship.Hull.fuelAmount > 0 then
|
||||
for i=1,#player.Ship.Thrusters do
|
||||
if player.Ship.Thrusters[i].direction == "right" then
|
||||
player.Ship.Thrusters[i]:draw(player.Ship.x, player.Ship.y, player.Ship.currentRotation - (player.Ship.currentRotation % player.Ship.Engine.degreeLock))
|
||||
end
|
||||
end
|
||||
end
|
||||
if love.keyboard.isDown('q') or love.keyboard.isDown('a') then
|
||||
for i=1,#player.Ship.Engine.Thrusters do
|
||||
if player.Ship.Engine.Thrusters[i].direction == "rotateleft" then
|
||||
player.Ship.Engine.Thrusters[i]:draw(player.Ship.x, player.Ship.y, player.Ship.currentRotation - (player.Ship.currentRotation % player.Ship.Engine.degreeLock))
|
||||
if love.keyboard.isDown('q') and player.Ship.Hull.fuelAmount > 0 or love.keyboard.isDown('a') and player.Ship.Hull.fuelAmount > 0 then
|
||||
for i=1,#player.Ship.Thrusters do
|
||||
if player.Ship.Thrusters[i].direction == "rotateleft" then
|
||||
player.Ship.Thrusters[i]:draw(player.Ship.x, player.Ship.y, player.Ship.currentRotation - (player.Ship.currentRotation % player.Ship.Engine.degreeLock))
|
||||
end
|
||||
end
|
||||
elseif love.keyboard.isDown('e') or love.keyboard.isDown('d') then
|
||||
for i=1,#player.Ship.Engine.Thrusters do
|
||||
if player.Ship.Engine.Thrusters[i].direction == "rotateright" then
|
||||
player.Ship.Engine.Thrusters[i]:draw(player.Ship.x, player.Ship.y, player.Ship.currentRotation - (player.Ship.currentRotation % player.Ship.Engine.degreeLock))
|
||||
elseif love.keyboard.isDown('e') and player.Ship.Hull.fuelAmount > 0 or love.keyboard.isDown('d') and player.Ship.Hull.fuelAmount > 0 then
|
||||
for i=1,#player.Ship.Thrusters do
|
||||
if player.Ship.Thrusters[i].direction == "rotateright" then
|
||||
player.Ship.Thrusters[i]:draw(player.Ship.x, player.Ship.y, player.Ship.currentRotation - (player.Ship.currentRotation % player.Ship.Engine.degreeLock))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Fuel UI draw
|
||||
love.graphics.setColor(175, 255, 255)
|
||||
love.graphics.setFont(Render.hudFont)
|
||||
love.graphics.print("FUEL", 3, love.graphics.getHeight() - 30)
|
||||
love.graphics.setLineWidth(2)
|
||||
love.graphics.rectangle("line", 3, love.graphics.getHeight() - 13, 125, 10)
|
||||
love.graphics.setColor(175, 255, 25) --change to be based on fuel amount
|
||||
love.graphics.rectangle("fill", 4, love.graphics.getHeight() - 12, 120, 8) --max width is 123
|
||||
love.graphics.rectangle("fill", 4, love.graphics.getHeight() - 12, player.Ship.Hull.fuelAmount / player.Ship.Hull.fuelCapacity * 123, 8) --max width is 123
|
||||
|
||||
-- Pink arc for debug purposes
|
||||
---[[
|
||||
love.graphics.setColor(255, 100, 100)
|
||||
love.graphics.arc("fill", player.Ship.x, player.Ship.y, 3, 0, math.pi*2, 20)
|
||||
--]]
|
||||
-- Debug above!
|
||||
Debug:drawAbove()
|
||||
end
|
||||
|
Reference in New Issue
Block a user