Files
paku/data/modules/ia/gota.lua
T
Raimon @ quifisraimon d2ebbccbf6 - [NEW] El mono
- [NEW] Noves animacions de detallets
- [NEW] Més particles i eye candy
- [FIX] Si es ficava un item/enemic en la fila de baix del tot no es guardaba
- [FIX] Quan se disaparaba cap a la dreta amb el final de la pantalla o una pared en la esquena, la bala no eixia
- [WIP] Treballant en el marcador
2026-10-06 15:56:37 +02:00

71 lines
2.5 KiB
Lua

function ia.update_gota(spr)
if spr.timer > 0 then
spr.timer = spr.timer-1
if spr.timer == 0 then
sprites.set_animation(spr, "gota_generador")
end
return
else
spr.invisible = nil;
if spr.current_frame==2 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)
local dir = 0.1
if spr.flipped then dir = -dir end
sprites.dust_ex(spr, {pos={x=spr.pos.x, y=spr.pos.y}, dir={x=-0.1,y=-1.2}, flipped=not spr.flipped})
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 = sprites.get_tile(spr.pos.x+4), sprites.get_tile(spr.pos.y+4)
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 = sprites.get_tile(spr.pos.x+4), sprites.get_tile(spr.pos.y+4)
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
function ia.update_polseta(spr)
if spr.current_frame==5 then sprites.remove(spr) return end
spr.dir.y = spr.dir.y + 0.1;
spr.pos.y = spr.pos.y + spr.dir.y
spr.pos.x = spr.pos.x + spr.dir.x
end