- [NEW] Música per a l'imp

- [NEW] Escena amb l'imp
- [FIX] scenes.lua - La música pot arrancar en qualsevol escena
This commit is contained in:
2026-04-04 00:58:03 +02:00
parent 9ab8c80a56
commit 73122ebb78
8 changed files with 148 additions and 36 deletions

View File

@@ -75,6 +75,7 @@ end
function abad:draw() function abad:draw()
local flip = abad.flip local flip = abad.flip
local x, y = viewp:screen_coords(self.x, self.y)
if abad.update==abad_state_stairs then if abad.update==abad_state_stairs then
flip=abad.stairs_flip flip=abad.stairs_flip
-- flip=(((abad.x>>1)+(abad.y>>1))%2)==0 -- flip=(((abad.x>>1)+(abad.y>>1))%2)==0
@@ -84,13 +85,14 @@ function abad:draw()
msg_print(0,35,msg,true) msg_print(0,35,msg,true)
end end
if (abad.respawning==0) or (math.floor(abad.respawning/15)%2==0) then if (abad.respawning==0) or (math.floor(abad.respawning/15)%2==0) then
local x, y = viewp:screen_coords(self.x, self.y) draw.surf(abad.frame*abad.w,0,abad.w,abad.h,x,y,abad.w,abad.h,flip)
draw.surf(abad.frame*cw,0,cw,ch,x,y,cw,ch,flip)
end end
if abad.respawning > 0 then if abad.respawning > 0 then
abad.respawning=abad.respawning-1 abad.respawning=abad.respawning-1
end end
draw.rect(x+abad.bb.x,y+abad.bb.y,abad.bb.w,abad.bb.h,3)
end end
function abad_make_safe( force ) function abad_make_safe( force )
@@ -105,7 +107,7 @@ end
function abad_hurt(howmuch) function abad_hurt(howmuch)
print(abad.hurting.." / "..abad.respawning) howmuch = 0
if abad.hurting == 0 and abad.respawning==0 then if abad.hurting == 0 and abad.respawning==0 then
sound.play(audio_abad_hit) sound.play(audio_abad_hit)
abad.energia=abad.energia-howmuch abad.energia=abad.energia-howmuch

View File

@@ -4,6 +4,7 @@ audio_song_premiere="mus_prem.ogg"
audio_song_elalien="mus_alie.ogg" audio_song_elalien="mus_alie.ogg"
audio_life_lost="mus_life.ogg" audio_life_lost="mus_life.ogg"
audio_game_over="mus_over.ogg" audio_game_over="mus_over.ogg"
audio_song_imp="mus_imp.ogg"
audio_final=audio_main_song audio_final=audio_main_song
audio_abad_jump="snd_ajmp.wav" audio_abad_jump="snd_ajmp.wav"

View File

@@ -170,6 +170,7 @@ function game_init(menu)
table.insert( actors, trigger.new(19,32,32,triggers.escena_habitacio_batman,"habitacio batman")) table.insert( actors, trigger.new(19,32,32,triggers.escena_habitacio_batman,"habitacio batman"))
-- --
table.insert( actors, trigger.new(55,1,3,triggers.escena_lluita_imp,"lluita imp"))
-- table.insert(actors,trigger.new(14,40,32,triggers.teleport_a)) -- table.insert(actors,trigger.new(14,40,32,triggers.teleport_a))
-- table.insert(actors,trigger.new(67,8,32,triggers.teleport_b)) -- table.insert(actors,trigger.new(67,8,32,triggers.teleport_b))
-- table.insert(actors,trigger.new(29,40,32,triggers.teleport_c)) -- table.insert(actors,trigger.new(29,40,32,triggers.teleport_c))
@@ -178,6 +179,7 @@ function game_init(menu)
score.create() score.create()
local abad_x, abad_y = coords.room_to_world ( 10, 4, 3 ) local abad_x, abad_y = coords.room_to_world ( 10, 4, 3 )
-- local abad_x, abad_y = coords.room_to_world ( 54, 8, 3 )
abad:move(abad_x, abad_y) abad:move(abad_x, abad_y)
abad_make_safe( true ) abad_make_safe( true )
@@ -286,12 +288,13 @@ function update_game()
score.draw() score.draw()
-- viewp:print() font.current(font_default)
-- msg_print(0,14,"ABAD= "..abad.x..", "..abad.y, true) viewp:print()
-- msg_print(0,21,"VIEW= "..vp_x..", "..vp_y, true) msg_print(0,14,"ABAD= "..abad.x..", "..abad.y, true)
-- local hab, xx, yy = coords.world_to_tile(abad.x, abad.y) msg_print(0,21,"VIEW= "..vp_x..", "..vp_y, true)
-- msg_print(0,28,hab.." ( "..xx..", "..yy.." )", true) local hab, xx, yy = coords.world_to_tile(abad.x, abad.y)
-- msg_print(0,35,hab.." ( "..xx..", "..yy.." )", true) msg_print(0,28,hab.." ( "..xx..", "..yy.." )", true)
msg_print(0,35,hab.." ( "..xx..", "..yy.." )", true)
-- msg_print(0,42," JH= "..abad.jump_height,true) -- msg_print(0,42," JH= "..abad.jump_height,true)
-- view_coord(abad.x+8, abad.y+0, 16, 32, 6) -- view_coord(abad.x+8, abad.y+0, 16, 32, 6)
@@ -330,6 +333,82 @@ function update_game()
-- end -- end
-- msg_print(abad.x, abad.y-8,msg) -- msg_print(abad.x, abad.y-8,msg)
-- end -- end
font.current(font_sf)
end end
function pause()
print("pause()")
-- surf.source(0)
-- surf.target(back)
-- draw.surf(0,0,128,96,0,0)
-- surf.target(0)
-- surf.source(tiles)
-- pausa_option=1
-- pause_old_update=game_update
-- game_update=update_pause
end
function update_pause()
draw.rectf(16,16,97,65,16)
draw.rect(16,16,97,65,15)
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.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 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)
end
end
end
flow:registrar("game", {game_init, update_game} ) flow:registrar("game", {game_init, update_game} )

View File

@@ -5,14 +5,10 @@ gorro_gif_row = 2
gorro={name="gorro",hab=5,x=6,y=3,w=32,h=32,bb={x=0,y=0,w=16,h=16}} gorro={name="gorro",hab=5,x=6,y=3,w=32,h=32,bb={x=0,y=0,w=16,h=16}}
function gorro.init() function gorro.init()
-- local habs={{60,5},{4,5},{34,4},{62,7},{75,4}} local habs={{4,5},{12,10},{21,11},{34,4},{43,1}}
-- local r=1+math.random(0,#habs-1) local r=1+math.random(0,#habs-1)
-- gorro.hab=habs[r][1] gorro.hab=habs[r][1]
-- gorro.x=habs[r][2] gorro.x=habs[r][2]
-- gorro.x=habs[r][2]*8
gorro.hab=4
gorro.x=5
local world_x, world_y = coords.room_to_world(gorro.hab,gorro.x,gorro.y) local world_x, world_y = coords.room_to_world(gorro.hab,gorro.x,gorro.y)
gorro.x=world_x gorro.x=world_x

View File

@@ -29,6 +29,8 @@ coords.set_config({
rooms_per_floor = mapa_rooms_per_piso, rooms_per_floor = mapa_rooms_per_piso,
}) })
font_default = font.current()
function images_init() function images_init()
tiles=surf.load("tiles.gif") tiles=surf.load("tiles.gif")
surf.source(tiles) surf.source(tiles)

BIN
data/mus_imp.ogg Normal file

Binary file not shown.

View File

@@ -3,20 +3,31 @@
o2aX = arcade_config.org2arc_escala o2aX = arcade_config.org2arc_escala
avatar_abad_x = 3*o2aX avatar_abad_x = 6
avatar_abad2_x = 4*o2aX avatar_abad2_x = 8
avatar_abad_y = 0 avatar_abad_y = 0
avatar_batman_x = 4*o2aX avatar_batman_x = 8
avatar_batman_y = 48*o2aX avatar_batman_y = 96
avatar_premiere_x = 69*o2aX avatar_premiere_x = 138
avatar_premiere_y = 20*o2aX avatar_premiere_y = 40
avatar_elalien_x = 3*o2aX avatar_elalien_x = 6
avatar_elalien_y = 16*o2aX avatar_elalien_y = 32
avatar_w = 10*o2aX avatar_w = 20
avatar_h = 10*o2aX avatar_h = 20
avatar_imp_x = 134
avatar_imp_y = 96
scenes={ scenes={
lluita_imp= {
{x=avatar_abad_x,y=avatar_abad_y,flip=false,audio="abad",text={"Eh!?","...","Tu qui eres?"},die=20},
{x=avatar_imp_x, y=avatar_imp_y,flip=true,audio="abad",text={"","Aaaarrrrgghhh",""},die=20,musica=audio_song_imp},
{x=avatar_abad_x,y=avatar_abad_y,flip=false,audio="abad",text={"Who are you?","Comment tu t'appel?","Quod nomen tibi est?"},die=20},
{x=avatar_imp_x, y=avatar_imp_y,flip=true,audio="abad",text={"","Grwuuuunnnn",""},die=20},
{x=avatar_abad_x,y=avatar_abad_y,flip=false,audio="abad",text={"Eeeerrrrggggg","Prruuuuuuummm","Uooooorrrr"},die=20},
{x=avatar_imp_x, y=avatar_imp_y,flip=true,audio="abad",text={"","GROOOOAAAARRR",""},die=20},
{x=avatar_abad_x,y=avatar_abad_y,flip=false,audio="abad",text={"MERDA!!","S'HA ENFADAT!!!","CACAUS A MI!!!!"},die=20},
},
intro_01= { intro_01= {
{x=avatar_abad_x,y=avatar_abad_y,flip=false,audio="abad",text={"Ah!, què bo!","Nit de Netflix amb","un bon bol de cacaus!"},die=20}, {x=avatar_abad_x,y=avatar_abad_y,flip=false,audio="abad",text={"Ah!, què bo!","Nit de Netflix amb","un bon bol de cacaus!"},die=20},
}, },
@@ -180,6 +191,22 @@ function playtext(snd)
end end
end end
function next_scene()
scenes.dnum=scenes.dnum+1
scenes.die=scenes.current_scene[scenes.dnum].die or 0
scenes.step=2
play_music()
-- print("NEXT SCENE")
end
function play_music()
if scenes.current_scene[scenes.dnum].musica then
print("PLAY MUSIC "..scenes.dnum)
music.stop()
music.play(scenes.current_scene[scenes.dnum].musica)
end
end
function draw_scene() function draw_scene()
local txt_x = not scenes.current_scene[scenes.dnum].flip and 38 or 8 local txt_x = not scenes.current_scene[scenes.dnum].flip and 38 or 8
@@ -287,9 +314,7 @@ function update_scene()
flow:next() flow:next()
-- end -- end
else else
scenes.dnum=scenes.dnum+1 next_scene()
scenes.die=scenes.current_scene[scenes.dnum].die or 0
scenes.step=2
end end
end end
else else
@@ -314,8 +339,9 @@ function update_scene()
end end
if scenes.step>8 then if scenes.step>8 then
if key.press(keyShoot) or key.press(keyDown) or key.press(keyUp) or key.press(keyLeft) or key.press(keyRight) or key.press(key.RETURN) or if controller:check("shoot") or controller:check("down") or
pad.press(btnShoot) or pad.press(btnDown) or pad.press(btnUp) or pad.press(btnLeft) or pad.press(btnRight) then controller:check("up") or controller:check("left") or
controller:check("right") or key.press(key.RETURN) then
if scenes.dnum==#scenes.current_scene then if scenes.dnum==#scenes.current_scene then
music.stop() music.stop()
-- if batman.endgame then -- if batman.endgame then
@@ -326,8 +352,9 @@ function update_scene()
flow:next() flow:next()
-- end -- end
else else
scenes.dnum=scenes.dnum+1 -- scenes.dnum=scenes.dnum+1
scenes.step=2 -- scenes.step=2
next_scene()
end end
end end
elseif key.press(keyShoot) or pad.press(btnShoot) then elseif key.press(keyShoot) or pad.press(btnShoot) then

View File

@@ -19,7 +19,7 @@ end
function trigger:draw() function trigger:draw()
-- do nothing -- do nothing
local scr_x, scr_y = viewp:screen_coords( self.x, self.y ) local scr_x, scr_y = viewp:screen_coords( self.x, self.y )
draw.rectf(scr_x,scr_y,self.w,self.h,3) draw.rect(scr_x,scr_y,self.w,self.h,3)
end end
function trigger:update() function trigger:update()
@@ -88,6 +88,11 @@ function triggers:escena_habitacio_batman()
end end
end end
function triggers:escena_lluita_imp()
start_scene(scenes.lluita_imp)
remove_actor(self)
end
-- function triggers:teleport_a() -- function triggers:teleport_a()
-- abad.teleport=true -- abad.teleport=true
-- sound.play(audio_hit) -- sound.play(audio_hit)