- 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

@@ -38,16 +38,16 @@ end
function abad_hurt(howmuch)
if abad.hurting == 0 and abad.respawning==0 then
playsnd(audio_abad_hit)
sound.play(audio_abad_hit)
abad.energia=abad.energia-howmuch
if abad.energia<=0 then
abad.vides=abad.vides-1
if abad.vides==0 then
--final de la partida
dead.start()
playmus(audio_game_over,0)
music.play(audio_game_over,0)
else
playmus(audio_life_lost,0)
music.play(audio_life_lost,0)
abad.energia=40
abad.hab=abad.safe.hab
abad.x=abad.safe.x
@@ -97,13 +97,13 @@ function abad_state_normal()
sound.stop(abad.jump)
abad.jump=nil
end
playsnd(audio_abad_jump)
sound.play(audio_abad_jump)
elseif key.down(keyDown) or pad.down(btnDown) then
abad.update=abad_state_crouch
--elseif btn(KEY_Z) then
-- abad.respawning=240
elseif key.down(keyShoot) or pad.down(btnShoot) and cacau.hab==-1 then
playsnd(audio_abad_shot)
sound.play(audio_abad_shot)
abad.update=abad_state_fire
abad.wait=0
cacau.init(abad.hab,abad.x+8,abad.y+8,abad.flip)
@@ -171,7 +171,7 @@ function abad_state_walking()
abad.wait=0
abad.step=(abad.step+1)%2
if abad.step==0 then
playsnd(audio_abad_step[abad.mustep],32)
sound.play(audio_abad_step[abad.mustep],32)
abad.mustep = abad.mustep + 1
if abad.mustep == 5 then abad.mustep=1 end
end
@@ -195,12 +195,12 @@ function abad_state_walking()
sound.stop(abad.jump)
abad.jump=nil
end
playsnd(audio_abad_jump)
sound.play(audio_abad_jump)
return
elseif key.down(keyDown) or pad.down(btnDown) then
abad.update=abad_state_crouch
elseif key.down(keyShoot) or pad.down(btnShoot) and cacau.hab==-1 then
playsnd(audio_abad_shot)
sound.play(audio_abad_shot)
abad.update=abad_state_fire
abad.wait=0
cacau.init(abad.hab,abad.x+8,abad.y+8,abad.flip)
@@ -258,7 +258,7 @@ function abad_state_jumping()
end
elseif abad.step>6 then
abad.update=abad_state_falling
abad.jump=playsnd(audio_abad_fall)
abad.jump=sound.play(audio_abad_fall)
end
abad.step=abad.step+1
end
@@ -302,16 +302,16 @@ function abad_state_stairs()
if key.down(keyRight) or pad.down(btnRight) then
abad.flip=false
abad_advance()
playsnd(audio_low)
sound.play(audio_low)
elseif key.down(keyLeft) or pad.down(btnLeft) then
abad.flip=true
abad_advance()
playsnd(audio_low)
sound.play(audio_low)
elseif key.down(keyUp) or pad.down(btnUp) then
if abad.y>0 then
if check_tile(abad.hab,abad.x+4,abad.y+8)==tiletype.stair or (abad.x+4)&7~=0 and check_tile(abad.hab,abad.x+12,abad.y+8)==tiletype.stair then
abad.y=abad.y-2
playsnd(audio_low)
sound.play(audio_low)
end
else
abad.hab=abad.hab-10
@@ -322,7 +322,7 @@ function abad_state_stairs()
if abad.y<32 then
if check_tile(abad.hab,abad.x+4,abad.y+16)==tiletype.stair or (abad.x+4)&7~=0 and check_tile(abad.hab,abad.x+12,abad.y+16)==tiletype.stair then
abad.y=abad.y+2
playsnd(audio_low)
sound.play(audio_low)
end
else
abad.hab=abad.hab+10

View File

@@ -79,7 +79,7 @@ function bambolla.update_normal()
end
bambolla.y=28-math.abs(math.sin(bambolla.x*0.1))*24
if bambolla.hab==abad.hab and bambolla.y>25.2 then
playsnd(audio_low)
sound.play(audio_low)
end
if bambolla.hab==abad.hab then
if cacau.hab==bambolla.hab and aabb(bambolla,cacau) then
@@ -89,7 +89,7 @@ function bambolla.update_normal()
bambolla.y=bambolla.y+8
bambolla.dx=0
bambolla.dy=-4
playsnd(audio_hit)
sound.play(audio_hit)
end
if aabb(bambolla,abad) then
abad_hurt(1)

View File

@@ -8,7 +8,7 @@ function final_init()
abad.update = abad_nop
game_update=update_final
next_actor()
playmus(audio_final)
music.play(audio_final)
local r,g,b=pal.color(15)
pal.color(17,r,g,b)
--fade.fadein()
@@ -33,15 +33,6 @@ function update_final()
mapa_update(abad.hab,final_room)
if key.press(key.M) then
mute = not mute
if mute then
music.stop()
else
playmus(audio_final)
end
end
if go_next_actor then next_actor() end
end
@@ -141,14 +132,6 @@ function update_final2()
text("C A C A U S", 42, 12, 17)
text("GRACIES PER JUGAR", 30, 48, 10)
if key.press(key.M) then
mute = not mute
if mute then
music.stop()
else
playmus(audio_final)
end
end
final_count=final_count+1
if final_count==200 or (key.press(keyShoot) or pad.press(btnShoot)) or key.press(key.RETURN) then
game_exit()

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,16 +339,67 @@ function update_menu()
surf.cls(16)
text("C A C A U S", 42, 8, 15)
if menu_state == 0 then
menu_state()
end
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
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
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
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 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()
@@ -391,31 +410,27 @@ function update_menu()
fade.fadeoutin()
elseif menu_sel==1 then
menu_count=0
menu_state=1
menu_sel=0
menu_state=update_options_menu--update_redefine_keys_menu;
else
menu_count=0
menu_state=2
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==3 then menu_sel=0 end
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=2 end
elseif key.press(key.M) then
mute = not mute
if mute then
music.stop()
else
playmus(audio_main_song)
end
if menu_sel==-1 then menu_sel=1 end
elseif key.press(key.ESCAPE) or pad.press(btnPause) then
sys.quit()
end
elseif menu_state==1 then
end
function update_redefine_keys_menu()
if key.press(key.ESCAPE) then
menu_count = 0
menu_state = 0
menu_state = update_options_menu;
end
if menu_count==0 then
text("PULSA TECLA PER A AMUNT", 20, 24, 13)
@@ -462,15 +477,17 @@ function update_menu()
local k = key.press();
if k ~= 0 and k~=key.ESCAPE then
menu_count = 0
menu_state = 0
menu_state = update_options_menu;
keyShoot=k
config.key("keyshoot", keyShoot)
end
end
else
end
function update_redefine_pad_menu()
if key.press(key.ESCAPE) then
menu_count = 0
menu_state = 0
menu_state = update_options_menu;
end
if menu_count==0 then
text("PULSA BOTÓ PER A AMUNT", 22, 24, 13)
@@ -517,13 +534,11 @@ function update_menu()
local btn = pad.press();
if btn ~= -1 then
menu_count = 0
menu_state = 0
menu_state = update_options_menu;
btnShoot=btn
config.key("btnshoot", btnShoot)
end
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)

View File

@@ -22,7 +22,7 @@ function gota:update_normal()
self.cx=self.x+2
self.dx=0
self.dy=-4
if self.hab==abad.hab then playsnd(audio_low) end
if self.hab==abad.hab then sound.play(audio_low) end
end
else
--self.flip=not self.flip

View File

@@ -73,7 +73,7 @@ function imp.update()
imp.x=imp.x-2
if imp.x==78 then
fireball.init(imp.hab,imp.x+8,imp.y+4,imp.flip)
playsnd(audio_hit)
sound.play(audio_hit)
imp.flip=not imp.flip
elseif imp.x==-12 then
imp.reset()
@@ -82,7 +82,7 @@ function imp.update()
imp.x=imp.x+2
if imp.x==4 then
fireball.init(imp.hab,imp.x+8,imp.y+4,imp.flip)
playsnd(audio_hit)
sound.play(audio_hit)
imp.flip=not imp.flip
elseif imp.x==92 then
imp.reset()

View File

@@ -29,9 +29,6 @@ function intro_intro()
game_update = intro_update
fade.fadeoutin()
end
if key.press(key.M) then
mute = not mute
end
end
function intro_update()
@@ -40,8 +37,6 @@ function intro_update()
fade.fadeoutin()
elseif key.press(key.SPACE) then
intro_wait=1
elseif key.press(key.M) then
mute = not mute
end
intro_wait=intro_wait-1
@@ -97,7 +92,7 @@ function intro_update()
start_scene(scenes.intro_04,58)
intro_step=intro_step+1
elseif intro_step==8 then
playmus(audio_main_song)
music.play(audio_main_song)
game_init(true)
fade.fadeoutin()
end

View File

@@ -144,7 +144,7 @@ function start_scene(scene,offset)
scenes.die=scenes.current_scene[scenes.dnum].die or 0
if scene[1].musica then
--print(scene[1].musica)
playmus(scenes.current_scene[scenes.dnum].musica)
music.play(scenes.current_scene[scenes.dnum].musica)
end
if offset then scenes.offset=offset end
old_update=game_update
@@ -153,13 +153,13 @@ end
function playtext(snd)
if snd=="abad" then
playsnd(audio_text_abad)
sound.play(audio_text_abad)
elseif snd=="batman" then
playsnd(audio_text_batman)
sound.play(audio_text_batman)
elseif snd=="premiere" then
playsnd(audio_text_premiere)
sound.play(audio_text_premiere)
elseif snd=="elalien" then
playsnd(audio_text_elalien)
sound.play(audio_text_elalien)
end
end
@@ -281,8 +281,6 @@ function update_scene()
else
pause()
end
elseif key.press(key.M) then
mute = not mute
end
if scenes.step>8 then

View File

@@ -24,7 +24,7 @@ function switches.start(hab,tile)
switches.current_index=2
switches.wait=0
switches.cooldown=60
playsnd(audio_switch)
sound.play(audio_switch)
end
function switches.update()

View File

@@ -71,7 +71,7 @@ end
function triggers:teleport_a()
abad.teleport=true
playsnd(audio_hit)
sound.play(audio_hit)
surf.cls(14)
imp.reset()
abad.hab=67
@@ -80,7 +80,7 @@ end
function triggers:teleport_b()
if abad.teleport then
playsnd(audio_hit)
sound.play(audio_hit)
surf.cls(14)
imp.reset()
abad.hab=14
@@ -90,7 +90,7 @@ end
function triggers:teleport_c()
abad.teleport2=true
playsnd(audio_hit)
sound.play(audio_hit)
surf.cls(14)
imp.reset()
abad.hab=61
@@ -99,7 +99,7 @@ end
function triggers:teleport_d()
if abad.teleport2 then
playsnd(audio_hit)
sound.play(audio_hit)
surf.cls(14)
imp.reset()
abad.hab=29