forked from JailDoctor/cacaus
- Menu de pausa, altres apanyos
This commit is contained in:
35
game.lua
35
game.lua
@@ -110,6 +110,7 @@ function game_init(menu)
|
||||
menu_count=0
|
||||
menu_change_room=300
|
||||
menu_room=rnd(60)
|
||||
playchirp(audio_main_song)
|
||||
else
|
||||
_update=update_game
|
||||
end
|
||||
@@ -276,6 +277,8 @@ function update_game()
|
||||
abad.hab=abad.hab+10
|
||||
elseif btn(KEY_LSHIFT) and btnp(KEY_UP) and hy>0 then
|
||||
abad.hab=abad.hab-10
|
||||
elseif btnp(KEY_ESCAPE) then
|
||||
pause()
|
||||
end
|
||||
if abad.objects.gps~=nil then
|
||||
if btnp(KEY_1) then
|
||||
@@ -325,7 +328,7 @@ function update_menu()
|
||||
fireball.update()
|
||||
switches.update()
|
||||
|
||||
if btn(KEY_SPACE) then
|
||||
if btnp(KEY_SPACE) then
|
||||
game_exit()
|
||||
game_init()
|
||||
end
|
||||
@@ -339,4 +342,32 @@ end
|
||||
|
||||
function aabb(a, b)
|
||||
return (a.x+a.bb.x+a.bb.w >= b.x+b.bb.x) and (a.x+a.bb.x <= b.x+b.bb.x+b.bb.w) and (a.y+a.bb.y+a.bb.h >= b.y+b.bb.y) and (a.y+a.bb.y <= b.y+b.bb.y+b.bb.h)
|
||||
end
|
||||
end
|
||||
|
||||
function pause()
|
||||
setsource(0)
|
||||
setdest(back)
|
||||
sspr(0,0,128,96,0,0)
|
||||
setdest(0)
|
||||
setsource(tiles)
|
||||
old_update=_update
|
||||
_update=update_pause
|
||||
end
|
||||
|
||||
function update_pause()
|
||||
rectfill(16,16,112,80,16)
|
||||
rect(16,16,112,80,15)
|
||||
prnt("PAUSA",54,30,15)
|
||||
prnt("ESC torna al joc",30,50,14)
|
||||
prnt("SPACE eixir",30,60,14)
|
||||
|
||||
if btnp(KEY_ESCAPE) then
|
||||
setsource(back)
|
||||
sspr(0,0,128,96,0,0)
|
||||
setsource(tiles)
|
||||
_update = old_update
|
||||
elseif btnp(KEY_SPACE) then
|
||||
game_exit()
|
||||
game_init(true)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user