diff --git a/game.ini b/game.ini index e885ac6..a19f6b9 100644 --- a/game.ini +++ b/game.ini @@ -2,4 +2,4 @@ title=Cacaus width=128 height=96 zoom=5 -files=audio.lua,dead.lua,scenes.lua,trigger.lua,score.lua,switches.lua,map.lua,mapa.lua,bol.lua,invisible.lua,gota.lua,fireball.lua,cacau.lua,bambolla.lua,imp.lua,gps.lua,peu.lua,gorro.lua,batman.lua,elalien.lua,premiere.lua,caco.lua,zombie.lua,abad.lua,game.lua,main.lua +files=audio.lua,dead.lua,scenes.lua,trigger.lua,score.lua,switches.lua,map.lua,mapa.lua,bol.lua,invisible.lua,gota.lua,fireball.lua,cacau.lua,bambolla.lua,imp.lua,gps.lua,peu.lua,gorro.lua,batman.lua,elalien.lua,premiere.lua,caco.lua,zombie.lua,abad.lua,intro.lua,game.lua,main.lua diff --git a/game.lua b/game.lua index 9b91463..80a799a 100644 --- a/game.lua +++ b/game.lua @@ -18,7 +18,7 @@ function remove_actor(actor) end end -function game_init() +function game_init(menu) actors={} cameras={} camera_names={[0]="GPS","Gorro","Peu de Paco","Premiere","EL_ALIEN","BatMan"} @@ -89,7 +89,7 @@ function game_init() table.insert(actors,caco.new(17,24,16,false)) -- TRIGGERS - table.insert(actors,trigger.new(10,44,32,triggers.escena_abad_inici)) + if not menu then table.insert(actors,trigger.new(10,44,32,triggers.escena_abad_inici)) end table.insert(actors,trigger.new(11,16,32,triggers.escena_abad_corfes)) table.insert(actors,trigger.new(19,32,32,triggers.escena_habitacio_batman)) score.create() @@ -101,7 +101,11 @@ function game_init() table.insert(cameras,elalien) table.insert(cameras,batman) - _update=update_game + if menu then + _update=update_menu + else + _update=update_game + end end function text(str,x,y,col) @@ -282,6 +286,25 @@ function update_game() end end +function update_menu() + cls(16) + text("C A C A U S", 40, 14, 15) + rect(15,44,113,93,2) + draw_hab(cameras[current_camera].hab,16,45) + + mapa_update(abad.hab,cameras[current_camera].hab) + + for key,actor in pairs(actors) do + actor:update() + end + imp.update() + bambolla.update() + cacau.update() + fireball.update() + switches.update() + +end + function game_exit() mapa_restore_backup() --freesurf(tiles) diff --git a/intro.lua b/intro.lua new file mode 100644 index 0000000..3db97a8 --- /dev/null +++ b/intro.lua @@ -0,0 +1,68 @@ +intro_wait=40 +intro_step=0 + +function intro_init() + _update = intro_update + cls(16) + rect(15,3,113,53,2) + camera(-16,-4) + mapa_draw(10) + rectfill(73,24,79,39,16) + sspr(0,0,16,16,44,24,16,16,true) + camera(0,0) +end + +function intro_update() + playchirp(audio_main_song) + game_init(true) + + intro_wait=intro_wait-1 + if intro_wait==0 then + if intro_step==0 then + start_scene(scenes.intro_01,58) + intro_step=1 + elseif intro_step==1 then + cls(16) + rect(15,3,113,53,2) + camera(-16,-4) + mapa_draw(10) + rectfill(73,24,79,39,16) + sspr(0,0,16,16,44,24,16,16,false) + camera(0,0) + intro_step=2 + elseif intro_step==2 then + start_scene(scenes.intro_02,58) + intro_step=3 + elseif intro_step==3 then + cls(16) + rect(15,3,113,53,2) + camera(-16,-4) + mapa_draw(10) + rectfill(73,24,79,39,16) + sspr(0,0,16,16,44,24,16,16,false) + sspr(112,88,16,8,76,32,16,8,true) + sspr(0,48,16,16,82,24,16,16,true) + camera(0,0) + intro_step=4 + elseif intro_step==4 then + start_scene(scenes.intro_03,58) + intro_step=5 + elseif intro_step==5 then + cls(16) + rect(15,3,113,53,2) + camera(-16,-4) + mapa_draw(10) + rectfill(73,24,79,39,16) + sspr(0,0,16,16,44,24,16,16,false) + camera(0,0) + intro_step=6 + elseif intro_step==6 then + start_scene(scenes.intro_04,58) + intro_step=7 + elseif intro_step==7 then + playchirp(audio_main_song) + game_init(true) + end + intro_wait=40 + end +end \ No newline at end of file diff --git a/main.lua b/main.lua index bfd73cd..5bc087d 100644 --- a/main.lua +++ b/main.lua @@ -4,7 +4,8 @@ function _init() local pal=loadpal("tiles.gif") setpal(pal) - game_init() + --game_init() + intro_init() end function _update() end diff --git a/scenes.lua b/scenes.lua index 952ef17..2bbd5ab 100644 --- a/scenes.lua +++ b/scenes.lua @@ -1,4 +1,21 @@ scenes={ + intro_01= { + {x=3,y=0,flip=false,audio=audio_text_abad,text={"Aaaah, que bo!","Nit de Netflix amb","un bon bol de cacaus!"},die=20}, + }, + intro_02= { + {x=3,y=0,flip=false,audio=audio_text_abad,text={"Eh! On està el","bol de cacaus???",""},die=20}, + }, + intro_03= { + {x=4,y=48,flip=true,audio=audio_text_batman,text={"ME'L HE ENDUT JO!!!", "S'HAN ACABAT ELS","CACAUS PA TU!"},die=20}, + {x=3,y=0,flip=false,audio=audio_text_abad,text={"Qué??","Però perqué???",""},die=20}, + {x=4,y=48,flip=true,audio=audio_text_batman,text={"Estas com una vaca!","Has de deixar de menjar", "eixes gorrinades"},die=20}, + {x=4,y=48,flip=true,audio=audio_text_batman,text={"Mira'm a mí. Estic","tot buenorro i faig", "esport"},die=20}, + {x=3,y=0,flip=false,audio=audio_text_abad,text={"Esport?????","I una merda!!","He de cuidar la panxa!"},die=20}, + {x=4,y=48,flip=true,audio=audio_text_batman,text={"Pos t'aguantes.","Ja pots despedir-te", "dels cacaus..."},die=20}, + }, + intro_04= { + {x=3,y=0,flip=false,audio=audio_text_abad,text={"Serà mamó...","",""},die=20}, + }, abad_inici={ {x=4,y=0,flip=false,audio=audio_text_abad,text={"Se va a enterar eixe","imbècil de Batman","quan el pille..."}}, {x=4,y=0,flip=false,audio=audio_text_abad,text={"Gonna per el GPS","per a trobarlo.",""}}, @@ -83,24 +100,28 @@ scenes={ }, } -function start_scene(scene) +function start_scene(scene,offset,die) --bkg=newsurf(128,96) --setdest(bkg) --setsource(0) --sspr(0,0,128,96,0,0) --setsource(tiles) --setdest(0) - _update=update_scene scenes.current_scene=scene scenes.dnum=1 scenes.step=0 scenes.char=1 scenes.wait=0 + scenes.offset=28 + scenes.die=scenes.current_scene[scenes.dnum].die or 0 + if offset then scenes.offset=offset end + old_update=_update + _update=update_scene end function draw_scene() local txt_x = not scenes.current_scene[scenes.dnum].flip and 38 or 8 - camera(0,-28) + camera(0,-scenes.offset) if scenes.step==0 then rectfill(0,16,128,17,12) line(0,15,128,15,16) @@ -181,12 +202,24 @@ function update_scene() if scenes.wait==6 then scenes.wait=0 draw_scene() + if scenes.step>8 and scenes.die>0 then + scenes.die=scenes.die-1 + if scenes.die==0 then + if scenes.dnum==#scenes.current_scene then + _update=old_update + else + scenes.dnum=scenes.dnum+1 + scenes.die=scenes.current_scene[scenes.dnum].die or 0 + scenes.step=2 + end + end + end end if btnp(KEY_SPACE) then if scenes.step>8 then if scenes.dnum==#scenes.current_scene then --freesurf(bkg) - _update=update_game + _update=old_update else scenes.dnum=scenes.dnum+1 scenes.step=2