@@ -8,6 +8,7 @@ self.ox = x | |||||
self.oy = y | self.oy = y | ||||
self.dy = 0 | self.dy = 0 | ||||
self.dx = 5 | self.dx = 5 | ||||
self.speed = 1 | |||||
self.image = love.graphics.newImage(image) | self.image = love.graphics.newImage(image) | ||||
self.width = self.image:getWidth() | self.width = self.image:getWidth() | ||||
self.height = self.image:getHeight() | self.height = self.image:getHeight() | ||||
@@ -34,8 +35,8 @@ function ship:update(dt) | |||||
if love.timer.getFPS() < 20 then | if love.timer.getFPS() < 20 then | ||||
self.path = {} | self.path = {} | ||||
end | 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 | if self.dx ~= 0 then | ||||
self.vector = math.atan( self.dy/ self.dx) | self.vector = math.atan( self.dy/ self.dx) | ||||
end | end | ||||
@@ -49,10 +50,8 @@ function ship:update(dt) | |||||
end ]]-- | end ]]-- | ||||
if love.keyboard.isDown('w') and self.fuel > 0 then | if love.keyboard.isDown('w') and self.fuel > 0 then | ||||
self.fuel = self.fuel - 0.5 | 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 | end | ||||
--[[ | --[[ | ||||
if love.keyboard.isDown('left') then | if love.keyboard.isDown('left') then | ||||
@@ -112,7 +111,7 @@ function ship:reset() | |||||
self.rotation = 1.57 | self.rotation = 1.57 | ||||
self.canvas = love.graphics.newCanvas(WINDOW_WIDTH, WINDOW_HEIGHT) | self.canvas = love.graphics.newCanvas(WINDOW_WIDTH, WINDOW_HEIGHT) | ||||
self.vector = 1.56 | self.vector = 1.56 | ||||
self.speed = 0 | |||||
self.speed = 1 | |||||
self.path = {} | self.path = {} | ||||
self.dottimer = 0.5 | self.dottimer = 0.5 | ||||
end | end |
@@ -3,8 +3,8 @@ local levelLoaded = false | |||||
local M = {} | local M = {} | ||||
function level1.load() | function level1.load() | ||||
shipsleft = 1 | 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") | local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png") | ||||
planetsleft = 3 | planetsleft = 3 | ||||
gameStatus = "setup" | gameStatus = "setup" | ||||
@@ -31,7 +31,7 @@ function level1.load() | |||||
table.insert(guibutts, menu:addButton("To menu", function () | table.insert(guibutts, menu:addButton("To menu", function () | ||||
level.goBack() | level.goBack() | ||||
end)) | end)) | ||||
-- table.insert(planets, planet(700, 200, 50, 0.3, planetImage, "nodelete")) | |||||
table.insert(planets, planet(700, 200, 50, 0.3, planetImage, "nodelete")) | |||||
end | end | ||||
function level1.reset() | function level1.reset() | ||||
firstShip:reset() | firstShip:reset() | ||||
@@ -42,7 +42,7 @@ function level1.reset() | |||||
table.insert(planets, planet(700, 200, 50, 0.3, planetImage)) | table.insert(planets, planet(700, 200, 50, 0.3, planetImage)) | ||||
shipsleft = 1 | shipsleft = 1 | ||||
shipIsHit = false | shipIsHit = false | ||||
firstShip.fuel = 50 | |||||
firstShip.fuel = 25 | |||||
planetsleft = 3 | planetsleft = 3 | ||||
end | end | ||||
function level1.GUIControl() | function level1.GUIControl() | ||||
@@ -5,8 +5,8 @@ function level2.load() | |||||
shipsleft = 1 | shipsleft = 1 | ||||
local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png") | local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png") | ||||
planetsleft = 3 | planetsleft = 3 | ||||
thrusterMax = 100 | |||||
firstShip.fuel = 100 | |||||
thrusterMax = 50 | |||||
firstShip.fuel = 50 | |||||
gameStatus = "setup" | gameStatus = "setup" | ||||
playbutts = {} | playbutts = {} | ||||
guibutts = {} | guibutts = {} | ||||
@@ -38,7 +38,7 @@ function level2.reset() | |||||
for k in pairs(planets) do | for k in pairs(planets) do | ||||
planets[k] = nil | planets[k] = nil | ||||
end | end | ||||
firstShip.fuel = 100 | |||||
firstShip.fuel = 50 | |||||
local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png") | local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png") | ||||
table.insert(planets, planet(700, 500, 50, 0.3, planetImage)) | table.insert(planets, planet(700, 500, 50, 0.3, planetImage)) | ||||
shipsleft = 1 | shipsleft = 1 | ||||
@@ -7,8 +7,8 @@ function level3.load() | |||||
planetsleft = 3 | planetsleft = 3 | ||||
gameStatus = "setup" | gameStatus = "setup" | ||||
playbutts = {} | playbutts = {} | ||||
thrusterMax = 150 | |||||
firstShip.fuel = 150 | |||||
thrusterMax = 75 | |||||
firstShip.fuel = 75 | |||||
guibutts = {} | guibutts = {} | ||||
VCAM.x, VCAM.y = WINDOW_WIDTH/2, WINDOW_HEIGHT/2 | VCAM.x, VCAM.y = WINDOW_WIDTH/2, WINDOW_HEIGHT/2 | ||||
explosions = {} | explosions = {} | ||||
@@ -45,7 +45,7 @@ function level3.reset() | |||||
end | end | ||||
local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png") | local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png") | ||||
shipsleft = 1 | shipsleft = 1 | ||||
firstShip.fuel = 150 | |||||
firstShip.fuel = 75 | |||||
shipIsHit = false | shipIsHit = false | ||||
planetsleft = 3 | planetsleft = 3 | ||||
end | end | ||||
@@ -8,8 +8,8 @@ function level4.load() | |||||
gameStatus = "setup" | gameStatus = "setup" | ||||
playbutts = {} | playbutts = {} | ||||
guibutts = {} | guibutts = {} | ||||
thrusterMax = 200 | |||||
firstShip.fuel = 200 | |||||
thrusterMax = 100 | |||||
firstShip.fuel = 100 | |||||
VCAM.x, VCAM.y = WINDOW_WIDTH/2, WINDOW_HEIGHT/2 | VCAM.x, VCAM.y = WINDOW_WIDTH/2, WINDOW_HEIGHT/2 | ||||
explosions = {} | explosions = {} | ||||
shipIsHit = false | shipIsHit = false | ||||
@@ -44,7 +44,7 @@ function level4.reset() | |||||
end | end | ||||
local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png") | local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png") | ||||
shipsleft = 1 | shipsleft = 1 | ||||
firstShip.fuel = 200 | |||||
firstShip.fuel = 100 | |||||
shipIsHit = false | shipIsHit = false | ||||
planetsleft = 3 | planetsleft = 3 | ||||
end | end | ||||
@@ -98,13 +98,13 @@ function levelgeneral.draw() | |||||
GUIDraw("left") | GUIDraw("left") | ||||
elseif gameStatus == "play" then | elseif gameStatus == "play" then | ||||
if not reachedGoal 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 m = smallfont:getWidth("Thrusters: ") | ||||
local n = smallfont:getHeight("Thrusters: ") | local n = smallfont:getHeight("Thrusters: ") | ||||
love.graphics.setColor(1,0,0,1) | 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.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) | love.graphics.setColor(1,1,1,1) | ||||
guimenu:butt(playbutts, WINDOW_WIDTH, WINDOW_HEIGHT, 1100, WINDOW_HEIGHT-50, 40, WINDOW_WIDTH/3) | guimenu:butt(playbutts, WINDOW_WIDTH, WINDOW_HEIGHT, 1100, WINDOW_HEIGHT-50, 40, WINDOW_WIDTH/3) | ||||
end | end | ||||
@@ -4,7 +4,6 @@ menuLoaded = false | |||||
function menu.update(dt) | function menu.update(dt) | ||||
if not menuLoaded then | if not menuLoaded then | ||||
firstShip.x = -100 | firstShip.x = -100 | ||||
firstShip.speed = 10 | |||||
firstShip.y = love.math.random(0, WINDOW_HEIGHT) | firstShip.y = love.math.random(0, WINDOW_HEIGHT) | ||||
menuLoaded = true | 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"))) | 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 | shipIsHit = false | ||||
firstShip:reset() | firstShip:reset() | ||||
firstShip.x = -100 | firstShip.x = -100 | ||||
firstShip.speed = 10 | |||||
firstShip.y = love.math.random(0, WINDOW_HEIGHT) | firstShip.y = love.math.random(0, WINDOW_HEIGHT) | ||||
--print("ship is hit") | --print("ship is hit") | ||||
end | end | ||||
@@ -40,7 +40,6 @@ local M = {} | |||||
function selectlv.update(dt) | function selectlv.update(dt) | ||||
if not menuLoaded then | if not menuLoaded then | ||||
firstShip.x = -100 | firstShip.x = -100 | ||||
firstShip.speed = 10 | |||||
firstShip.y = love.math.random(0, WINDOW_HEIGHT) | firstShip.y = love.math.random(0, WINDOW_HEIGHT) | ||||
menuLoaded = true | 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"))) | 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 | shipIsHit = false | ||||
firstShip:reset() | firstShip:reset() | ||||
firstShip.x = -100 | firstShip.x = -100 | ||||
firstShip.speed = 10 | |||||
firstShip.y = love.math.random(0, WINDOW_HEIGHT) | firstShip.y = love.math.random(0, WINDOW_HEIGHT) | ||||
--print("ship is hit") | --print("ship is hit") | ||||
end | end | ||||
@@ -223,6 +223,7 @@ function GUIButton(num, shipImage, x, y, fn, sx, sy, color, r) | |||||
if pressed and hot then | if pressed and hot then | ||||
love.keyboard.mouseisReleased = false | love.keyboard.mouseisReleased = false | ||||
fn() | fn() | ||||
hot = false | |||||
end | end | ||||
love.graphics.draw(shipImage,x,y, r, sx, sy, shipW/2, shipH/2) | love.graphics.draw(shipImage,x,y, r, sx, sy, shipW/2, shipH/2) | ||||
love.graphics.print("x" .. num,x+10,y) | love.graphics.print("x" .. num,x+10,y) | ||||
@@ -24,6 +24,7 @@ function mainMenu:butt(buttons, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, locationx, locati | |||||
if button.now and hot == i then | if button.now and hot == i then | ||||
love.keyboard.mouseisReleased = false | love.keyboard.mouseisReleased = false | ||||
button.fn() | button.fn() | ||||
hot = false | |||||
break | break | ||||
end | end | ||||
if arg == "beatenGreen" then | if arg == "beatenGreen" then | ||||