Gotes en el mapa completades!
This commit is contained in:
127
data/gota.lua
Normal file
127
data/gota.lua
Normal file
@@ -0,0 +1,127 @@
|
||||
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,_x_offset, _y_offset)
|
||||
local world_x, world_y = arc_mapa_get_coords(_hab,_x,_y)
|
||||
_x_offset = _x_offset or 0
|
||||
_y_offset = _y_offset or 0
|
||||
world_x = world_x+_x_offset
|
||||
world_y = world_y+_y_offset
|
||||
return {hab=_hab,
|
||||
ix=world_x,
|
||||
iy=world_y,
|
||||
x=world_x,
|
||||
y=world_y,
|
||||
w=16,
|
||||
h=16,
|
||||
freq=_freq,
|
||||
cx=0,
|
||||
dx=0,
|
||||
dy=0,
|
||||
floor_y=0,
|
||||
wait=0,
|
||||
step=0,
|
||||
hit=gota.hit,
|
||||
update=gota.update_normal,
|
||||
draw=gota.draw_normal,
|
||||
draw_drop= gota.draw_drop,
|
||||
bb={x=4,y=0,w=8,h=12}}
|
||||
end
|
||||
|
||||
function gota:draw_normal()
|
||||
local x = gota_gif_col*cw
|
||||
local y = gota_gif_row*ch
|
||||
if viewp:inside(self.x, self.y, self.w, self.h) then
|
||||
local scr_x, scr_y = viewp:screen_coords( self.x, self.y )
|
||||
draw.surf(x,y,self.w,self.h,scr_x,scr_y)
|
||||
local x_check = scr_x+self.bb.x+(self.bb.w/2)-1
|
||||
local y_check = scr_y+self.bb.h
|
||||
draw.rectf(x_check,y_check,1,1,4)
|
||||
end
|
||||
end
|
||||
|
||||
function gota:update_normal()
|
||||
self.wait=self.wait+1
|
||||
|
||||
if self.wait==18 then
|
||||
self.wait=0
|
||||
self.step=self.step+1
|
||||
end
|
||||
|
||||
if self.step > self.freq then
|
||||
self.y=self.y+2
|
||||
local x_check = self.x+self.bb.x+(self.bb.w/2)-1
|
||||
local y_check = self.y+self.bb.h
|
||||
|
||||
if arc_check_tile(x_check,y_check)>=tiletype.block then
|
||||
self.update=gota.update_splash
|
||||
self.draw=gota.draw_splash
|
||||
self.floor_y=self.y+8
|
||||
self.cx=self.x+2
|
||||
self.dx=0
|
||||
self.dy=-4
|
||||
self.dy=-2
|
||||
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
|
||||
|
||||
function gota:hit()
|
||||
end
|
||||
|
||||
function gota:draw_drop( x, y )
|
||||
splash_x, splash_y = viewp:screen_coords( x, y )
|
||||
draw.circf( splash_x, splash_y, 2, 16)
|
||||
draw.circf( splash_x, splash_y, 1, 11)
|
||||
end
|
||||
|
||||
function gota:draw_splash()
|
||||
local splash_L1_x = (self.cx-self.dx)
|
||||
local splash_L2_x = (self.cx-(self.dx/2))
|
||||
local splash_R1_x = (self.cx+self.dx)
|
||||
local splash_R2_x = (self.cx+(self.dx/2))
|
||||
local splash_U_y = self.y
|
||||
local splash_D_y = self.y-1
|
||||
|
||||
self:draw_drop( splash_L1_x, splash_U_y )
|
||||
self:draw_drop( splash_L2_x, splash_D_y )
|
||||
self:draw_drop( splash_R1_x, splash_U_y )
|
||||
self:draw_drop( splash_R2_x, splash_D_y )
|
||||
end
|
||||
|
||||
function gota:update_splash()
|
||||
self.dx=self.dx-1
|
||||
self.dy=self.dy+0.25
|
||||
self.x=self.cx+self.dx
|
||||
self.y=self.y+math.floor(self.dy)
|
||||
|
||||
if self.y>self.floor_y then
|
||||
self.step=0
|
||||
self.update=gota.update_normal
|
||||
self.draw=gota.draw_normal
|
||||
self.x=self.ix
|
||||
self.y=self.iy
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user