forked from JailDoctor/cacaus
91 lines
2.6 KiB
Lua
91 lines
2.6 KiB
Lua
local arcade_config = require("arcade_config")
|
|
o2aX = arcade_config.org2arc_escala
|
|
cxr = arcade_config.character_per_row-1
|
|
cxr2 = arcade_config.character_per_row_base2
|
|
cw = arcade_config.character_width
|
|
ch = arcade_config.character_height
|
|
-- posició en el gif
|
|
gota_gif_col = 7
|
|
gota_gif_row = 0
|
|
|
|
gota={}
|
|
|
|
function gota.new(_hab,_x,_y,_freq)
|
|
return {hab=_hab,ix=_x,iy=_y,x=_x,y=_y,freq=_freq,cx=0,dx=0,dy=0,wait=0,step=0,hit=gota.hit,update=gota.update_normal, draw=gota.draw_normal,bb={x=2,y=0,w=4,h=6}}
|
|
end
|
|
|
|
function gota:draw_normal()
|
|
-- draw.surf(112,0,8,8,self.x,self.y)
|
|
local x = gota_gif_col*cw
|
|
local y = gota_gif_row*ch
|
|
local cw= 8*o2aX
|
|
local ch= 8*o2aX
|
|
draw.surf(x,y,cw,ch,self.x*o2aX,self.y*o2aX)
|
|
end
|
|
|
|
function gota:update_normal()
|
|
self.wait=self.wait+1
|
|
|
|
if self.wait==6 then
|
|
self.wait=0
|
|
self.step=self.step+1
|
|
if self.step > self.freq then
|
|
self.y=self.y+4
|
|
if check_tile(self.hab,self.x+2,self.y+2)>=tiletype.block then
|
|
self.update=gota.update_splash
|
|
self.draw=gota.draw_splash
|
|
self.cx=self.x+2
|
|
self.dx=0
|
|
self.dy=-4
|
|
if self.hab==abad.hab then sound.play(audio_low) end
|
|
end
|
|
else
|
|
--self.flip=not self.flip
|
|
end
|
|
|
|
if self.hab==abad.hab then
|
|
if aabb(abad,self) then
|
|
abad_hurt(1)
|
|
self.update=gota.update_splash
|
|
self.draw=gota.draw_splash
|
|
self.cx=self.x+2
|
|
self.dx=0
|
|
self.dy=-4
|
|
end
|
|
end
|
|
|
|
end
|
|
end
|
|
|
|
function gota:hit()
|
|
end
|
|
|
|
function gota:draw_splash()
|
|
draw.circf( (self.cx+self.dx)*o2aX, self.y*o2aX, 2*o2aX, 16)
|
|
draw.circf( (self.cx+self.dx)*o2aX, self.y*o2aX, 1*o2aX, 11)
|
|
draw.circf( (self.cx-self.dx)*o2aX, self.y*o2aX, 2*o2aX, 16)
|
|
draw.circf( (self.cx-self.dx)*o2aX, self.y*o2aX, 1*o2aX, 11)
|
|
draw.circf( (self.cx-(self.dx/2))*o2aX, (self.y-4)*o2aX, 2*o2aX, 16)
|
|
draw.circf( (self.cx-(self.dx/2))*o2aX, (self.y-4)*o2aX, 1*o2aX, 11)
|
|
draw.circf( (self.cx+(self.dx/2))*o2aX, (self.y-4)*o2aX, 2*o2aX, 16)
|
|
draw.circf( (self.cx+(self.dx/2))*o2aX, (self.y-4)*o2aX, 1*o2aX, 11)
|
|
end
|
|
|
|
function gota:update_splash()
|
|
self.wait=self.wait+1
|
|
|
|
if self.wait==3 then
|
|
self.wait=0
|
|
self.dx=self.dx-2
|
|
self.x=self.cx+self.dx
|
|
self.y=self.y+self.dy
|
|
self.dy=self.dy+1
|
|
if self.y>48 then
|
|
self.step=0
|
|
self.update=gota.update_normal
|
|
self.draw=gota.draw_normal
|
|
self.x=self.ix
|
|
self.y=self.iy
|
|
end
|
|
end
|
|
end |