Skip to content

Instantly share code, notes, and snippets.

@keith-kurak
Created October 30, 2022 18:11
Show Gist options
  • Save keith-kurak/cc2e1c74d250f7b2aacd03e720ab0db4 to your computer and use it in GitHub Desktop.
Save keith-kurak/cc2e1c74d250f7b2aacd03e720ab0db4 to your computer and use it in GitHub Desktop.
PICO-04: lava floor, game over condition
-- ** make a lava floor that generates a game over condition when touched
-- 1) After creating lava sprite with flag 2 set, add this to set_map_x()
-- make lava
if flr_hgt < 1 then
mset(x,15,2)
end
-- 2) in _init(), add dead flag to player
dead = false
-- 3) In _draw(), draw text on dead condition
if (player.dead) then
camera()
print("dead!",50,60)
print("press 🅾️ to try again",20,68)
return
end
-- 4) Add death logic to _update60()
-- already dead
if p.dead then
if (btnp(🅾️)) then
_init()
end
return
end
-- apply death
if hit(p.x,p.y,7,7,2) then
p.dead=true
return
end
-- 5) Put missing map logic inside init or else you'll see weird stuff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment