diff --git a/data/abad.lua b/data/abad.lua index 501d946..f66b7cd 100644 --- a/data/abad.lua +++ b/data/abad.lua @@ -46,6 +46,7 @@ function abad_init() draw=abad.draw, hurting=0, update=nil, + save_update=nil, jumpfwd=false, step_length=1, vmove_space=1, @@ -156,6 +157,7 @@ end function abad_shot_cacau () if cacau:available(abad.cacau_num_shots, abad.cacau_type_shot) then sound.play(audio_abad_shot) + abad.save_update=abad.update abad.update=abad_state_fire abad.wait=0 -- cacau.init(abad.hab,abad.x+8,abad.y+8,abad.flip) @@ -346,8 +348,15 @@ function abad_state_fire() if abad.wait==6 then abad.wait=0 - abad.update=abad_state_normal + if abad.save_update==nil then + abad.update=abad_state_normal + else + abad.update=abad.save_update + abad.save_update=nil + end end + + if abad.save_update~=nil then abad_advance() end end function abad_state_walking() @@ -419,6 +428,10 @@ function abad_state_jumping() abad.step=abad.step+1 if abad.jumpfwd then abad_advance() end + + if abad.objects.llibre and controller:check("shoot") then + abad_shot_cacau() + end end @@ -456,6 +469,10 @@ function abad_state_falling() abad.jump_height = abad.jump_height-1 abad.falling=abad.falling+1 if abad.jumpfwd then abad_advance() end + + if abad.objects.llibre and controller:check("shoot") then + abad_shot_cacau() + end end function abad_state_stairs() diff --git a/data/game.lua b/data/game.lua index 800354f..5dc1f9a 100644 --- a/data/game.lua +++ b/data/game.lua @@ -1,7 +1,7 @@ viewport= require("viewport") require "abad" require "cacau" -require "gps" +require "llibre" require "gorro" require "peu" require "premiere" @@ -98,8 +98,8 @@ function game_init(menu) abad_init() table.insert(actors,abad) - gps.init() - table.insert(actors,gps) + llibre.init() + table.insert(actors,llibre) gorro.init() table.insert(actors,gorro) @@ -222,7 +222,7 @@ function update_game() local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y) end if key.press(key.N0) then - local abad_x, abad_y = coords.room_to_world ( 53, 3, 3 ) + local abad_x, abad_y = coords.room_to_world ( 41, 3, 3 ) print(abad_x..", "..abad_y) abad:move(abad_x, abad_y) local scr_ax, scr_ay = viewp:screen_coords(abad_x, abad_y) diff --git a/data/llibre.lua b/data/llibre.lua new file mode 100644 index 0000000..19f66e3 --- /dev/null +++ b/data/llibre.lua @@ -0,0 +1,40 @@ +-- posició en el gif (tiles de 32) +llibre_gif_col = 7 +llibre_gif_row = 3 + +llibre={name="llibre",hab=5,x=6,y=3,w=32,h=32,bb={x=0,y=0,w=32,h=32}} + +function llibre.init() + -- local habs={{33,8},{13,4},{51,9},{50,4},{42,7}} + -- local r=1+math.random(0,#habs-1) + -- llibre.hab=habs[r][1] + -- llibre.x=habs[r][2]*8 + -- llibre.x=habs[r][2] + llibre.hab = 41 + llibre.x = 10 + llibre.y = 2 + + local world_x, world_y = coords.room_to_world(llibre.hab,llibre.x,llibre.y) + llibre.x=world_x-4 + llibre.y=world_y-3 + + llibre.update=llibre.update + llibre.draw=llibre.draw +end + +function llibre.draw() + local x = llibre_gif_col*llibre.w + local y = llibre_gif_row*llibre.h + local scr_x, scr_y = viewp:screen_coords( llibre.x, llibre.y ) + draw.surf(x,y,llibre.w,llibre.h,scr_x,scr_y,llibre.w,llibre.h) +end + +function llibre.update() + if llibre.hab==abad.hab then + if collision(abad,llibre) then + abad.objects.llibre=true + remove_actor(llibre) + start_scene(scenes.llibre_trobat) + end + end +end diff --git a/data/main.lua b/data/main.lua index 6e5993f..93b6037 100644 --- a/data/main.lua +++ b/data/main.lua @@ -86,7 +86,7 @@ function mini.init() surf.target(0) surf.cls(16) - flow:executar("logo") + flow:executar("game") end function mini.update() diff --git a/data/scenes.lua b/data/scenes.lua index 7a89086..f9b2ac5 100644 --- a/data/scenes.lua +++ b/data/scenes.lua @@ -28,6 +28,11 @@ scenes={ {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}, }, + llibre_trobat={ + {x=avatar_abad2_x,y=avatar_abad_y,flip=false,audio="abad",text={"Este llibre...","Es el de les tècniques","especials ..."}}, + {x=avatar_abad2_x,y=avatar_abad_y,flip=false,audio="abad",text={"...","TÈCNICA 'CACAU AERI'","salt i dispar"}}, + {x=avatar_abad2_x,y=avatar_abad_y,flip=false,audio="abad",text={"Ja se"," 'CACAU AERI'",""}}, + }, 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}, }, diff --git a/data/tiles.gif b/data/tiles.gif index 716b94d..df748db 100644 Binary files a/data/tiles.gif and b/data/tiles.gif differ