From cfe78a72b655b60e3f57e19d95301ff98dd64f1a Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Thu, 29 Dec 2022 21:20:24 +0100 Subject: [PATCH] - final cutscenes finished - fade system - minor changes to stairs graphic --- batman.lua | 1 + fade.lua | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++ final.lua | 44 ++++++++++++++++++++---- game.ini | 2 +- game.lua | 5 ++- intro.lua | 54 ++++++++++++++++------------- main.lua | 5 +-- scenes.lua | 15 ++++++-- tiles.gif | Bin 4839 -> 4851 bytes 9 files changed, 188 insertions(+), 37 deletions(-) create mode 100644 fade.lua diff --git a/batman.lua b/batman.lua index 4976187..125fca0 100644 --- a/batman.lua +++ b/batman.lua @@ -18,6 +18,7 @@ end function batman.hit() if abad.objects.bol~=nil then + batman.endgame=true -- Start end of the game start_scene(scenes.final) end diff --git a/fade.lua b/fade.lua new file mode 100644 index 0000000..5d4e5c5 --- /dev/null +++ b/fade.lua @@ -0,0 +1,99 @@ +fade = { + table={13,15,5,3,12,5,6,7,12,9,10,16,9,13,14}, + pal={}, + old_update=nil, + wait=0, + step=0, + outin=false, + + init = function() + for i=1,15 do + local r,g,b=getcolor(i) + fade.pal[i]={r,g,b} + end + end, + + getstep=function(num,steps) + if steps==0 or num==16 then return num end + for i=1,steps do + num=fade.table[num] + if num==16 then return num end + end + return num + end, + + fadeout = function() + --print("fading out") + fade.old_update=_update + _update=fade.update_fadeout + fade.wait=0 + fade.step=0 + end, + + fadeoutin = function() + --print("fading outin") + fade.old_update=_update + _update=fade.update_fadeout + fade.wait=0 + fade.step=0 + fade.outin=true + end, + + update_fadeout=function() + --print("out") + fade.wait=fade.wait+1 + if fade.wait==6 then + fade.wait=0 + for i=1,15 do + local v=fade.getstep(i,fade.step) + --print(v) + if v==16 then + setcolor(i,0,0,0) + else + setcolor(i,fade.pal[v][1],fade.pal[v][2],fade.pal[v][3]) + end + end + fade.step=fade.step+1 + if fade.step==7 then + _update = fade.old_update + if fade.outin then + fade.outin=false; + fade.fadein() + end + end + end + end, + + fadein = function() + --print("fading in") + fade.old_update=_update + _update=fade.update_fadein + fade.wait=0 + fade.step=6 + for i=1,15 do setcolor(i,0,0,0) end + end, + + update_fadein=function() + --print("in") + fade.old_update() + + fade.wait=fade.wait+1 + if fade.wait==6 then + fade.wait=0 + for i=1,15 do + local v=fade.getstep(i,fade.step) + --print(v) + if v==16 then + setcolor(i,0,0,0) + else + setcolor(i,fade.pal[v][1],fade.pal[v][2],fade.pal[v][3]) + end + end + fade.step=fade.step-1 + if fade.step<0 then + _update = fade.old_update + end + end + end + +} diff --git a/final.lua b/final.lua index 2245136..55e2728 100644 --- a/final.lua +++ b/final.lua @@ -5,14 +5,17 @@ function final_init() cameras={} current_actor=1 - --table.insert(actors,zombie.new(2,24,24,false)) - abad.update = abad_nop _update=update_final next_actor() play(audio_final) + local r,g,b=getcolor(15) + setcolor(17,r,g,b) + --fade.fadein() end +go_next_actor=false + function update_final() cls(16) @@ -25,7 +28,7 @@ function update_final() rectfill(114,0,191,96,16) rect(15,40,113,89,2) - text("C A C A U S", 42, 12, 15) + text("C A C A U S", 42, 12, 17) text(actor.name, 64-(#actor.name*2), 28, 11) mapa_update(abad.hab,final_room) @@ -38,6 +41,8 @@ function update_final() play(audio_final) end end + + if go_next_actor then next_actor() end end function init_actor(name,flipped,w,h,anim) @@ -80,7 +85,9 @@ function draw_actor() end if actor.x>96 or actor.x<-actor.w or (#actor.anim==1 and actor.center_count==0) then - next_actor() + go_next_actor=true + fade.fadeoutin() + return true end end end @@ -89,6 +96,8 @@ function draw_actor() end function next_actor() + go_next_actor=false + faded = true if current_actor==1 then init_actor("ZOMBIE",false,16,16,{16,17,16,18}) elseif current_actor==2 then @@ -117,11 +126,32 @@ function next_actor() init_actor("BATMAN",false,16,16,{24,25,24,26}) elseif current_actor==13 then init_actor("EL ABAD",true,16,16,{0,1,0,2}) + elseif current_actor==14 then + final_count=0 + _update=update_final2 + fade.fadeoutin() end final_room=final_rooms[current_actor] current_actor=current_actor+1 end ----bol de cacaus ---batman ---abad +function update_final2() + cls(16) + + text("C A C A U S", 42, 12, 17) + text("GRACIES PER JUGAR", 30, 48, 10) + + if btnp(KEY_M) then + mute = not mute + if mute then + stopchirp() + else + play(audio_final) + end + end + final_count=final_count+1 + if final_count==200 or btnp(KEY_SPACE) or btnp(KEY_RETURN) then + game_init(true) + fade.fadeoutin() + end +end diff --git a/game.ini b/game.ini index 68e9a87..09005f2 100644 --- a/game.ini +++ b/game.ini @@ -2,4 +2,4 @@ title=Cacaus width=128 height=96 zoom=5 -files=final.lua,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 +files=final.lua,fade.lua,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 5265487..cb46ee4 100644 --- a/game.lua +++ b/game.lua @@ -97,7 +97,7 @@ function game_init(menu) table.insert(actors,caco.new(17,24,16,false)) -- TRIGGERS - if not menu then table.insert(actors,trigger.new(10,44,32,triggers.escena_abad_inici)) end + if not menu then table.insert(actors,trigger.new(10,57,32,triggers.escena_abad_inici)) end table.insert(actors,trigger.new(11,16,32,triggers.escena_abad_corfes)) table.insert(actors,trigger.new(31,12,32,triggers.escena_abad_portes)) @@ -128,7 +128,9 @@ function game_init(menu) play(audio_main_song) else _update=update_game + stopchirp() end + --fade.fadein() end function text(str,x,y,col) @@ -348,6 +350,7 @@ function update_menu() if btnp(KEY_SPACE) then game_exit() game_init() + fade.fadeoutin() elseif btnp(KEY_M) then mute = not mute if mute then diff --git a/intro.lua b/intro.lua index 9ebb4f5..a2ce5b0 100644 --- a/intro.lua +++ b/intro.lua @@ -12,6 +12,7 @@ function intro_init() setsource(logo) sspr(0,0,36,5,28,35,72,10) setsource(tiles) + fade.fadein() end function intro_intro() @@ -19,15 +20,9 @@ function intro_intro() text("presenta",48,50,14) intro_wait=intro_wait-1 if intro_wait==0 or btnp(KEY_ESCAPE) or btnp(KEY_SPACE) 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,true) - camera(0,0) - intro_wait=40 + intro_wait=1 _update = intro_update + fade.fadeoutin() end if btnp(KEY_M) then mute = not mute @@ -35,10 +30,13 @@ function intro_intro() end function intro_update() + --print("intro_update") --play(audio_main_song) --game_init(true) if btnp(KEY_ESCAPE) then game_init(true) + elseif btnp(KEY_SPACE) then + intro_wait=1 elseif btnp(KEY_M) then mute = not mute end @@ -46,9 +44,18 @@ function intro_update() intro_wait=intro_wait-1 if intro_wait==0 then if intro_step==0 then - start_scene(scenes.intro_01,58) - intro_step=1 + 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) + intro_step=intro_step+1 elseif intro_step==1 then + start_scene(scenes.intro_01,58) + intro_step=intro_step+1 + elseif intro_step==2 then cls(16) rect(15,3,113,53,2) camera(-16,-4) @@ -56,11 +63,11 @@ function intro_update() 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 + intro_step=intro_step+1 elseif intro_step==3 then + start_scene(scenes.intro_02,58) + intro_step=intro_step+1 + elseif intro_step==4 then cls(16) rect(15,3,113,53,2) camera(-16,-4) @@ -70,11 +77,11 @@ function intro_update() 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 + intro_step=intro_step+1 elseif intro_step==5 then + start_scene(scenes.intro_03,58) + intro_step=intro_step+1 + elseif intro_step==6 then cls(16) rect(15,3,113,53,2) camera(-16,-4) @@ -82,14 +89,15 @@ function intro_update() 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 + intro_step=intro_step+1 elseif intro_step==7 then + start_scene(scenes.intro_04,58) + intro_step=intro_step+1 + elseif intro_step==8 then play(audio_main_song) game_init(true) + fade.fadeoutin() end - intro_wait=40 + intro_wait=50 end end \ No newline at end of file diff --git a/main.lua b/main.lua index f6df7ce..3bc79ff 100644 --- a/main.lua +++ b/main.lua @@ -6,10 +6,11 @@ function _init() logo=newsurf(36,5) back=newsurf(128,96) + fade.init() --game_init() - --intro_init() - final_init() + intro_init() + --final_init() end function _update() end diff --git a/scenes.lua b/scenes.lua index 34e737c..acde26d 100644 --- a/scenes.lua +++ b/scenes.lua @@ -231,7 +231,12 @@ function update_scene() scenes.die=scenes.die-1 if scenes.die==0 then if scenes.dnum==#scenes.current_scene then - _update=old_update + if batman.endgame then + final_init() + fade.fadeoutin() + else + _update=old_update + end else scenes.dnum=scenes.dnum+1 scenes.die=scenes.current_scene[scenes.dnum].die or 0 @@ -250,8 +255,12 @@ function update_scene() elseif btnp(KEY_SPACE) then if scenes.step>8 then if scenes.dnum==#scenes.current_scene then - --freesurf(bkg) - _update=old_update + if batman.endgame then + final_init() + fade.fadeoutin() + else + _update=old_update + end else scenes.dnum=scenes.dnum+1 scenes.step=2 diff --git a/tiles.gif b/tiles.gif index d24956528498eeb1e0e8437bd58bf6e52414cf1a..15848763a4ca681e59a28961f8c988f7e3ebb5eb 100644 GIT binary patch delta 2030 zcmVa~yH zK3`|Z2@a8;x6j}RM|r~Yt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