- [NEW] Sucubo acabat i funcionant
This commit is contained in:
24
data/modules/ia/palo.lua
Normal file
24
data/modules/ia/palo.lua
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
function ia.update_palo(spr)
|
||||
local tx, ty, ty2 = (spr.pos.x+2)>>3, (spr.pos.y+1)>>3, (spr.pos.y+2)>>3
|
||||
|
||||
if rooms.is_outside(tx,ty) then sprites.remove(spr) return 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()
|
||||
end
|
||||
end
|
||||
|
||||
spr.dy = spr.dy + spr.ay;
|
||||
spr.pos.y = spr.pos.y + spr.dy
|
||||
if spr.flipped then
|
||||
spr.pos.x = spr.pos.x - 6
|
||||
else
|
||||
spr.pos.x = spr.pos.x + 6
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,23 @@
|
||||
|
||||
function ia.update_sucubo(spr)
|
||||
|
||||
map.surf(rooms.surf_foreground)
|
||||
|
||||
if spr.state == templates.ALIVE then
|
||||
spr.timer = spr.timer + 1
|
||||
if spr.timer==100 then
|
||||
sprites.set_animation(spr, "sucubo_fire")
|
||||
elseif spr.timer > 100 then
|
||||
if spr.current_frame == 2 then
|
||||
spr.timer = 0
|
||||
local palo = templates.create("palo", {pos={x=spr.pos.x, y=spr.pos.y}, flipped=spr.flipped})
|
||||
table.insert(sprites.list, palo)
|
||||
end
|
||||
end
|
||||
if spr.animation_finished then
|
||||
spr.animation_finished = nil
|
||||
sprites.set_animation(spr, "sucubo_stand")
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user