- Mute implementat

This commit is contained in:
2022-12-28 19:24:20 +01:00
parent 5a980fcdfb
commit 5a27c54cb3
8 changed files with 50 additions and 25 deletions

View File

@@ -30,16 +30,16 @@ end
function abad_hurt(howmuch)
if abad.hurting == 0 then
playchirp(audio_abad_hit)
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()
playchirp(audio_game_over, true)
play(audio_game_over, true)
else
playchirp(audio_life_lost, true)
play(audio_life_lost, true)
abad.energia=40
abad.hab=abad.safe.hab
abad.x=abad.safe.x
@@ -80,11 +80,11 @@ function abad_state_normal()
abad.update=abad_state_jumping
abad.step=0
abad.jumpfwd=false
playchirp(audio_abad_jump)
play(audio_abad_jump)
elseif btn(KEY_DOWN) then
abad.update=abad_state_crouch
elseif btnp(KEY_SPACE) and cacau.hab==-1 then
playchirp(audio_abad_shot)
play(audio_abad_shot)
abad.update=abad_state_fire
abad.wait=0
cacau.init(abad.hab,abad.x+8,abad.y+8,abad.flip)
@@ -152,7 +152,7 @@ function abad_state_walking()
abad.wait=0
abad.step=(abad.step+1)%2
if abad.step==0 then
playchirp(audio_abad_step[abad.mustep])
play(audio_abad_step[abad.mustep])
abad.mustep = abad.mustep + 1
if abad.mustep == 5 then abad.mustep=1 end
end
@@ -172,7 +172,7 @@ function abad_state_walking()
abad.update=abad_state_jumping
abad.step=0
abad.jumpfwd=true
playchirp(audio_abad_jump)
play(audio_abad_jump)
return
elseif btn(KEY_DOWN) then
abad.update=abad_state_crouch
@@ -234,7 +234,7 @@ function abad_state_jumping()
end
elseif abad.step>6 then
abad.update=abad_state_falling
playchirp(audio_abad_fall)
play(audio_abad_fall)
end
abad.step=abad.step+1
end

View File

@@ -79,7 +79,7 @@ function bambolla.update_normal()
end
bambolla.y=28-abs(sin(bambolla.x*0.1))*24
if bambolla.hab==abad.hab and bambolla.y>25.2 then
playchirp(audio_low)
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
playchirp(audio_hit)
play(audio_hit)
end
if aabb(bambolla,abad) then
abad_hurt(1)

View File

@@ -10,6 +10,7 @@ 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
@@ -19,6 +20,12 @@ function remove_actor(actor)
end
end
function play(song)
if not mute then
playchirp(song)
end
end
function game_init(menu)
actors={}
cameras={}
@@ -110,7 +117,7 @@ function game_init(menu)
menu_count=0
menu_change_room=300
menu_room=rnd(60)
playchirp(audio_main_song)
play(audio_main_song)
else
_update=update_game
end
@@ -191,7 +198,7 @@ function update_game()
elseif btnp(KEY_RETURN) then
mode=modes.playing
--mapa_do_backup()
--playchirp(audio_main_song);
--play(audio_main_song);
elseif btnp(KEY_S) and (btn(KEY_LCTRL) or btn(KEY_LGUI)) then
_update=update_dialog
elseif btnp(KEY_C) then
@@ -277,6 +284,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_M) then
mute = not mute
elseif btnp(KEY_ESCAPE) then
pause()
end
@@ -331,6 +340,13 @@ function update_menu()
if btnp(KEY_SPACE) then
game_exit()
game_init()
elseif btnp(KEY_M) then
mute = not mute
if mute then
stopchirp()
else
play(audio_main_song)
end
end
end

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 playchirp(audio_low) end
if self.hab==abad.hab then 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)
playchirp(audio_hit)
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)
playchirp(audio_hit)
play(audio_hit)
imp.flip=not imp.flip
elseif imp.x==92 then
imp.reset()

View File

@@ -29,13 +29,18 @@ function intro_intro()
intro_wait=40
_update = intro_update
end
if btnp(KEY_M) then
mute = not mute
end
end
function intro_update()
--playchirp(audio_main_song)
--play(audio_main_song)
--game_init(true)
if btnp(KEY_ESCAPE) then
game_init(true)
elseif btnp(KEY_M) then
mute = not mute
end
intro_wait=intro_wait-1
@@ -82,7 +87,7 @@ function intro_update()
start_scene(scenes.intro_04,58)
intro_step=7
elseif intro_step==7 then
playchirp(audio_main_song)
play(audio_main_song)
game_init(true)
end
intro_wait=40

View File

@@ -156,7 +156,7 @@ function draw_scene()
if scenes.char<#scenes.current_scene[scenes.dnum].text[1] then
scenes.step=scenes.step-1
scenes.char=scenes.char+1
playchirp(scenes.current_scene[scenes.dnum].audio)
play(scenes.current_scene[scenes.dnum].audio)
else
scenes.char=1
end
@@ -165,7 +165,7 @@ function draw_scene()
if scenes.char<#scenes.current_scene[scenes.dnum].text[2] then
scenes.step=scenes.step-1
scenes.char=scenes.char+1
playchirp(scenes.current_scene[scenes.dnum].audio)
play(scenes.current_scene[scenes.dnum].audio)
else
scenes.char=1
end
@@ -174,7 +174,7 @@ function draw_scene()
if scenes.char<#scenes.current_scene[scenes.dnum].text[3] then
scenes.step=scenes.step-1
scenes.char=scenes.char+1
playchirp(scenes.current_scene[scenes.dnum].audio)
play(scenes.current_scene[scenes.dnum].audio)
else
scenes.char=1
end
@@ -218,10 +218,12 @@ function update_scene()
end
if btnp(KEY_ESCAPE) then
if scenes.current_scene[scenes.dnum].die then
game_init(true)
else
pause()
end
if btnp(KEY_SPACE) then
elseif btnp(KEY_SPACE) then
if scenes.step>8 then
if scenes.dnum==#scenes.current_scene then
--freesurf(bkg)
@@ -233,5 +235,7 @@ function update_scene()
else
scenes.step=8
end
elseif btnp(KEY_M) then
mute = not mute
end
end

View File

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