diff --git a/entities/ship/ship.lua b/entities/ship/ship.lua index f1c7050..e2e2a2f 100644 --- a/entities/ship/ship.lua +++ b/entities/ship/ship.lua @@ -8,6 +8,7 @@ self.ox = x self.oy = y self.dy = 0 self.dx = 5 +self.speed = 1 self.image = love.graphics.newImage(image) self.width = self.image:getWidth() self.height = self.image:getHeight() @@ -34,8 +35,8 @@ function ship:update(dt) if love.timer.getFPS() < 20 then self.path = {} end - self.x = self.x + self.dx/2 - self.y = self.y + self.dy/2 + self.x = self.x + self.dx*self.speed/2 + self.y = self.y + self.dy*self.speed/2 if self.dx ~= 0 then self.vector = math.atan( self.dy/ self.dx) end @@ -49,10 +50,8 @@ function ship:update(dt) end ]]-- if love.keyboard.isDown('w') and self.fuel > 0 then self.fuel = self.fuel - 0.5 - self.speed = math.sqrt(self.dx^2 + self.dy^2) - self.speed = self.speed + 0.5 - self.dx = math.cos(self.vector) * self.speed - self.dy = math.sin(self.vector) * self.speed + self.speed = self.speed + 0.05 + end --[[ if love.keyboard.isDown('left') then @@ -112,7 +111,7 @@ function ship:reset() self.rotation = 1.57 self.canvas = love.graphics.newCanvas(WINDOW_WIDTH, WINDOW_HEIGHT) self.vector = 1.56 - self.speed = 0 + self.speed = 1 self.path = {} self.dottimer = 0.5 end diff --git a/levels/level1.lua b/levels/level1.lua index 5194d06..1838e39 100644 --- a/levels/level1.lua +++ b/levels/level1.lua @@ -3,8 +3,8 @@ local levelLoaded = false local M = {} function level1.load() shipsleft = 1 - thrusterMax = 50 - firstShip.fuel = 50 + thrusterMax = 25 + firstShip.fuel = 25 local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png") planetsleft = 3 gameStatus = "setup" @@ -31,7 +31,7 @@ function level1.load() table.insert(guibutts, menu:addButton("To menu", function () level.goBack() end)) - -- table.insert(planets, planet(700, 200, 50, 0.3, planetImage, "nodelete")) + table.insert(planets, planet(700, 200, 50, 0.3, planetImage, "nodelete")) end function level1.reset() firstShip:reset() @@ -42,7 +42,7 @@ function level1.reset() table.insert(planets, planet(700, 200, 50, 0.3, planetImage)) shipsleft = 1 shipIsHit = false - firstShip.fuel = 50 + firstShip.fuel = 25 planetsleft = 3 end function level1.GUIControl() diff --git a/levels/level2.lua b/levels/level2.lua index 79c9ffe..80eab2d 100644 --- a/levels/level2.lua +++ b/levels/level2.lua @@ -5,8 +5,8 @@ function level2.load() shipsleft = 1 local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png") planetsleft = 3 - thrusterMax = 100 - firstShip.fuel = 100 + thrusterMax = 50 + firstShip.fuel = 50 gameStatus = "setup" playbutts = {} guibutts = {} @@ -38,7 +38,7 @@ function level2.reset() for k in pairs(planets) do planets[k] = nil end - firstShip.fuel = 100 + firstShip.fuel = 50 local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png") table.insert(planets, planet(700, 500, 50, 0.3, planetImage)) shipsleft = 1 diff --git a/levels/level3.lua b/levels/level3.lua index ff8cd07..0d74ec8 100644 --- a/levels/level3.lua +++ b/levels/level3.lua @@ -7,8 +7,8 @@ function level3.load() planetsleft = 3 gameStatus = "setup" playbutts = {} - thrusterMax = 150 - firstShip.fuel = 150 + thrusterMax = 75 + firstShip.fuel = 75 guibutts = {} VCAM.x, VCAM.y = WINDOW_WIDTH/2, WINDOW_HEIGHT/2 explosions = {} @@ -45,7 +45,7 @@ function level3.reset() end local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png") shipsleft = 1 - firstShip.fuel = 150 + firstShip.fuel = 75 shipIsHit = false planetsleft = 3 end diff --git a/levels/level4.lua b/levels/level4.lua index 1ba04f3..cc0ec1a 100644 --- a/levels/level4.lua +++ b/levels/level4.lua @@ -8,8 +8,8 @@ function level4.load() gameStatus = "setup" playbutts = {} guibutts = {} - thrusterMax = 200 - firstShip.fuel = 200 + thrusterMax = 100 + firstShip.fuel = 100 VCAM.x, VCAM.y = WINDOW_WIDTH/2, WINDOW_HEIGHT/2 explosions = {} shipIsHit = false @@ -44,7 +44,7 @@ function level4.reset() end local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png") shipsleft = 1 - firstShip.fuel = 200 + firstShip.fuel = 100 shipIsHit = false planetsleft = 3 end diff --git a/levels/levelgeneral.lua b/levels/levelgeneral.lua index 763e6ab..4e35233 100644 --- a/levels/levelgeneral.lua +++ b/levels/levelgeneral.lua @@ -98,13 +98,13 @@ function levelgeneral.draw() GUIDraw("left") elseif gameStatus == "play" then if not reachedGoal then - love.graphics.printf("Thrusters: ", 0, WINDOW_HEIGHT-50, 600, "center") + love.graphics.printf("Thrusters: ", 0, WINDOW_HEIGHT-100, 300, "center") local m = smallfont:getWidth("Thrusters: ") local n = smallfont:getHeight("Thrusters: ") love.graphics.setColor(1,0,0,1) - love.graphics.rectangle("fill",m + 100, WINDOW_HEIGHT-50, thrusterMax/2, n) + love.graphics.rectangle("fill",0, WINDOW_HEIGHT-50, thrusterMax/2, n) love.graphics.setColor(0,1,0,1) - love.graphics.rectangle("fill",m + 100, WINDOW_HEIGHT-50, firstShip.fuel/2, n) + love.graphics.rectangle("fill",0, WINDOW_HEIGHT-50, firstShip.fuel/2, n) love.graphics.setColor(1,1,1,1) guimenu:butt(playbutts, WINDOW_WIDTH, WINDOW_HEIGHT, 1100, WINDOW_HEIGHT-50, 40, WINDOW_WIDTH/3) end diff --git a/levels/menu.lua b/levels/menu.lua index 05d13cf..d007a42 100644 --- a/levels/menu.lua +++ b/levels/menu.lua @@ -4,7 +4,6 @@ menuLoaded = false function menu.update(dt) if not menuLoaded then firstShip.x = -100 - firstShip.speed = 10 firstShip.y = love.math.random(0, WINDOW_HEIGHT) menuLoaded = true table.insert(planets, planet(love.math.random(100, WINDOW_WIDTH-100), love.math.random(100, WINDOW_HEIGHT-100), 90000000, 0.3, love.graphics.newImage("entities/planet/planet.png"))) @@ -20,7 +19,6 @@ function menu.update(dt) shipIsHit = false firstShip:reset() firstShip.x = -100 - firstShip.speed = 10 firstShip.y = love.math.random(0, WINDOW_HEIGHT) --print("ship is hit") end diff --git a/levels/selectlv.lua b/levels/selectlv.lua index 299cbe6..fbb11be 100644 --- a/levels/selectlv.lua +++ b/levels/selectlv.lua @@ -40,7 +40,6 @@ local M = {} function selectlv.update(dt) if not menuLoaded then firstShip.x = -100 - firstShip.speed = 10 firstShip.y = love.math.random(0, WINDOW_HEIGHT) menuLoaded = true table.insert(planets, planet(love.math.random(100, WINDOW_WIDTH-100), love.math.random(100, WINDOW_HEIGHT-100), 90000000, 0.3, love.graphics.newImage("entities/planet/planet.png"))) @@ -53,7 +52,6 @@ function selectlv.update(dt) shipIsHit = false firstShip:reset() firstShip.x = -100 - firstShip.speed = 10 firstShip.y = love.math.random(0, WINDOW_HEIGHT) --print("ship is hit") end diff --git a/src/GUI.lua b/src/GUI.lua index 081e135..20f7968 100644 --- a/src/GUI.lua +++ b/src/GUI.lua @@ -223,6 +223,7 @@ function GUIButton(num, shipImage, x, y, fn, sx, sy, color, r) if pressed and hot then love.keyboard.mouseisReleased = false fn() + hot = false end love.graphics.draw(shipImage,x,y, r, sx, sy, shipW/2, shipH/2) love.graphics.print("x" .. num,x+10,y) diff --git a/src/mainMenu.lua b/src/mainMenu.lua index cf08c53..1ba996a 100644 --- a/src/mainMenu.lua +++ b/src/mainMenu.lua @@ -24,6 +24,7 @@ function mainMenu:butt(buttons, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, locationx, locati if button.now and hot == i then love.keyboard.mouseisReleased = false button.fn() + hot = false break end if arg == "beatenGreen" then