- [NEW] Gota

This commit is contained in:
2026-03-23 08:14:37 +01:00
parent d5c0dfddeb
commit 53aea81265
9 changed files with 141 additions and 0 deletions

BIN
data/gfx/gota.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -204,4 +204,32 @@ animations = {
{ frame={x=27,y=0,w=9,h=8}, wait=2 }
}
},
["gota_generador"] = {
cycle = {1,2,3,4,5,6,7,8},
loop = false,
frames = {
{ frame={x=0,y=0,w=8,h=8}, wait=2 },
{ frame={x=8,y=0,w=8,h=8}, wait=2 },
{ frame={x=16,y=0,w=8,h=8}, wait=2 },
{ frame={x=24,y=0,w=8,h=8}, wait=2 },
{ frame={x=32,y=0,w=8,h=8}, wait=2 },
{ frame={x=40,y=0,w=8,h=8}, wait=2 },
{ frame={x=48,y=0,w=8,h=8}, wait=50 },
{ frame={x=48,y=0,w=8,h=8}, wait=1 }
}
},
["gota"] = {
cycle = {1},
loop = false,
frames = {
{ frame={x=48,y=0,w=8,h=8}, wait=100 }
}
},
["esguit"] = {
cycle = {1},
loop = false,
frames = {
{ frame={x=56,y=0,w=8,h=8}, wait=100 }
}
},
}

62
data/modules/ia/gota.lua Normal file
View File

@@ -0,0 +1,62 @@
function ia.update_gota(spr)
if spr.timer > 0 then
spr.invisible = true
spr.timer = spr.timer-1
if spr.timer == 1 then
spr.animation_finished = nil
spr.current_frame = 1
spr.current_wait = 1
end
else
spr.invisible = nil;
if spr.animation_finished then
local gota = templates.create("gota_caiguent", {pos={x=spr.pos.x, y=spr.pos.y}, flipped=spr.flipped})
table.insert(sprites.list, gota)
spr.animation_finished = nil
spr.current_frame = 1
spr.current_wait = 1
end
end
end
function gota_esguita(spr)
sprites.remove(spr)
table.insert(sprites.list, templates.create("gota_esguit", {pos={x=spr.pos.x, y=spr.pos.y}, dir={x= 1,y= math.random(3,5)}, flipped=spr.flipped}))
table.insert(sprites.list, templates.create("gota_esguit", {pos={x=spr.pos.x, y=spr.pos.y}, dir={x=-1,y= math.random(3,5)}, flipped=spr.flipped}))
table.insert(sprites.list, templates.create("gota_esguit", {pos={x=spr.pos.x, y=spr.pos.y}, dir={x=-1,y=-math.random(3,5)}, flipped=spr.flipped}))
table.insert(sprites.list, templates.create("gota_esguit", {pos={x=spr.pos.x, y=spr.pos.y}, dir={x= 1,y=-math.random(3,5)}, flipped=spr.flipped}))
end
function ia.update_gota_caiguent(spr)
local tx, ty = (spr.pos.x+4)>>3, (spr.pos.y+4)>>3
if rooms.is_outside(tx,ty) then sprites.remove(spr) return end
if map.tile(tx,ty) >= 16 then
gota_esguita(spr)
end
if sprites.hero.state == templates.ALIVE then
local x1,y1,w1,h1 = util.aabb(spr) -- El meu aabb
local x2,y2,w2,h2 = util.aabb(sprites.hero) -- el aabb del heroi
-- Si toca al heroi...
if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then
sprites.hero.hit()
gota_esguita(spr)
end
end
spr.pos.y = spr.pos.y + 1
end
function ia.update_gota_esguit(spr)
local tx, ty = (spr.pos.x+4)>>3, (spr.pos.y+4)>>3
if rooms.is_outside(tx,ty) then sprites.remove(spr) return end
spr.dir.y = spr.dir.y + 1;
spr.pos.y = spr.pos.y + spr.dir.y
spr.pos.x = spr.pos.x + spr.dir.x
end

View File

@@ -16,4 +16,5 @@ items = {
{ name="sucubo 75", label="sucubo75", visual={x=0, y=64, w=16, h=16} },
{ name="nemesio", label="nemesio", visual={x=16, y=80, w=16, h=16} },
{ name="rata", label="rata", visual={x=80, y=48, w=9, h=8} },
{ name="gota", label="gota", visual={x=80, y=56, w=8, h=8} },
}

View File

@@ -192,6 +192,56 @@ function me.create(type, options)
room = options.room,
ia = ia.update_rata
}
elseif key == "gota" then
sprite = {
type = key,
pos = options.pos,--{ x=100, y=4*12*8+71 },
size = { w=8,h=8 },
bbo = { left=2, top=3, right=3, bottom=1 },
current_frame = 1,
current_wait = 1,
flipped = options.flipped,
surf = surf.load("gfx/gota.gif"),
animation = "gota_generador",
state = me.ALIVE,
enemy = true,
timer = 0,
room = options.room,
ia = ia.update_gota
}
elseif key == "gota_caiguent" then
sprite = {
type = key,
pos = options.pos,--{ x=100, y=4*12*8+71 },
size = { w=8,h=8 },
bbo = { left=2, top=3, right=3, bottom=1 },
current_frame = 1,
current_wait = 1,
flipped = options.flipped,
surf = surf.load("gfx/gota.gif"),
animation = "gota",
state = me.ALIVE,
enemy = true,
room = options.room,
ia = ia.update_gota_caiguent
}
elseif key == "gota_esguit" then
sprite = {
type = key,
pos = options.pos,--{ x=100, y=4*12*8+71 },
dir = options.dir,
size = { w=8,h=8 },
bbo = { left=2, top=3, right=3, bottom=1 },
current_frame = 1,
current_wait = 1,
flipped = options.flipped,
surf = surf.load("gfx/gota.gif"),
animation = "esguit",
state = me.ALIVE,
enemy = true,
room = options.room,
ia = ia.update_gota_esguit
}
else
error("Template not recognized")
end