From b756186984bab0d8d9ab6552ac42c24195ccdc37 Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Wed, 28 Dec 2022 16:40:36 +0100 Subject: [PATCH] - Intro i menu --- abad.lua | 3 +++ dead.lua | 5 +++-- game.lua | 45 +++++++++++++++++++++++++++++++++++---------- intro.lua | 4 ++-- 4 files changed, 43 insertions(+), 14 deletions(-) diff --git a/abad.lua b/abad.lua index 48c0d11..8064ac6 100644 --- a/abad.lua +++ b/abad.lua @@ -1,6 +1,9 @@ abad={x=40,y=24,flip=false,frame=1,wait=0,hab=10,vides=3,energia=40,falling=0,step=0, mustep=1,hurting=0,update=nil,jumpfwd=false,anim={0,1,0,2},bb={x=4,y=0,w=8,h=16},safe={hab=10,x=40,y=24}} +function abad_nop() +end + function abad_init() abad={x=40,y=24,flip=false,frame=1,wait=0,hab=10,vides=3,energia=40,falling=0,step=0,mustep=1,draw=abad.draw,hurting=0,update=nil,jumpfwd=false,anim={0,1,0,2},bb={x=4,y=0,w=8,h=16},safe={hab=10,x=40,y=24}} abad.update=abad_state_normal diff --git a/dead.lua b/dead.lua index df67022..e8f77a6 100644 --- a/dead.lua +++ b/dead.lua @@ -41,7 +41,8 @@ function dead.update() if (dead.count>250 and btnp(KEY_SPACE)) or dead.count>500 then game_exit() - _init() - _update=update_game + game_init() + --_init() + --_update=update_game end end \ No newline at end of file diff --git a/game.lua b/game.lua index 80a799a..917ea64 100644 --- a/game.lua +++ b/game.lua @@ -1,7 +1,8 @@ --hab=0 modes={playing=0,editing=1} -mode=modes.editing +--mode=modes.editing +mode=modes.playing seltile = 0 @@ -101,8 +102,14 @@ function game_init(menu) table.insert(cameras,elalien) table.insert(cameras,batman) + mapa_do_backup() + if menu then + abad.update = abad_nop _update=update_menu + menu_count=0 + menu_change_room=300 + menu_room=rnd(60) else _update=update_game end @@ -182,7 +189,7 @@ function update_game() abad.hab=abad.hab-10 elseif btnp(KEY_RETURN) then mode=modes.playing - mapa_do_backup() + --mapa_do_backup() --playchirp(audio_main_song); elseif btnp(KEY_S) and (btn(KEY_LCTRL) or btn(KEY_LGUI)) then _update=update_dialog @@ -286,13 +293,28 @@ 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) +function update_menu() + menu_count=menu_count+1 + menu_change_room=menu_change_room-1 + if menu_change_room==0 then + menu_room = rnd(60) + menu_change_room=300 + end + + cls(16) + text("C A C A U S", 40, 12, 15) + if menu_count<20 then + text("Pulsa SPACE", 40, 28, 13) + else + text("Pulsa SPACE", 40, 28, 16) + if menu_count>40 then menu_count=0 end + end + draw_hab(menu_room,16,41) + rectfill(0,0,14,96,16) + rectfill(114,0,191,96,16) + rect(15,40,113,89,2) + mapa_update(abad.hab,menu_room) for key,actor in pairs(actors) do actor:update() @@ -302,12 +324,15 @@ function update_menu() cacau.update() fireball.update() switches.update() - + + if btn(KEY_SPACE) then + game_exit() + game_init() + end end function game_exit() mapa_restore_backup() - --freesurf(tiles) actors={} cameras={} end diff --git a/intro.lua b/intro.lua index 3db97a8..16be2ed 100644 --- a/intro.lua +++ b/intro.lua @@ -13,8 +13,8 @@ function intro_init() end function intro_update() - playchirp(audio_main_song) - game_init(true) + --playchirp(audio_main_song) + --game_init(true) intro_wait=intro_wait-1 if intro_wait==0 then