From 51a426ad7b773ce92742632231ed60d2798db35b Mon Sep 17 00:00:00 2001 From: PossiblyAxolotl Date: Sat, 14 May 2022 23:42:52 -0600 Subject: [PATCH] level loading and full end anim --- Source/Main.lua | 4 +++- Source/Map.lua | 2 ++ Source/Player.lua | 38 ++++++++++++++++++++++++++++++++++- Source/data/level.rocketbyte | 2 +- Source/data/level2.rocketbyte | 1 + 5 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 Source/data/level2.rocketbyte diff --git a/Source/Main.lua b/Source/Main.lua index 125c7fd..44d6968 100644 --- a/Source/Main.lua +++ b/Source/Main.lua @@ -8,7 +8,7 @@ import "Saws" import "Editor" mode = "menu" -map = "data/saw.rocketbyte" +map = "data/level.rocketbyte" deaths = 0 energy = 0 @@ -16,6 +16,8 @@ totalEnergy = 0 showEnergy = false +next = nil + local gfx = playdate.graphics local disp = playdate.display local font = gfx.font.new("gfx/big") diff --git a/Source/Map.lua b/Source/Map.lua index 0b10aaa..e4f5b3e 100644 --- a/Source/Map.lua +++ b/Source/Map.lua @@ -14,6 +14,7 @@ function addMapSave(_file) end function addMap(_file, rs) + next = nil if rs then deaths = 0 end if #tiles > 0 then for i = 1, #tiles, 1 do @@ -37,6 +38,7 @@ function addMap(_file, rs) if level.saws then loadBlades(level.saws) end if level.rotators then loadSpins(level.rotators) end if level.fuel then loadFuel(level.fuel) end + if level.next then next = level.next end addPlayer(level.rocket.x,level.rocket.y, level.bigrocket.x, level.bigrocket.y) tiles = gfx.sprite.addWallSprites(tilemap, {0,1,6,7,8,10,11,12}) diff --git a/Source/Player.lua b/Source/Player.lua index 5d9e9d0..36f3c0d 100644 --- a/Source/Player.lua +++ b/Source/Player.lua @@ -1,5 +1,8 @@ import "CoreLibs/math" import "CoreLibs/animation" +import "CoreLibs/animator" +import "CoreLibs/timer" +import "CoreLibs/easing" local velocity = {x=0,y=0} local lerpmnt = 0.5 @@ -53,10 +56,41 @@ local function playerWin() song:stop() song:load("sfx/song3") song:play(1) + local startPos = playdate.geometry.point.new(sprRocket.x, sprRocket.y) + local endPos = playdate.geometry.point.new(sprBigRocket.x, sprBigRocket.y) + sprRocket:setAnimator(gfx.animator.new(800, startPos, endPos)) + + rocketfly = playdate.timer.new(6000, function(timer) + local stPos = playdate.geometry.point.new(sprBigRocket.x, sprBigRocket.y) + local ndPos = playdate.geometry.point.new(sprBigRocket.x, sprBigRocket.y - 1000) + sprBigRocket:setAnimator(gfx.animator.new(3000,stPos,ndPos, playdate.easingFunctions.inCubic)) + end) + + song:setFinishCallback(function() + if next then + savedLevel = next + end + playdate.datastore.write({savedLevel=map,savedDeaths=deaths},"savegame") + totalEnergy = 0 + showEnergy = false + energy = 0 + if next == nil then + mainMenuCreation() + createMenu(mainmenu) + next = nil + else + next = nil + killBlades() + killPlayer() + addMapSave(savedLevel) + end + end) + end active = false exists = false dead = true + end local function die() @@ -67,6 +101,7 @@ local function die() end function updatePlayer() + playdate.timer.updateTimers() sprRocket:setImage(imgRocket) if active == true then if playdate.buttonIsPressed(playdate.kButtonUp) or playdate.buttonIsPressed(playdate.kButtonA) then @@ -117,4 +152,5 @@ function updateExit() if sprBigRocket:alphaCollision(sprRocket) and energy == totalEnergy then playerWin() end -end \ No newline at end of file +end + diff --git a/Source/data/level.rocketbyte b/Source/data/level.rocketbyte index 5d90e7b..fd0e18c 100644 --- a/Source/data/level.rocketbyte +++ b/Source/data/level.rocketbyte @@ -1 +1 @@ -{"bigrocket":{"x":73.333333,"y":144.79638},"fuel":[{"x":73.333333,"y":100}],"dimensions":{"x":22,"y":17},"rocket":{"x":276.27907,"y":144.651163},"tiles":[{"t":2,"x":2,"y":1},{"t":2,"x":14,"y":1},{"t":2,"x":14,"y":5},{"t":2,"x":22,"y":5},{"t":2,"x":8,"y":6},{"t":2,"x":2,"y":12},{"t":2,"x":8,"y":12},{"t":2,"x":11,"y":12},{"t":2,"x":14,"y":12},{"t":2,"x":8,"y":17},{"t":2,"x":22,"y":17},{"t":3,"x":3,"y":1},{"t":3,"x":4,"y":1},{"t":3,"x":5,"y":1},{"t":3,"x":6,"y":1},{"t":3,"x":7,"y":1},{"t":3,"x":8,"y":1},{"t":3,"x":9,"y":1},{"t":3,"x":10,"y":1},{"t":3,"x":11,"y":1},{"t":3,"x":12,"y":1},{"t":3,"x":13,"y":1},{"t":3,"x":15,"y":5},{"t":3,"x":16,"y":5},{"t":3,"x":17,"y":5},{"t":3,"x":18,"y":5},{"t":3,"x":19,"y":5},{"t":3,"x":20,"y":5},{"t":3,"x":21,"y":5},{"t":3,"x":3,"y":12},{"t":3,"x":4,"y":12},{"t":3,"x":5,"y":12},{"t":3,"x":6,"y":12},{"t":3,"x":7,"y":12},{"t":3,"x":9,"y":12},{"t":3,"x":10,"y":12},{"t":3,"x":9,"y":17},{"t":3,"x":10,"y":17},{"t":3,"x":11,"y":17},{"t":3,"x":12,"y":17},{"t":3,"x":13,"y":17},{"t":3,"x":14,"y":17},{"t":3,"x":15,"y":17},{"t":3,"x":16,"y":17},{"t":3,"x":17,"y":17},{"t":3,"x":18,"y":17},{"t":3,"x":19,"y":17},{"t":3,"x":20,"y":17},{"t":3,"x":21,"y":17},{"t":4,"x":2,"y":2},{"t":4,"x":14,"y":2},{"t":4,"x":2,"y":3},{"t":4,"x":14,"y":3},{"t":4,"x":2,"y":4},{"t":4,"x":14,"y":4},{"t":4,"x":2,"y":5},{"t":4,"x":2,"y":6},{"t":4,"x":14,"y":6},{"t":4,"x":22,"y":6},{"t":4,"x":2,"y":7},{"t":4,"x":8,"y":7},{"t":4,"x":14,"y":7},{"t":4,"x":22,"y":7},{"t":4,"x":2,"y":8},{"t":4,"x":8,"y":8},{"t":4,"x":14,"y":8},{"t":4,"x":22,"y":8},{"t":4,"x":2,"y":9},{"t":4,"x":8,"y":9},{"t":4,"x":14,"y":9},{"t":4,"x":22,"y":9},{"t":4,"x":2,"y":10},{"t":4,"x":8,"y":10},{"t":4,"x":14,"y":10},{"t":4,"x":22,"y":10},{"t":4,"x":2,"y":11},{"t":4,"x":8,"y":11},{"t":4,"x":14,"y":11},{"t":4,"x":22,"y":11},{"t":4,"x":22,"y":12},{"t":4,"x":8,"y":13},{"t":4,"x":22,"y":13},{"t":4,"x":8,"y":14},{"t":4,"x":22,"y":14},{"t":4,"x":8,"y":15},{"t":4,"x":22,"y":15},{"t":4,"x":8,"y":16},{"t":4,"x":22,"y":16}]} \ No newline at end of file +{"bigrocket":{"x":73.333333,"y":144.79638},"next":"data/level2.rocketbyte","fuel":[{"x":73.333333,"y":100}],"dimensions":{"x":22,"y":17},"rocket":{"x":276.27907,"y":144.651163},"tiles":[{"t":2,"x":2,"y":1},{"t":2,"x":14,"y":1},{"t":2,"x":14,"y":5},{"t":2,"x":22,"y":5},{"t":2,"x":8,"y":6},{"t":2,"x":2,"y":12},{"t":2,"x":8,"y":12},{"t":2,"x":11,"y":12},{"t":2,"x":14,"y":12},{"t":2,"x":8,"y":17},{"t":2,"x":22,"y":17},{"t":3,"x":3,"y":1},{"t":3,"x":4,"y":1},{"t":3,"x":5,"y":1},{"t":3,"x":6,"y":1},{"t":3,"x":7,"y":1},{"t":3,"x":8,"y":1},{"t":3,"x":9,"y":1},{"t":3,"x":10,"y":1},{"t":3,"x":11,"y":1},{"t":3,"x":12,"y":1},{"t":3,"x":13,"y":1},{"t":3,"x":15,"y":5},{"t":3,"x":16,"y":5},{"t":3,"x":17,"y":5},{"t":3,"x":18,"y":5},{"t":3,"x":19,"y":5},{"t":3,"x":20,"y":5},{"t":3,"x":21,"y":5},{"t":3,"x":3,"y":12},{"t":3,"x":4,"y":12},{"t":3,"x":5,"y":12},{"t":3,"x":6,"y":12},{"t":3,"x":7,"y":12},{"t":3,"x":9,"y":12},{"t":3,"x":10,"y":12},{"t":3,"x":9,"y":17},{"t":3,"x":10,"y":17},{"t":3,"x":11,"y":17},{"t":3,"x":12,"y":17},{"t":3,"x":13,"y":17},{"t":3,"x":14,"y":17},{"t":3,"x":15,"y":17},{"t":3,"x":16,"y":17},{"t":3,"x":17,"y":17},{"t":3,"x":18,"y":17},{"t":3,"x":19,"y":17},{"t":3,"x":20,"y":17},{"t":3,"x":21,"y":17},{"t":4,"x":2,"y":2},{"t":4,"x":14,"y":2},{"t":4,"x":2,"y":3},{"t":4,"x":14,"y":3},{"t":4,"x":2,"y":4},{"t":4,"x":14,"y":4},{"t":4,"x":2,"y":5},{"t":4,"x":2,"y":6},{"t":4,"x":14,"y":6},{"t":4,"x":22,"y":6},{"t":4,"x":2,"y":7},{"t":4,"x":8,"y":7},{"t":4,"x":14,"y":7},{"t":4,"x":22,"y":7},{"t":4,"x":2,"y":8},{"t":4,"x":8,"y":8},{"t":4,"x":14,"y":8},{"t":4,"x":22,"y":8},{"t":4,"x":2,"y":9},{"t":4,"x":8,"y":9},{"t":4,"x":14,"y":9},{"t":4,"x":22,"y":9},{"t":4,"x":2,"y":10},{"t":4,"x":8,"y":10},{"t":4,"x":14,"y":10},{"t":4,"x":22,"y":10},{"t":4,"x":2,"y":11},{"t":4,"x":8,"y":11},{"t":4,"x":14,"y":11},{"t":4,"x":22,"y":11},{"t":4,"x":22,"y":12},{"t":4,"x":8,"y":13},{"t":4,"x":22,"y":13},{"t":4,"x":8,"y":14},{"t":4,"x":22,"y":14},{"t":4,"x":8,"y":15},{"t":4,"x":22,"y":15},{"t":4,"x":8,"y":16},{"t":4,"x":22,"y":16}]} \ No newline at end of file diff --git a/Source/data/level2.rocketbyte b/Source/data/level2.rocketbyte new file mode 100644 index 0000000..5d90e7b --- /dev/null +++ b/Source/data/level2.rocketbyte @@ -0,0 +1 @@ +{"bigrocket":{"x":73.333333,"y":144.79638},"fuel":[{"x":73.333333,"y":100}],"dimensions":{"x":22,"y":17},"rocket":{"x":276.27907,"y":144.651163},"tiles":[{"t":2,"x":2,"y":1},{"t":2,"x":14,"y":1},{"t":2,"x":14,"y":5},{"t":2,"x":22,"y":5},{"t":2,"x":8,"y":6},{"t":2,"x":2,"y":12},{"t":2,"x":8,"y":12},{"t":2,"x":11,"y":12},{"t":2,"x":14,"y":12},{"t":2,"x":8,"y":17},{"t":2,"x":22,"y":17},{"t":3,"x":3,"y":1},{"t":3,"x":4,"y":1},{"t":3,"x":5,"y":1},{"t":3,"x":6,"y":1},{"t":3,"x":7,"y":1},{"t":3,"x":8,"y":1},{"t":3,"x":9,"y":1},{"t":3,"x":10,"y":1},{"t":3,"x":11,"y":1},{"t":3,"x":12,"y":1},{"t":3,"x":13,"y":1},{"t":3,"x":15,"y":5},{"t":3,"x":16,"y":5},{"t":3,"x":17,"y":5},{"t":3,"x":18,"y":5},{"t":3,"x":19,"y":5},{"t":3,"x":20,"y":5},{"t":3,"x":21,"y":5},{"t":3,"x":3,"y":12},{"t":3,"x":4,"y":12},{"t":3,"x":5,"y":12},{"t":3,"x":6,"y":12},{"t":3,"x":7,"y":12},{"t":3,"x":9,"y":12},{"t":3,"x":10,"y":12},{"t":3,"x":9,"y":17},{"t":3,"x":10,"y":17},{"t":3,"x":11,"y":17},{"t":3,"x":12,"y":17},{"t":3,"x":13,"y":17},{"t":3,"x":14,"y":17},{"t":3,"x":15,"y":17},{"t":3,"x":16,"y":17},{"t":3,"x":17,"y":17},{"t":3,"x":18,"y":17},{"t":3,"x":19,"y":17},{"t":3,"x":20,"y":17},{"t":3,"x":21,"y":17},{"t":4,"x":2,"y":2},{"t":4,"x":14,"y":2},{"t":4,"x":2,"y":3},{"t":4,"x":14,"y":3},{"t":4,"x":2,"y":4},{"t":4,"x":14,"y":4},{"t":4,"x":2,"y":5},{"t":4,"x":2,"y":6},{"t":4,"x":14,"y":6},{"t":4,"x":22,"y":6},{"t":4,"x":2,"y":7},{"t":4,"x":8,"y":7},{"t":4,"x":14,"y":7},{"t":4,"x":22,"y":7},{"t":4,"x":2,"y":8},{"t":4,"x":8,"y":8},{"t":4,"x":14,"y":8},{"t":4,"x":22,"y":8},{"t":4,"x":2,"y":9},{"t":4,"x":8,"y":9},{"t":4,"x":14,"y":9},{"t":4,"x":22,"y":9},{"t":4,"x":2,"y":10},{"t":4,"x":8,"y":10},{"t":4,"x":14,"y":10},{"t":4,"x":22,"y":10},{"t":4,"x":2,"y":11},{"t":4,"x":8,"y":11},{"t":4,"x":14,"y":11},{"t":4,"x":22,"y":11},{"t":4,"x":22,"y":12},{"t":4,"x":8,"y":13},{"t":4,"x":22,"y":13},{"t":4,"x":8,"y":14},{"t":4,"x":22,"y":14},{"t":4,"x":8,"y":15},{"t":4,"x":22,"y":15},{"t":4,"x":8,"y":16},{"t":4,"x":22,"y":16}]} \ No newline at end of file