[NEW] Implementada pausa
[FIX] Corregit un segon arranc de partida [NEW] Afegida controller:keypressed
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
local menu_count = 0
|
||||
local pausa_option= 1
|
||||
|
||||
function pause_init()
|
||||
-- surf.target(0)
|
||||
-- surf.cls(16)
|
||||
menu_count = 1
|
||||
states:next()
|
||||
end
|
||||
|
||||
function pause_draw()
|
||||
draw.rectf(32,32,194,130,16)
|
||||
draw.rect(32,32,194,130,15)
|
||||
draw.text("PAUSA",108,40,15)
|
||||
|
||||
menu_count=menu_count+1
|
||||
local parpadeig=false
|
||||
if menu_count>=20 then
|
||||
parpadeig=true
|
||||
if menu_count>40 then menu_count=0 end
|
||||
end
|
||||
draw.rect(56,66+(20*(pausa_option-1)),146,18,14)
|
||||
if (not parpadeig) then draw.rect(56,66+(20*(pausa_option-1)),146,18,13) end
|
||||
|
||||
draw.text("CONTINUAR",60,70,14)
|
||||
draw.text("MUSICA:",60,90,14)
|
||||
if music.enabled() then
|
||||
draw.text("SI",182,90,15)
|
||||
else
|
||||
draw.text("NO",182,90,15)
|
||||
end
|
||||
draw.text("SÓ:",60,110,14)
|
||||
if sound.enabled() then
|
||||
draw.text("SI",182,110,15)
|
||||
else
|
||||
draw.text("NO",182,110,15)
|
||||
end
|
||||
draw.text("EIXIR",60,130,14)
|
||||
end
|
||||
|
||||
function pause_update_logic()
|
||||
if controller:keypressed("down") then
|
||||
pausa_option = pausa_option + 1
|
||||
if pausa_option == 5 then pausa_option = 1 end
|
||||
elseif controller:keypressed("up") then
|
||||
pausa_option = pausa_option - 1
|
||||
if pausa_option == 0 then pausa_option = 4 end
|
||||
elseif controller:keypressed("shoot") then
|
||||
if pausa_option==1 then
|
||||
states:next()
|
||||
elseif pausa_option==2 then
|
||||
music.enabled(not music.enabled())
|
||||
elseif pausa_option==3 then
|
||||
sound.enabled(not sound.enabled())
|
||||
else
|
||||
states:executar("title", false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function pause_update()
|
||||
if key.press(key.ESCAPE) then
|
||||
states:next()
|
||||
return
|
||||
end
|
||||
|
||||
pause_update_logic()
|
||||
pause_draw()
|
||||
end
|
||||
|
||||
|
||||
function pause_end()
|
||||
states:finish()
|
||||
end
|
||||
|
||||
states:registrar("pause", { pause_init, pause_update, pause_end } )
|
||||
Reference in New Issue
Block a user