Browse Source

Redid speed

tags/earlywindows
Madiwka 3 years ago
parent
commit
0d432d48b3
10 changed files with 24 additions and 27 deletions
  1. +6
    -7
      entities/ship/ship.lua
  2. +4
    -4
      levels/level1.lua
  3. +3
    -3
      levels/level2.lua
  4. +3
    -3
      levels/level3.lua
  5. +3
    -3
      levels/level4.lua
  6. +3
    -3
      levels/levelgeneral.lua
  7. +0
    -2
      levels/menu.lua
  8. +0
    -2
      levels/selectlv.lua
  9. +1
    -0
      src/GUI.lua
  10. +1
    -0
      src/mainMenu.lua

+ 6
- 7
entities/ship/ship.lua View File

@@ -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

+ 4
- 4
levels/level1.lua View File

@@ -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()


+ 3
- 3
levels/level2.lua View File

@@ -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


+ 3
- 3
levels/level3.lua View File

@@ -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


+ 3
- 3
levels/level4.lua View File

@@ -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


+ 3
- 3
levels/levelgeneral.lua View File

@@ -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


+ 0
- 2
levels/menu.lua View File

@@ -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


+ 0
- 2
levels/selectlv.lua View File

@@ -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


+ 1
- 0
src/GUI.lua View File

@@ -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)


+ 1
- 0
src/mainMenu.lua View File

@@ -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


Loading…
Cancel
Save