diff --git a/abad.lua b/abad.lua index 8064ac6..ba7bb18 100644 --- a/abad.lua +++ b/abad.lua @@ -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 diff --git a/bambolla.lua b/bambolla.lua index d610e45..2df9cc4 100644 --- a/bambolla.lua +++ b/bambolla.lua @@ -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) diff --git a/game.lua b/game.lua index f7892a6..55fa1f9 100644 --- a/game.lua +++ b/game.lua @@ -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 diff --git a/gota.lua b/gota.lua index ac97518..aeab46c 100644 --- a/gota.lua +++ b/gota.lua @@ -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 diff --git a/imp.lua b/imp.lua index 0b6e45b..aa00e03 100644 --- a/imp.lua +++ b/imp.lua @@ -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() diff --git a/intro.lua b/intro.lua index 7452b01..f020fc7 100644 --- a/intro.lua +++ b/intro.lua @@ -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 diff --git a/scenes.lua b/scenes.lua index 2a3765c..388974c 100644 --- a/scenes.lua +++ b/scenes.lua @@ -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 - pause() - end - - if btnp(KEY_SPACE) then + if scenes.current_scene[scenes.dnum].die then + game_init(true) + else + pause() + end + 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 diff --git a/switches.lua b/switches.lua index 991ebe3..b41f98b 100644 --- a/switches.lua +++ b/switches.lua @@ -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()