- Passat a mini v1.3.7

- [NEW] ara es pot activar i desactivar el só, des del nou menu d'opcions i desde el menu in-game
- [NEW] menus canviats un poc
This commit is contained in:
2025-10-30 16:31:07 +01:00
parent a5d097aa50
commit 639fd6e34d
10 changed files with 261 additions and 243 deletions

View File

@@ -28,7 +28,6 @@ actors={}
cameras={}
camera_names={[0]="GPS","Gorro","Peu de Paco","Premiere","EL_ALIEN","BatMan"}
current_camera=0
mute=false
function remove_actor(actor)
for index, value in pairs(actors) do
@@ -38,19 +37,6 @@ function remove_actor(actor)
end
end
function playmus(song,loop)
if not mute then
music.play(song,loop)
end
end
function playsnd(snd,volume)
if not mute then
--print(sound)
return sound.play(snd,volume)
end
end
function game_init(menu)
actors={}
cameras={}
@@ -151,13 +137,13 @@ function game_init(menu)
if menu then
menu_sel=0
menu_state=0
menu_state=update_main_menu;
abad.update = abad_nop
game_update=update_menu
menu_count=0
menu_change_room=300
menu_room=math.random(0,59)
playmus(audio_main_song)
music.play(audio_main_song)
else
game_update=update_game
music.stop()
@@ -296,24 +282,6 @@ function update_game()
fireball.update()
switches.update()
--local hx = abad.hab%10
--local hy = math.floor(abad.hab/10)
--if btnp(KEY_RETURN) then
-- mode=modes.editing
-- mapa_restore_backup()
--elseif btn(KEY_LSHIFT) and btnp(KEY_RIGHT) and hx<9 then
-- abad.hab=abad.hab+1
--elseif btn(KEY_LSHIFT) and btnp(KEY_LEFT) and hx>0 then
-- abad.hab=abad.hab-1
--elseif btn(KEY_LSHIFT) and btnp(KEY_DOWN) and hy<7 then
-- 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_M) then
-- mute = not mute
--elseif btnp(KEY_ESCAPE) then
-- pause()
--end
if key.press(key.ESCAPE) or pad.press(btnPause) then
pause()
end
@@ -371,159 +339,206 @@ function update_menu()
surf.cls(16)
text("C A C A U S", 42, 8, 15)
if menu_state == 0 then
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
if (not parpadeig or menu_sel~=0) then text("JUGAR", 54, 16, 13) end
if (not parpadeig or menu_sel~=1) then text("REDEFINIR TECLAT", 32, 24, 13) end
if (not parpadeig or menu_sel~=2) then text("REDEFINIR GAMEPAD", 30, 32, 13) end
menu_state()
end
redraw_menu_hab()
function update_options_menu()
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(28,28+(10*menu_sel),73,9,14)
if (not parpadeig) then draw.rect(28,28+(10*menu_sel),73,9,13) end
if key.press(keyShoot) or key.press(key.SPACE) or pad.press(pad.A) or pad.press(btnShoot) then
if menu_sel==0 then
game_exit()
game_init()
fade.fadeoutin()
elseif menu_sel==1 then
menu_count=0
menu_state=1
else
menu_count=0
menu_state=2
end
elseif key.press(keyDown) or key.press(key.DOWN) or pad.press(pad.DOWN) or pad.press(btnDown) then
menu_sel=menu_sel+1
if menu_sel==3 then menu_sel=0 end
elseif key.press(keyUp) or key.press(key.UP) or pad.press(pad.UP) or pad.press(btnUp) then
menu_sel=menu_sel-1
if menu_sel==-1 then menu_sel=2 end
elseif key.press(key.M) then
mute = not mute
if mute then
music.stop()
else
playmus(audio_main_song)
end
elseif key.press(key.ESCAPE) or pad.press(btnPause) then
sys.quit()
draw.text("MÚSICA", 30, 30, 14); draw.text(music.enabled() and "SI" or "NO",91,30,15)
draw.text("", 30, 40, 14); draw.text(sound.enabled() and "SI" or "NO",91,40,15)
draw.text("REDEFINIR TECLAT", 30, 50, 14)
draw.text("REDEFINIR GAMEPAD", 30, 60, 14)
draw.text("TORNAR", 30, 70, 14)
if key.press(keyShoot) or key.press(key.SPACE) or pad.press(pad.A) or pad.press(btnShoot) then
if menu_sel==0 then
music.enabled(not music.enabled())
if music.enabled() then music.play(audio_main_song) end
elseif menu_sel==1 then
sound.enabled(not sound.enabled())
elseif menu_sel==2 then
menu_count=0
menu_state=update_redefine_keys_menu
elseif menu_sel==3 then
menu_count=0
menu_state=update_redefine_pad_menu
else
menu_count=0
menu_sel=0
menu_state=update_main_menu
end
elseif menu_state==1 then
if key.press(key.ESCAPE) then
elseif key.press(keyDown) or key.press(key.DOWN) or pad.press(pad.DOWN) or pad.press(btnDown) then
menu_sel=menu_sel+1
if menu_sel==5 then menu_sel=0 end
elseif key.press(keyUp) or key.press(key.UP) or pad.press(pad.UP) or pad.press(btnUp) then
menu_sel=menu_sel-1
if menu_sel==-1 then menu_sel=4 end
elseif key.press(key.ESCAPE) or pad.press(btnPause) then
menu_count=0
menu_sel=0
menu_state=update_main_menu
end
end
function update_main_menu()
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(28,18+(10*menu_sel),73,9,14)
if (not parpadeig) then draw.rect(28,18+(10*menu_sel),73,9,13) end
text("JUGAR", 54, 20, 14)
text("OPCIONS", 50, 30, 14)
--if (not parpadeig or menu_sel~=2) then text("REDEFINIR GAMEPAD", 30, 32, 13) end
redraw_menu_hab()
if key.press(keyShoot) or key.press(key.SPACE) or pad.press(pad.A) or pad.press(btnShoot) then
if menu_sel==0 then
game_exit()
game_init()
fade.fadeoutin()
elseif menu_sel==1 then
menu_count=0
menu_sel=0
menu_state=update_options_menu--update_redefine_keys_menu;
else
menu_count=0
menu_state=update_redefine_pad_menu
end
elseif key.press(keyDown) or key.press(key.DOWN) or pad.press(pad.DOWN) or pad.press(btnDown) then
menu_sel=menu_sel+1
if menu_sel==2 then menu_sel=0 end
elseif key.press(keyUp) or key.press(key.UP) or pad.press(pad.UP) or pad.press(btnUp) then
menu_sel=menu_sel-1
if menu_sel==-1 then menu_sel=1 end
elseif key.press(key.ESCAPE) or pad.press(btnPause) then
sys.quit()
end
end
function update_redefine_keys_menu()
if key.press(key.ESCAPE) then
menu_count = 0
menu_state = update_options_menu;
end
if menu_count==0 then
text("PULSA TECLA PER A AMUNT", 20, 24, 13)
local k = key.press();
if k ~= 0 and k~=key.ESCAPE then
menu_count = 1
keyUp=k
config.key("keyup", keyUp)
end
elseif menu_count==1 then
text("PULSA TECLA PER A AVALL", 20, 24, 13)
local k = key.press();
if k ~= 0 and k~=key.ESCAPE then
menu_count = 2
keyDown=k
config.key("keydown", keyDown)
end
elseif menu_count==2 then
text("PULSA TECLA PER A ESQUERRA", 14, 24, 13)
local k = key.press();
if k ~= 0 and k~=key.ESCAPE then
menu_count = 3
keyLeft=k
config.key("keleft", keyLeft)
end
elseif menu_count==3 then
text("PULSA TECLA PER A DRETA", 20, 24, 13)
local k = key.press();
if k ~= 0 and k~=key.ESCAPE then
menu_count = 4
keyRight=k
config.key("keyright", keyRight)
end
elseif menu_count==4 then
text("PULSA TECLA PER A BOTAR", 20, 24, 13)
local k = key.press();
if k ~= 0 and k~=key.ESCAPE then
menu_count = 5
keyJump=k
config.key("keyjump", keyJump)
end
elseif menu_count==5 then
text("PULSA TECLA PER A DISPAR", 18, 24, 13)
local k = key.press();
if k ~= 0 and k~=key.ESCAPE then
menu_count = 0
menu_state = 0
end
if menu_count==0 then
text("PULSA TECLA PER A AMUNT", 20, 24, 13)
local k = key.press();
if k ~= 0 and k~=key.ESCAPE then
menu_count = 1
keyUp=k
config.key("keyup", keyUp)
end
elseif menu_count==1 then
text("PULSA TECLA PER A AVALL", 20, 24, 13)
local k = key.press();
if k ~= 0 and k~=key.ESCAPE then
menu_count = 2
keyDown=k
config.key("keydown", keyDown)
end
elseif menu_count==2 then
text("PULSA TECLA PER A ESQUERRA", 14, 24, 13)
local k = key.press();
if k ~= 0 and k~=key.ESCAPE then
menu_count = 3
keyLeft=k
config.key("keleft", keyLeft)
end
elseif menu_count==3 then
text("PULSA TECLA PER A DRETA", 20, 24, 13)
local k = key.press();
if k ~= 0 and k~=key.ESCAPE then
menu_count = 4
keyRight=k
config.key("keyright", keyRight)
end
elseif menu_count==4 then
text("PULSA TECLA PER A BOTAR", 20, 24, 13)
local k = key.press();
if k ~= 0 and k~=key.ESCAPE then
menu_count = 5
keyJump=k
config.key("keyjump", keyJump)
end
elseif menu_count==5 then
text("PULSA TECLA PER A DISPAR", 18, 24, 13)
local k = key.press();
if k ~= 0 and k~=key.ESCAPE then
menu_count = 0
menu_state = 0
keyShoot=k
config.key("keyshoot", keyShoot)
end
end
else
if key.press(key.ESCAPE) then
menu_count = 0
menu_state = 0
end
if menu_count==0 then
text("PULSA BOTÓ PER A AMUNT", 22, 24, 13)
local btn = pad.press();
if btn ~= -1 then
menu_count = 1
btnUp=btn
config.key("btnup", btnUp)
end
elseif menu_count==1 then
text("PULSA BOTÓ PER A AVALL", 22, 24, 13)
local btn = pad.press();
if btn ~= -1 then
menu_count = 2
btnDown=btn
config.key("btndown", btnDown)
end
elseif menu_count==2 then
text("PULSA BOTÓ PER A ESQUERRA", 16, 24, 13)
local btn = pad.press();
if btn ~= -1 then
menu_count = 3
btnLeft=btn
config.key("keleft", btnLeft)
end
elseif menu_count==3 then
text("PULSA BOTÓ PER A DRETA", 22, 24, 13)
local btn = pad.press();
if btn ~= -1 then
menu_count = 4
btnRight=btn
config.key("btnright", btnRight)
end
elseif menu_count==4 then
text("PULSA BOTÓ PER A BOTAR", 22, 24, 13)
local btn = pad.press();
if btn ~= -1 then
menu_count = 5
btnJump=btn
config.key("btnjump", btnJump)
end
elseif menu_count==5 then
text("PULSA BOTÓ PER A DISPAR", 20, 24, 13)
local btn = pad.press();
if btn ~= -1 then
menu_count = 0
menu_state = 0
btnShoot=btn
config.key("btnshoot", btnShoot)
end
menu_state = update_options_menu;
keyShoot=k
config.key("keyshoot", keyShoot)
end
end
end
function update_redefine_pad_menu()
if key.press(key.ESCAPE) then
menu_count = 0
menu_state = update_options_menu;
end
if menu_count==0 then
text("PULSA BOTÓ PER A AMUNT", 22, 24, 13)
local btn = pad.press();
if btn ~= -1 then
menu_count = 1
btnUp=btn
config.key("btnup", btnUp)
end
elseif menu_count==1 then
text("PULSA BOTÓ PER A AVALL", 22, 24, 13)
local btn = pad.press();
if btn ~= -1 then
menu_count = 2
btnDown=btn
config.key("btndown", btnDown)
end
elseif menu_count==2 then
text("PULSA BOTÓ PER A ESQUERRA", 16, 24, 13)
local btn = pad.press();
if btn ~= -1 then
menu_count = 3
btnLeft=btn
config.key("keleft", btnLeft)
end
elseif menu_count==3 then
text("PULSA BOTÓ PER A DRETA", 22, 24, 13)
local btn = pad.press();
if btn ~= -1 then
menu_count = 4
btnRight=btn
config.key("btnright", btnRight)
end
elseif menu_count==4 then
text("PULSA BOTÓ PER A BOTAR", 22, 24, 13)
local btn = pad.press();
if btn ~= -1 then
menu_count = 5
btnJump=btn
config.key("btnjump", btnJump)
end
elseif menu_count==5 then
text("PULSA BOTÓ PER A DISPAR", 20, 24, 13)
local btn = pad.press();
if btn ~= -1 then
menu_count = 0
menu_state = update_options_menu;
btnShoot=btn
config.key("btnshoot", btnShoot)
end
end
end
function game_exit()
@@ -550,28 +565,55 @@ end
function update_pause()
draw.rectf(16,16,97,65,16)
draw.rect(16,16,97,65,15)
draw.text("PAUSA",54,30,15)
if pausa_option==1 then
draw.rect(28,48,73,9,13)
else
draw.rect(28,58,73,9,13)
draw.text("PAUSA",54,20,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.text("CONTINUAR",30,50,14)
draw.text("EIXIR",30,60,14)
draw.rect(28,33+(10*(pausa_option-1)),73,9,14)
if (not parpadeig) then draw.rect(28,33+(10*(pausa_option-1)),73,9,13) end
--draw.rect(28,33+(10*(pausa_option-1)),73,9,13)
draw.text("CONTINUAR",30,35,14)
draw.text("MUSICA:",30,45,14)
if music.enabled() then
draw.text("SI",91,45,15)
else
draw.text("NO",91,45,15)
end
draw.text("SÓ:",30,55,14)
if sound.enabled() then
draw.text("SI",91,55,15)
else
draw.text("NO",91,55,15)
end
draw.text("EIXIR",30,65,14)
if key.press(key.ESCAPE) then
surf.source(back)
draw.surf(0,0,128,96,0,0)
surf.source(tiles)
game_update = pause_old_update
elseif key.press(keyDown) or key.press(keyUp) or pad.press(btnDown) or pad.press(btnUp) then
if pausa_option==1 then pausa_option=2 else pausa_option=1 end
elseif key.press(keyDown) or pad.press(btnDown) then
pausa_option = pausa_option + 1
if pausa_option == 5 then pausa_option = 1 end
elseif key.press(keyUp) or pad.press(btnUp) then
pausa_option = pausa_option - 1
if pausa_option == 0 then pausa_option = 4 end
elseif key.press(keyShoot) or pad.press(btnShoot) then
if pausa_option==1 then
surf.source(back)
draw.surf(0,0,128,96,0,0)
surf.source(tiles)
game_update = pause_old_update
elseif pausa_option==2 then
music.enabled(not music.enabled())
elseif pausa_option==3 then
sound.enabled(not sound.enabled())
else
game_exit()
game_init(true)