Browse Source

Bug fixes

tags/8.1
Madiwka3 3 years ago
parent
commit
b2af5195a7
7 changed files with 44 additions and 50 deletions
  1. +2
    -0
      entities/ship/ship.lua
  2. +10
    -6
      explosion.lua
  3. +4
    -10
      levels/level7.lua
  4. +6
    -9
      levels/levelgeneral.lua
  5. +8
    -15
      levels/practice.lua
  6. +10
    -2
      main.lua
  7. +4
    -8
      src/GUI.lua

+ 2
- 0
entities/ship/ship.lua View File

@@ -19,6 +19,7 @@ self.vector = 1.5708
self.color = {1,1,1,1} self.color = {1,1,1,1}
self.path = {} self.path = {}
self.dottimer = 0.5 self.dottimer = 0.5
self.exploded = false
self.fuel = 0 self.fuel = 0
self.destX = x self.destX = x
end end
@@ -147,4 +148,5 @@ function ship:reset()
self.destX = self.x self.destX = self.x
self.path = {} self.path = {}
self.dottimer = 0.5 self.dottimer = 0.5
self.exploded = false
end end

+ 10
- 6
explosion.lua View File

@@ -7,6 +7,7 @@ function explosion:init(x, y, v, color, type)
self.y = y self.y = y
self.v = v self.v = v
self.range = 0 self.range = 0
self.maxRange = WINDOW_WIDTH*2
self.killed = false self.killed = false
if type ~= nil then if type ~= nil then
self.type = type self.type = type
@@ -16,14 +17,17 @@ end


function explosion:update(dt) function explosion:update(dt)
self.range = self.range + dt * 24 self.range = self.range + dt * 24
local maxRange = WINDOW_WIDTH*2
if (self.type == 0) then
--print("my range is " .. self.range)
end
self.maxRange = WINDOW_WIDTH*2
if self.type == 1 then if self.type == 1 then
maxRange = WINDOW_WIDTH*6
self.maxRange = WINDOW_WIDTH*6
elseif self.type == 2 then elseif self.type == 2 then
maxRange = 200
self.maxRange = 200
end end
if self.range * self.v > maxRange then
--print("killing myself with range" .. self.range)
if self.range * self.v > self.maxRange then
--print("killing myself with range" .. self.range .. " " .. self.v .. " " .. self.maxRange .. " and type " .. self.type)
self.killed = true self.killed = true
end end
end end
@@ -36,7 +40,7 @@ function explosion:render(toggle)
if self.type == 2 then if self.type == 2 then
love.graphics.setColor(1,1,1,0.7/(self.range)) love.graphics.setColor(1,1,1,0.7/(self.range))
-- print(self.range) -- print(self.range)
elseif toggle == "special" then
elseif self.type == 1 then
love.graphics.setColor(1,1,1,0.7/(self.range/6)) love.graphics.setColor(1,1,1,0.7/(self.range/6))
-- print(self.range) -- print(self.range)
end end


+ 4
- 10
levels/level7.lua View File

@@ -1,15 +1,7 @@
level7 = Class{} level7 = Class{}
local levelLoaded = false local levelLoaded = false
local M = {} local M = {}
function love.wheelmoved(x, y)
if gameStatus == "play" then
if y > 0 and camera.scale < 1 then
camera.scale = camera.scale + 0.1
elseif y < 0 and camera.scale > 0.5 then
camera.scale = camera.scale - 0.1
end
end
end

function level7.load() function level7.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")
@@ -23,6 +15,7 @@ function level7.load()
explosions = {} explosions = {}
shipIsHit = false shipIsHit = false
guimenu = mainMenu() guimenu = mainMenu()
cameraControl = true
reachedGoal = false reachedGoal = false
lvlbase = base(1400, WINDOW_HEIGHT/2) lvlbase = base(1400, WINDOW_HEIGHT/2)
levelLoaded = true levelLoaded = true
@@ -119,7 +112,8 @@ function level7.bonusUpdate(dt)
if not cannons[i].appeared then if not cannons[i].appeared then
sounds["appear"]:stop() sounds["appear"]:stop()
sounds["appear"]:play() sounds["appear"]:play()
table.insert(explosions, explosion(1500, cannons[i].y, 100, {1,1,1,1}, 1))
local coolx, cooly = camera:toWorldCoords(1280, 720)
table.insert(explosions, explosion(coolx, cannons[i].y, 100, {1,1,1,1}, 1))
cannons[i].appeared = true cannons[i].appeared = true
end end
end end


+ 6
- 9
levels/levelgeneral.lua View File

@@ -34,9 +34,10 @@ function levelgeneral.update(dt)
--print(camera.x .. " " .. camera.y) --print(camera.x .. " " .. camera.y)
for i, explosion in ipairs(explosions) do for i, explosion in ipairs(explosions) do
explosion:update(dt) explosion:update(dt)
if explosion.killed then if explosion.killed then
table.remove(explosions, i) table.remove(explosions, i)
if shipIsHit then
if shipIsHit and explosion.type == 0 then
gameStatus = "setup" gameStatus = "setup"
levelgeneral.reset() levelgeneral.reset()
end end
@@ -45,10 +46,9 @@ function levelgeneral.update(dt)
if gameStatus == "play" then if gameStatus == "play" then
camera.x, camera.y = firstShip.x - firstShip.height*4, firstShip.y- firstShip.width camera.x, camera.y = firstShip.x - firstShip.height*4, firstShip.y- firstShip.width
--print(camera.x .. firstShip.x) --print(camera.x .. firstShip.x)
if shipIsHit then
if #explosions == 0 then
table.insert(explosions, explosion(firstShip.x, firstShip.y, 100, {1,1,1,1}))
end
if shipIsHit and not firstShip.exploded then
table.insert(explosions, explosion(firstShip.x, firstShip.y, 100, {1,1,1,1}, 0))
firstShip.exploded = true
end end
firstShip:update(dt) firstShip:update(dt)
@@ -105,11 +105,7 @@ function levelgeneral.draw()
end end
firstShip:draw() firstShip:draw()
for i, explosion in ipairs(explosions) do for i, explosion in ipairs(explosions) do
if shipIsHit then
explosion:render() explosion:render()
else
explosion:render("special")
end
--print("exploding") --print("exploding")
end end
camera:detach() camera:detach()
@@ -145,6 +141,7 @@ function levelgeneral.goBack()
levelgeneral.reset() levelgeneral.reset()
lvlbase = nil lvlbase = nil
gameStatus = "setup" gameStatus = "setup"
cameraControl = false
firstShip.path = {} firstShip.path = {}
cannons = {} cannons = {}
levelLoaded = false levelLoaded = false


+ 8
- 15
levels/practice.lua View File

@@ -2,15 +2,7 @@ practice = Class{}
local levelLoaded = false local levelLoaded = false
local M = {} local M = {}
local currenctScore = 0 local currenctScore = 0
function love.wheelmoved(x, y)
if gameStatus == "play" then
if y > 0 and camera.scale < 1 then
camera.scale = camera.scale + 0.1
elseif y < 0 and camera.scale > 0.5 then
camera.scale = camera.scale - 0.1
end
end
end

function practice.update(dt) function practice.update(dt)
if not levelLoaded then if not levelLoaded then
shipsleft = 1 shipsleft = 1
@@ -21,6 +13,7 @@ function practice.update(dt)
guibutts = {} guibutts = {}
XCAM = 0 XCAM = 0
currentScore = 0 currentScore = 0
cameraControl = true
thrusterMax = 0 thrusterMax = 0
YCAM = 0 YCAM = 0
firstShip.fuel = 0 firstShip.fuel = 0
@@ -48,6 +41,7 @@ function practice.update(dt)
--print(camera.x .. " " .. camera.y) --print(camera.x .. " " .. camera.y)
for i, explosion in ipairs(explosions) do for i, explosion in ipairs(explosions) do
explosion:update(dt) explosion:update(dt)
-- print("1 update done")
if explosion.killed then if explosion.killed then
table.remove(explosions, i) table.remove(explosions, i)
if shipIsHit then if shipIsHit then
@@ -59,12 +53,10 @@ function practice.update(dt)
if gameStatus == "play" then if gameStatus == "play" then
camera.x, camera.y = firstShip.x - firstShip.height*4, firstShip.y- firstShip.width camera.x, camera.y = firstShip.x - firstShip.height*4, firstShip.y- firstShip.width
--print(camera.x .. firstShip.x) --print(camera.x .. firstShip.x)
if shipIsHit then
if #explosions == 0 then
table.insert(explosions, explosion(firstShip.x, firstShip.y, 100, {1,1,1,1}))
end
if shipIsHit and not firstShip.exploded then
table.insert(explosions, explosion(firstShip.x, firstShip.y, 100, {1,1,1,1}))
explosions[#explosions].type = 0
firstShip.exploded = true
end end
firstShip:update(dt) firstShip:update(dt)
for i in ipairs(planets) do for i in ipairs(planets) do
@@ -138,6 +130,7 @@ function practice.draw()
end end
function practice.goBack() function practice.goBack()
practice.reset() practice.reset()
cameraControl = false
gameStatus = "setup" gameStatus = "setup"
levelLoaded = false levelLoaded = false
gameState = "menu" gameState = "menu"


+ 10
- 2
main.lua View File

@@ -11,7 +11,7 @@ WINDOW_WIDTH = 1280
WINDOW_HEIGHT = 720 WINDOW_HEIGHT = 720
OFFSET_X = 0 OFFSET_X = 0
OFFSET_Y = 0 OFFSET_Y = 0
cameraControl = false
currentLevel = 0 currentLevel = 0


saveData = { saveData = {
@@ -24,7 +24,15 @@ buttons = {}
cannons = {} cannons = {}
projectiles = {} projectiles = {}
menu = mainMenu() menu = mainMenu()

function love.wheelmoved(x, y)
if gameStatus == "play" and cameraControl then
if y > 0 and camera.scale < 1 then
camera.scale = camera.scale + 0.1
elseif y < 0 and camera.scale > 0.5 then
camera.scale = camera.scale - 0.1
end
end
end
function love.load() function love.load()
print(love.filesystem.getAppdataDirectory()) print(love.filesystem.getAppdataDirectory())
print(love.filesystem.getSaveDirectory()) print(love.filesystem.getSaveDirectory())


+ 4
- 8
src/GUI.lua View File

@@ -50,11 +50,9 @@ function GUIDraw(mode)
love.graphics.draw(shipImage,mx,my, 1.5708, 1, 1, shipW/2, shipH/2) love.graphics.draw(shipImage,mx,my, 1.5708, 1, 1, shipW/2, shipH/2)
if love.keyboard.mouseisReleased then if love.keyboard.mouseisReleased then
love.keyboard.mouseisReleased = false love.keyboard.mouseisReleased = false
if #explosions == 0 then
local zerox, zeroy = camera:toWorldCoords(0, 0) local zerox, zeroy = camera:toWorldCoords(0, 0)
table.insert(explosions, explosion(zerox, my, 100, {1,1,1,1})) table.insert(explosions, explosion(zerox, my, 100, {1,1,1,1}))
explosions[1].type = 1
end
explosions[#explosions].type = 1


firstShip.destX = vmx firstShip.destX = vmx
firstShip.y = vmy firstShip.y = vmy
@@ -84,8 +82,8 @@ function GUIDraw(mode)
if #explosions == 0 then if #explosions == 0 then
local zerox, zeroy = camera:toWorldCoords(0, 0) local zerox, zeroy = camera:toWorldCoords(0, 0)
table.insert(explosions, explosion(zerox, my, 100, {1,1,1,1})) table.insert(explosions, explosion(zerox, my, 100, {1,1,1,1}))
explosions[1].type = 1
end
explosions[#explosions].type = 1
end
sounds["appear"]:play() sounds["appear"]:play()
firstShip.destX = 250 firstShip.destX = 250
@@ -111,10 +109,8 @@ function GUIDraw(mode)
end end
if love.keyboard.mouseisReleased then if love.keyboard.mouseisReleased then
love.keyboard.mouseisReleased = false love.keyboard.mouseisReleased = false
if #explosions == 0 then
table.insert(explosions, explosion(0, 100, 100, {1,1,1,1})) table.insert(explosions, explosion(0, 100, 100, {1,1,1,1}))
explosions[1].type = 1
end
explosions[#explosions].type = 1
sounds["appear"]:play() sounds["appear"]:play()
firstShip.destX = vmx firstShip.destX = vmx
firstShip.y = 100 firstShip.y = 100


Loading…
Cancel
Save