- bambolla implemented
This commit is contained in:
126
bambolla.lua
Normal file
126
bambolla.lua
Normal file
@@ -0,0 +1,126 @@
|
||||
bambolla={hab=75,x=24,y=24,cx=0,dx=0,dy=0,flip=true,enabled=false,counter=200,wait=0,bb={x=2,y=2,w=12,h=12}}
|
||||
|
||||
function bambolla.reset()
|
||||
bambolla.hit=bambolla.hit
|
||||
bambolla.update=bambolla.update_normal
|
||||
bambolla.draw=bambolla.draw_normal
|
||||
bambolla.hab=abad.hab
|
||||
bambolla.enabled=false
|
||||
bambolla.counter=200
|
||||
end
|
||||
|
||||
function bambolla.init()
|
||||
bambolla.enabled=false
|
||||
bambolla.hit=bambolla.hit
|
||||
bambolla.update=bambolla.update_normal
|
||||
bambolla.draw=bambolla.draw_normal
|
||||
bambolla.hab=abad.hab
|
||||
if abad.x<40 then
|
||||
if check_tile(bambolla.hab,92,38)<tiletype.half and
|
||||
check_tile(bambolla.hab,84,38)<tiletype.half and
|
||||
check_tile(bambolla.hab,92,30)<tiletype.half and
|
||||
check_tile(bambolla.hab,84,30)<tiletype.half and
|
||||
check_tile(bambolla.hab,92,46)>=tiletype.half then
|
||||
bambolla.enabled=true
|
||||
bambolla.flip=true
|
||||
bambolla.x=92
|
||||
else
|
||||
bambolla.reset()
|
||||
end
|
||||
else
|
||||
if check_tile(bambolla.hab,0,38)<tiletype.half and
|
||||
check_tile(bambolla.hab,8,38)<tiletype.half and
|
||||
check_tile(bambolla.hab,0,30)<tiletype.half and
|
||||
check_tile(bambolla.hab,0,30)<tiletype.half and
|
||||
check_tile(bambolla.hab,0,46)>=tiletype.half then
|
||||
bambolla.enabled=true
|
||||
bambolla.flip=false
|
||||
bambolla.x=-12
|
||||
else
|
||||
bambolla.reset()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function bambolla.draw_normal()
|
||||
if bambolla.enabled then
|
||||
sspr(112,16,16,16,bambolla.x,bambolla.y,16,16)
|
||||
end
|
||||
end
|
||||
|
||||
function bambolla.hit()
|
||||
end
|
||||
|
||||
function bambolla.update_normal()
|
||||
bambolla.wait=bambolla.wait+1
|
||||
|
||||
if bambolla.wait==3 then
|
||||
bambolla.wait=0
|
||||
if not bambolla.enabled then
|
||||
bambolla.counter=bambolla.counter-1
|
||||
local r = rnd(bambolla.counter)
|
||||
print(r)
|
||||
if bambolla.counter==1 or r==1 then
|
||||
bambolla.init()
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if bambolla.flip then
|
||||
bambolla.x=bambolla.x-2
|
||||
if bambolla.x<=-12 then
|
||||
bambolla.reset()
|
||||
end
|
||||
else
|
||||
bambolla.x=bambolla.x+2
|
||||
if bambolla.x>=92 then
|
||||
bambolla.reset()
|
||||
end
|
||||
end
|
||||
bambolla.y=28-abs(sin(bambolla.x*0.1))*24
|
||||
|
||||
if bambolla.hab==abad.hab then
|
||||
if aabb(bambolla,abad) then
|
||||
--bambolla.hab=-1
|
||||
if abad.energia>0 then abad.energia=abad.energia-1 end
|
||||
bambolla.update=bambolla.update_splash
|
||||
bambolla.draw=bambolla.draw_splash
|
||||
bambolla.cx=bambolla.x+8
|
||||
bambolla.y=bambolla.y+8
|
||||
bambolla.dx=0
|
||||
bambolla.dy=-4
|
||||
cls(3)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
bambolla.update=bambolla.update_normal
|
||||
bambolla.draw=bambolla.draw_normal
|
||||
|
||||
function bambolla.draw_splash()
|
||||
circfill(bambolla.cx+bambolla.dx,bambolla.y,2,16)
|
||||
circfill(bambolla.cx+bambolla.dx,bambolla.y,1,6)
|
||||
circfill(bambolla.cx-bambolla.dx,bambolla.y,2,16)
|
||||
circfill(bambolla.cx-bambolla.dx,bambolla.y,1,6)
|
||||
circfill(bambolla.cx-(bambolla.dx/2),bambolla.y-4,2,16)
|
||||
circfill(bambolla.cx-(bambolla.dx/2),bambolla.y-4,1,6)
|
||||
circfill(bambolla.cx+(bambolla.dx/2),bambolla.y-4,2,16)
|
||||
circfill(bambolla.cx+(bambolla.dx/2),bambolla.y-4,1,6)
|
||||
end
|
||||
|
||||
function bambolla.update_splash()
|
||||
bambolla.wait=bambolla.wait+1
|
||||
|
||||
if bambolla.wait==3 then
|
||||
bambolla.wait=0
|
||||
bambolla.dx=bambolla.dx-2
|
||||
bambolla.x=bambolla.cx+bambolla.dx
|
||||
bambolla.y=bambolla.y+bambolla.dy
|
||||
bambolla.dy=bambolla.dy+1
|
||||
if bambolla.y>48 then
|
||||
bambolla.reset()
|
||||
end
|
||||
end
|
||||
end
|
||||
2
game.ini
2
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,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
|
||||
files=scenes.lua,starter.lua,score.lua,switches.lua,map.lua,mapa.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,main.lua
|
||||
|
||||
2
main.lua
2
main.lua
@@ -92,6 +92,7 @@ function draw_hab(hab,x,y,editing)
|
||||
end
|
||||
end
|
||||
if imp.hab==hab then imp.draw() end
|
||||
if bambolla.hab==hab then bambolla.draw() end
|
||||
if cacau.hab==hab then cacau:draw() end
|
||||
if fireball.hab==hab then fireball:draw() end
|
||||
end
|
||||
@@ -201,6 +202,7 @@ function update_game()
|
||||
end
|
||||
end
|
||||
imp.update()
|
||||
bambolla.update()
|
||||
cacau.update()
|
||||
fireball.update()
|
||||
switches.update()
|
||||
|
||||
Reference in New Issue
Block a user