diff --git a/abad.lua b/abad.lua index d58a76a..eb0e2c7 100644 --- a/abad.lua +++ b/abad.lua @@ -71,6 +71,7 @@ function abad_advance() if abad.update~=abad_state_walking then limit=tiletype.half end if not abad.flip and abad.x==84 then abad.hab=abad.hab+1 + imp.reset() abad.x=-4 elseif check_tile(abad.hab,abad.x+inc,abad.y+14)6 then @@ -197,6 +200,7 @@ function abad_state_falling() abad.y=abad.y+2 else abad.hab=abad.hab+10 + imp.reset() abad.y=0 end end @@ -222,6 +226,7 @@ function abad_state_stairs() end else abad.hab=abad.hab-10 + imp.reset() abad.y=32 end elseif btn(KEY_DOWN) then @@ -231,6 +236,7 @@ function abad_state_stairs() end else abad.hab=abad.hab+10 + imp.reset() abad.y=0 end end diff --git a/fireball.lua b/fireball.lua new file mode 100644 index 0000000..bb337b2 --- /dev/null +++ b/fireball.lua @@ -0,0 +1,50 @@ +fireball={hab=-1,x=0,y=0,wait=0,flip=false,bb={x=0,y=0,w=4,h=4}} + +function fireball.init(_hab,_x,_y,_flip) + if fireball.hab ~= -1 then return end + fireball.hab=_hab + fireball.x=_x + fireball.y=_y + fireball.flip=_flip +end + +function fireball:draw() + circfill(fireball.x,fireball.y,3,16) + circfill(fireball.x,fireball.y,2,3) + circfill(fireball.x,fireball.y,1,8) +end + +function fireball:update() + if fireball.hab == -1 then return end + fireball.wait=fireball.wait+1 + + if fireball.wait==3 then + fireball.wait=0 + + if fireball.x>96 then + fireball.hab=-1 + return + elseif check_tile(fireball.hab,fireball.x,fireball.y)0 then abad.energia=abad.energia-1 end + cls(3) + end + end + end +end diff --git a/game.ini b/game.ini index 67d18dd..bcae176 100644 --- a/game.ini +++ b/game.ini @@ -2,4 +2,4 @@ title=Cacaus width=128 height=96 zoom=5 -files=scenes.lua,starter.lua,score.lua,switches.lua,map.lua,mapa.lua,cacau.lua,gps.lua,peu.lua,gorro.lua,batman.lua,elalien.lua,premiere.lua,caco.lua,zombie.lua,abad.lua,main.lua +files=scenes.lua,starter.lua,score.lua,switches.lua,map.lua,mapa.lua,fireball.lua,cacau.lua,imp.lua,gps.lua,peu.lua,gorro.lua,batman.lua,elalien.lua,premiere.lua,caco.lua,zombie.lua,abad.lua,main.lua diff --git a/imp.lua b/imp.lua new file mode 100644 index 0000000..b6941b9 --- /dev/null +++ b/imp.lua @@ -0,0 +1,92 @@ +imp={hab=75,x=24,y=24,flip=true,enabled=false,counter=100,frame=28,wait=0,step=0,anim={28,29,28,30},bb={x=4,y=0,w=8,h=16},scene_intro=false,scene_object=false} + +function imp.reset() + imp.hit=imp.hit + imp.update=imp.update + imp.draw=imp.draw + imp.hab=abad.hab + imp.enabled=false + imp.counter=100 +end + +function imp.init() + imp.enabled=false + imp.hit=imp.hit + imp.update=imp.update + imp.draw=imp.draw + imp.hab=abad.hab + if abad.x<40 then + if check_tile(imp.hab,92,38)=tiletype.half then + imp.enabled=true + imp.flip=true + imp.x=92 + else + imp.reset() + end + else + if check_tile(imp.hab,0,38)=tiletype.half then + imp.enabled=true + imp.flip=false + imp.x=-12 + else + imp.reset() + end + end +end + +function imp.draw() + if imp.enabled then + sspr((imp.frame&7)*16,(imp.frame>>3)*16,16,16,imp.x,imp.y,16,16,imp.flip) + end +end + +function imp.hit() +end + +function imp.update() + imp.wait=imp.wait+1 + + if imp.wait==6 then + imp.wait=0 + if not imp.enabled then + imp.counter=imp.counter-1 + local r = rnd(imp.counter) + print(r) + if imp.counter==1 or r==1 then + imp.init() + end + return + end + + imp.step=(imp.step+1)%4 + imp.frame=imp.anim[imp.step+1] + + if imp.flip then + imp.x=imp.x-2 + if imp.x==78 then + fireball.init(imp.hab,imp.x+8,imp.y+4,imp.flip) + imp.flip=not imp.flip + elseif imp.x==-12 then + imp.reset() + end + else + imp.x=imp.x+2 + if imp.x==4 then + fireball.init(imp.hab,imp.x+8,imp.y+4,imp.flip) + imp.flip=not imp.flip + elseif imp.x==92 then + imp.reset() + end + end + + end +end + diff --git a/main.lua b/main.lua index 18ac840..b9941f6 100644 --- a/main.lua +++ b/main.lua @@ -24,7 +24,7 @@ function _init() local pal=loadpal("tiles.gif") setpal(pal) - --mapa_new() + -- ACTORS PRINCIPALS abad_init() table.insert(actors,abad) @@ -46,11 +46,13 @@ function _init() batman.init() table.insert(actors,batman) + -- MALOTES PERSISTENTS z = zombie.new() table.insert(actors,z) c=caco.new(13,24,16,true) table.insert(actors,c) + -- STARTERS table.insert(actors,starter.new(10,44,32,scenes.abad_inici)) table.insert(actors,starter.new(11,16,32,scenes.abad_corfes)) score.create() @@ -89,7 +91,9 @@ function draw_hab(hab,x,y,editing) actor:draw() end end + if imp.hab==hab then imp.draw() end if cacau.hab==hab then cacau:draw() end + if fireball.hab==hab then fireball:draw() end end camera(0,0) end @@ -196,7 +200,9 @@ function update_game() end end end + imp.update() cacau.update() + fireball.update() switches.update() if btnp(KEY_RETURN) then