function _init()
game_over = false
make_cave()
make_player()
end
function _update()
if (not game_over) then
update_cave()
move_player()
check_hit()
else
if (btnp(5)) _init() -- restart
end
end
function _draw()
cls() -- clear screen
draw_cave()
draw_player()
if (game_over) then
print("game over!", 44, 44, 7)
print("your score: " .. player.score, 34, 54, 7)
print("press ❎ to play again!", 18, 72, 6)
else
print("score: " .. player.score, 2, 2, 7)
-- Display health
print("health: " .. player.health, 2, 12, 7)
end
end
function make_player()
player = {}
player.x = 24 -- position
player.y = 60
player.dy = 0 -- fall speed
player.rise = 1 -- sprites
player.fall = 2
player.dead = 3
function _init()
game_over = false
make_cave()
make_player()
end
function _update()
if (not game_over) then
update_cave()
move_player()
check_hit()
else
if (btnp(5)) _init() -- restart
end
end
function _draw()
cls() -- clear screen
draw_cave()
draw_player()
if (game_over) then
print("game over!", 44, 44, 7)
print("your score: " .. player.score, 34, 54, 7)
print("press ❎ to play again!", 18, 72, 6)
else
print("score: " .. player.score, 2, 2, 7)
-- Display health
print("health: " .. player.health, 2, 12, 7)
end
end
function make_player()
player = {}
player.x = 24 -- position
player.y = 60
player.dy = 0 -- fall speed
player.rise = 1 -- sprites
player.fall = 2
player.dead = 3