- [NEW] Gota implementada
This commit is contained in:
75
gota.lua
Normal file
75
gota.lua
Normal file
@@ -0,0 +1,75 @@
|
||||
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()
|
||||
sspr(112,0,8,8,self.x,self.y)
|
||||
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
|
||||
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()
|
||||
circfill(self.cx+self.dx,self.y,2,16)
|
||||
circfill(self.cx+self.dx,self.y,1,11)
|
||||
circfill(self.cx-self.dx,self.y,2,16)
|
||||
circfill(self.cx-self.dx,self.y,1,11)
|
||||
circfill(self.cx-(self.dx/2),self.y-4,2,16)
|
||||
circfill(self.cx-(self.dx/2),self.y-4,1,11)
|
||||
circfill(self.cx+(self.dx/2),self.y-4,2,16)
|
||||
circfill(self.cx+(self.dx/2),self.y-4,1,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
|
||||
Reference in New Issue
Block a user