From 9a01fff6e3e20b7d577aa5d1174aabd19246fa88 Mon Sep 17 00:00:00 2001 From: JailDoctor Date: Thu, 17 Nov 2022 20:09:02 +0100 Subject: [PATCH] - [NEW] Gota implementada --- game.ini | 2 +- gota.lua | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ main.lua | 2 ++ 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 gota.lua diff --git a/game.ini b/game.ini index f8132bd..27debc4 100644 --- a/game.ini +++ b/game.ini @@ -2,4 +2,4 @@ title=Cacaus width=128 height=96 zoom=5 -files=dead.lua,scenes.lua,trigger.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 +files=dead.lua,scenes.lua,trigger.lua,score.lua,switches.lua,map.lua,mapa.lua,gota.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 diff --git a/gota.lua b/gota.lua new file mode 100644 index 0000000..c587396 --- /dev/null +++ b/gota.lua @@ -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 \ No newline at end of file diff --git a/main.lua b/main.lua index 317f9ab..7406901 100644 --- a/main.lua +++ b/main.lua @@ -52,6 +52,8 @@ function _init() table.insert(actors,batman) -- MALOTES PERSISTENTS + table.insert(actors,gota.new(10,80,4,20)) + table.insert(actors,zombie.new(2,24,24,false)) table.insert(actors,caco.new(13,24,16,true)) table.insert(actors,caco.new(20,24,16,false))