From 8afe1765d6ac4d3a51d1d58c7f9bea64d2659548 Mon Sep 17 00:00:00 2001 From: Madiwka3 Date: Mon, 19 Apr 2021 20:22:37 +0600 Subject: [PATCH] Added menu animation --- buttonClutter.lua | 2 ++ entities/planet/planet.lua | 7 ++++++- entities/planet/planet.png | Bin 0 -> 13943 bytes levels/level1.lua | 10 +++++++++- levels/level2.lua | 17 ++++++++++++----- levels/menu.lua | 24 +++++++++++++++++++++++ levels/practice.lua | 6 ++++-- levels/selectlv.lua | 28 ++++++++++++++++++++++++++- main.lua | 4 ++++ src/GUI.lua | 38 ++++++++++++++++++------------------- 10 files changed, 107 insertions(+), 29 deletions(-) create mode 100644 entities/planet/planet.png diff --git a/buttonClutter.lua b/buttonClutter.lua index b9ed52e..106cad8 100644 --- a/buttonClutter.lua +++ b/buttonClutter.lua @@ -1,6 +1,8 @@ function buttonClutter() table.insert(buttons, menu:addButton("Practice", function() + menuLoaded = false + objReset() gameState = "practice" end)) table.insert(buttons, menu:addButton("Levels", diff --git a/entities/planet/planet.lua b/entities/planet/planet.lua index c7f6050..0cab6b0 100644 --- a/entities/planet/planet.lua +++ b/entities/planet/planet.lua @@ -2,7 +2,7 @@ planet = Class{} G = 6.67e-1 -function planet:init(x, y, mass, radius, img) +function planet:init(x, y, mass, radius, img, arg) self.x = x self.y = y self.mass = mass @@ -11,6 +11,11 @@ self.w = img:getWidth() self.image = img self.angle = 0 self.color = {1,1,1,1} +if arg == "nodelete" then + self.deletable = false +else + self.deletable = true +end end function planet:update(dt) diff --git a/entities/planet/planet.png b/entities/planet/planet.png new file mode 100644 index 0000000000000000000000000000000000000000..cf6f26e43b6e5158c3a798b3e3ef16e0e6eaf58c GIT binary patch literal 13943 zcmeHuXH-+$*7i>5p$XD^5v3%d1_%gJqy_0DM2ZkXfCPcii=v^4f`Emh2ny06frxZO z0|=-HB3%?gP*ITLQ3M6$3!ZcDJ$HQXpF76;{<|c5jO;b%eCAxwnrrPgy7jH~lidf+ z-I5Q_OVV!|%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IY^ju6@HBL?7KVHLE2qNSIzcr zmE78SFAMe)fnDZu_niWR$?i=cv!I1VqVogyt+RrdNUULmd$r2^rN}!HKp9Iz&* zsE>4K3fn_B|KOZqlAv6ph?Fa8I==uch+&-=O8@N0vxKs4(TNeGWj&s+@?}n%&Yr7C zInVRW{jv-yYhdY7nPCEAq&a<(>fJkUkl2*pp4W809F)&We*zr(IBOH-Ho|9F4X+gd zZl_|k0mtc%Gb&f}KGtwjJ1frbdv#vdtFhab`%q?S149*|bSxE9O3B=KHGjMD5-J+a zOtmJpKqAR=!XUq5mAPMNa|4X3_Tlp}1*Kxsr{o4T$5AGvXp1W(SEee$fc!4f3$u^t z^1u~aUY26cJgv(9w&59)UaUYrxZF&wv*o^%vn)?jQch? zpWR=j7<_IHIwg-!@dD%eWhMYh7#YBNx*38b`sIgDioZ{CHT`G-U7Q8-J`!59*>&lR0-?t6M78k?#Mc=h`iRI3ZP*MP zNgYx-RK=+V&Y06mf^IYoKM+WoxFmt$VOJSadxwzg)U|MAzA=#B{oGY-^^wl4(lAV$ zvzZvkm#yGi1g9!EWB3UGKfqApD0X&XxK~M|6EFY)%^qA59TTv{(`MMEba_sQ4G~tP!<#B=6Iwci0$`%Y07=u(7Z| KT4&~y^#1_RX4oeH literal 0 HcmV?d00001 diff --git a/levels/level1.lua b/levels/level1.lua index 95f791b..ff343af 100644 --- a/levels/level1.lua +++ b/levels/level1.lua @@ -21,14 +21,16 @@ function level1.update(dt) level1.reset() end )) table.insert(guibutts, menu:addButton("Release brake!", function () + if shipsleft == 0 then selectedItem = "none" gameStatus = "play" + end end )) table.insert(guibutts, menu:addButton("To menu", function () level1.goBack() end)) - table.insert(planets, planet(700, 200, 50, 0.3, planetImage)) + table.insert(planets, planet(700, 200, 50, 0.3, planetImage, "nodelete")) end if reachedGoal then @@ -40,7 +42,9 @@ function level1.update(dt) level1.goBack() end camera:update(dt) + if lvlbase ~= nil then lvlbase:update(dt) + end --print(camera.x .. " " .. camera.y) for i, explosion in ipairs(explosions) do explosion:update(dt) @@ -76,7 +80,9 @@ function level1.draw() love.graphics.setColor(1,1,1,1) camera:attach() firstShip:draw() + if lvlbase ~= nil then lvlbase:draw() + end for i in ipairs(planets) do planets[i]:draw(dt) end @@ -103,12 +109,14 @@ function level1.draw() end function level1.goBack() level1.reset() + gameStatus = "setup" firstShip.path = {} levelLoaded = false for k in pairs(planets) do planets[k] = nil end + lvlbase = nil gameState = "selectlv" end function level1.reset() diff --git a/levels/level2.lua b/levels/level2.lua index b6cb9cb..bf3c0ca 100644 --- a/levels/level2.lua +++ b/levels/level2.lua @@ -21,14 +21,16 @@ function level2.update(dt) level2.reset() end )) table.insert(guibutts, menu:addButton("Release brake!", function () - selectedItem = "none" - gameStatus = "play" + if shipsleft == 0 then + selectedItem = "none" + gameStatus = "play" + end end )) table.insert(guibutts, menu:addButton("To menu", function () level2.goBack() end)) - table.insert(planets, planet(700, 500, 50, 0.3, planetImage)) + table.insert(planets, planet(700, 500, 50, 0.3, planetImage, "nodelete")) end if reachedGoal then @@ -40,7 +42,9 @@ function level2.update(dt) level2.goBack() end camera:update(dt) - lvlbase:update(dt) + if lvlbase ~= nil then + lvlbase:update(dt) + end --print(camera.x .. " " .. camera.y) for i, explosion in ipairs(explosions) do explosion:update(dt) @@ -76,7 +80,9 @@ function level2.draw() love.graphics.setColor(1,1,1,1) camera:attach() firstShip:draw() - lvlbase:draw() + if lvlbase ~= nil then + lvlbase:draw() + end for i in ipairs(planets) do planets[i]:draw(dt) end @@ -103,6 +109,7 @@ function level2.draw() end function level2.goBack() level2.reset() + lvlbase = nil gameStatus = "setup" firstShip.path = {} levelLoaded = false diff --git a/levels/menu.lua b/levels/menu.lua index fd091fd..2375182 100644 --- a/levels/menu.lua +++ b/levels/menu.lua @@ -1,12 +1,36 @@ menu = Class{} local M = {} +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"))) + end + for i in ipairs(planets) do + planets[i]:update(dt) + end if animationSecsLeft > 0 then animationSecsLeft = animationSecsLeft - dt end + firstShip:update(dt) + if shipIsHit then + shipIsHit = false + firstShip:reset() + firstShip.x = -100 + firstShip.speed = 10 + firstShip.y = love.math.random(0, WINDOW_HEIGHT) + print("ship is hit") + end end function menu.draw(dt) + firstShip:draw() + for i in ipairs(planets) do + planets[i]:draw(dt) + end if animationSecsLeft > 0 then love.graphics.setColor(1,1,1,1-1/(animationSecsLeft+0.000001)) love.graphics.draw(logo, 0,0) diff --git a/levels/practice.lua b/levels/practice.lua index a6a752a..8044651 100644 --- a/levels/practice.lua +++ b/levels/practice.lua @@ -18,8 +18,10 @@ function practice.update(dt) practice.reset() end )) table.insert(guibutts, menu:addButton("Release brake!", function () - selectedItem = "none" - gameStatus = "play" + if shipsleft == 0 then + selectedItem = "none" + gameStatus = "play" + end end )) table.insert(guibutts, menu:addButton("To menu", function () diff --git a/levels/selectlv.lua b/levels/selectlv.lua index 5fb5fef..443580b 100644 --- a/levels/selectlv.lua +++ b/levels/selectlv.lua @@ -1,10 +1,14 @@ selectlv = Class{} levels = {} table.insert(levels, menu:addButton("Level 1", function () +menuLoaded = false +objReset() gameState = "level1" end )) table.insert(levels, menu:addButton("Level 2", function () if saveData.levelsBeaten > 0 then + menuLoaded = false + objReset() gameState = "level2" end end )) @@ -17,10 +21,32 @@ table.insert(levels, menu:addButton("Go Back", function () end )) 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"))) + end + for i in ipairs(planets) do + planets[i]:update(dt) + end + firstShip:update(dt) + if shipIsHit then + shipIsHit = false + firstShip:reset() + firstShip.x = -100 + firstShip.speed = 10 + firstShip.y = love.math.random(0, WINDOW_HEIGHT) + print("ship is hit") + end end function selectlv.draw(dt) + firstShip:draw() + for i in ipairs(planets) do + planets[i]:draw(dt) + end menu:butt(levels, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH/2, WINDOW_HEIGHT/2, 40, WINDOW_WIDTH/3, "beatenGreen") end diff --git a/main.lua b/main.lua index 1fe5c01..3ed04bf 100644 --- a/main.lua +++ b/main.lua @@ -61,3 +61,7 @@ function love.mousereleased(x, y, button) end +function objReset() + firstShip:reset() + planets = {} +end \ No newline at end of file diff --git a/src/GUI.lua b/src/GUI.lua index fdea071..b67f7d1 100644 --- a/src/GUI.lua +++ b/src/GUI.lua @@ -158,23 +158,25 @@ function GUIDraw(mode) for j in ipairs(planets) do - local hot = (vmx > planets[j].x-planets[j].w*0.3/2 and vmx < planets[j].x+planets[j].w*0.3 and vmy > planets[j].y-planets[j].w*0.3/2 and vmy < planets[j].y + planets[j].w*0.3) - if hot then - planets[j].color = {1,0,0,1} - print("hot") - else - planets[j].color = {1,1,1,1} - --print(mx .. " " .. my .. " " .. firstShip.x .. " " .. firstShip.y .. " " .. firstShip.width .. firstShip.height) - end - local pressed = love.keyboard.mouseisReleased - if location == "android" then - pressed = love.mouse.isDown(1) - end - if pressed and hot then - love.keyboard.mouseisReleased = false - table.remove(planets, j) - planetsleft = planetsleft + 1 - break + if planets[j].deletable then + local hot = (vmx > planets[j].x-planets[j].w*0.3/2 and vmx < planets[j].x+planets[j].w*0.3 and vmy > planets[j].y-planets[j].w*0.3/2 and vmy < planets[j].y + planets[j].w*0.3) + if hot then + planets[j].color = {1,0,0,1} + print("hot") + else + planets[j].color = {1,1,1,1} + --print(mx .. " " .. my .. " " .. firstShip.x .. " " .. firstShip.y .. " " .. firstShip.width .. firstShip.height) + end + local pressed = love.keyboard.mouseisReleased + if location == "android" then + pressed = love.mouse.isDown(1) + end + if pressed and hot then + love.keyboard.mouseisReleased = false + table.remove(planets, j) + planetsleft = planetsleft + 1 + break + end end end end @@ -187,9 +189,7 @@ function GUIDraw(mode) --REMOVE TOOL --START BUTTON - if shipsleft == 0 then guimenu:butt(guibutts, WINDOW_WIDTH, WINDOW_HEIGHT, menuX + 200, WINDOW_HEIGHT-100, 40, WINDOW_WIDTH/3.7) - end --START BUTTON love.window.setTitle(selectedItem) end