level loading and full end anim

This commit is contained in:
PossiblyAxolotl 2022-05-14 23:42:52 -06:00
parent 6b2987dfa7
commit 51a426ad7b
5 changed files with 44 additions and 3 deletions

View file

@ -8,7 +8,7 @@ import "Saws"
import "Editor" import "Editor"
mode = "menu" mode = "menu"
map = "data/saw.rocketbyte" map = "data/level.rocketbyte"
deaths = 0 deaths = 0
energy = 0 energy = 0
@ -16,6 +16,8 @@ totalEnergy = 0
showEnergy = false showEnergy = false
next = nil
local gfx <const> = playdate.graphics local gfx <const> = playdate.graphics
local disp <const> = playdate.display local disp <const> = playdate.display
local font <const> = gfx.font.new("gfx/big") local font <const> = gfx.font.new("gfx/big")

View file

@ -14,6 +14,7 @@ function addMapSave(_file)
end end
function addMap(_file, rs) function addMap(_file, rs)
next = nil
if rs then deaths = 0 end if rs then deaths = 0 end
if #tiles > 0 then if #tiles > 0 then
for i = 1, #tiles, 1 do for i = 1, #tiles, 1 do
@ -37,6 +38,7 @@ function addMap(_file, rs)
if level.saws then loadBlades(level.saws) end if level.saws then loadBlades(level.saws) end
if level.rotators then loadSpins(level.rotators) end if level.rotators then loadSpins(level.rotators) end
if level.fuel then loadFuel(level.fuel) 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) 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}) tiles = gfx.sprite.addWallSprites(tilemap, {0,1,6,7,8,10,11,12})

View file

@ -1,5 +1,8 @@
import "CoreLibs/math" import "CoreLibs/math"
import "CoreLibs/animation" import "CoreLibs/animation"
import "CoreLibs/animator"
import "CoreLibs/timer"
import "CoreLibs/easing"
local velocity = {x=0,y=0} local velocity = {x=0,y=0}
local lerpmnt <const> = 0.5 local lerpmnt <const> = 0.5
@ -53,10 +56,41 @@ local function playerWin()
song:stop() song:stop()
song:load("sfx/song3") song:load("sfx/song3")
song:play(1) 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 end
active = false active = false
exists = false exists = false
dead = true dead = true
end end
local function die() local function die()
@ -67,6 +101,7 @@ local function die()
end end
function updatePlayer() function updatePlayer()
playdate.timer.updateTimers()
sprRocket:setImage(imgRocket) sprRocket:setImage(imgRocket)
if active == true then if active == true then
if playdate.buttonIsPressed(playdate.kButtonUp) or playdate.buttonIsPressed(playdate.kButtonA) 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 if sprBigRocket:alphaCollision(sprRocket) and energy == totalEnergy then
playerWin() playerWin()
end end
end end

View file

@ -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}]} {"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}]}

View file

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