diff --git a/data/gfx/dimoni.gif b/data/gfx/dimoni.gif new file mode 100644 index 0000000..b43407a Binary files /dev/null and b/data/gfx/dimoni.gif differ diff --git a/data/gfx/sprites.gif b/data/gfx/sprites.gif index 3f7d174..8aa320e 100644 Binary files a/data/gfx/sprites.gif and b/data/gfx/sprites.gif differ diff --git a/data/maps/rooms_foreground.gif b/data/maps/rooms_foreground.gif index 66ed4b0..cfe11e6 100644 Binary files a/data/maps/rooms_foreground.gif and b/data/maps/rooms_foreground.gif differ diff --git a/data/modules/animations.lua b/data/modules/animations.lua index cfccc67..7302147 100644 --- a/data/modules/animations.lua +++ b/data/modules/animations.lua @@ -240,4 +240,13 @@ animations = { { frame={x=32,y=0,w=16,h=18}, offset={flipped={x=0,y=-2}}, wait=2 } } }, + ["dimoni_walk"] = { + cycle = {1,2,1,3}, + loop = true, + frames = { + { frame={x=0,y=0,w=16,h=17}, offset={normal={x=0,y=-2}, flipped={x=0,y=-2}}, wait=4 }, + { frame={x=16,y=0,w=16,h=17}, offset={normal={x=0,y=-2}, flipped={x=0,y=-2}}, wait=4 }, + { frame={x=32,y=0,w=16,h=17}, offset={normal={x=0,y=-2}, flipped={x=0,y=-2}}, wait=4 } + } + }, } \ No newline at end of file diff --git a/data/modules/ia/bullet.lua b/data/modules/ia/bullet.lua index 24aef4d..0ec7e18 100644 --- a/data/modules/ia/bullet.lua +++ b/data/modules/ia/bullet.lua @@ -9,7 +9,13 @@ function ia.update_bullet(spr) if v.enemy and v.state ~= templates.DEAD then local x2,y2,w2,h2 = util.aabb(v) if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then - if v.state == templates.ALIVE then v.state = templates.DYING end + if v.state == templates.ALIVE then + if v.bulletproof then + gota_esguita(spr) + else + v.state = templates.DYING + end + end sprites.remove(spr) return end diff --git a/data/modules/ia/dimoni.lua b/data/modules/ia/dimoni.lua new file mode 100644 index 0000000..8c802af --- /dev/null +++ b/data/modules/ia/dimoni.lua @@ -0,0 +1,31 @@ + +function ia.update_dimoni(spr) + map.surf(rooms.surf_foreground) + if spr.state == templates.ALIVE then + 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() + spr.flipped = not spr.flipped + end + end + + if spr.flipped then + local tx, ty = (spr.pos.x+3)>>3, (spr.pos.y+15)>>3 + if map.tile(tx,ty) < 16 and map.tile(tx,ty-1) < 16 and map.tile(tx,ty+1) > 0 then + spr.pos.x = spr.pos.x - 1 + else + spr.flipped = not spr.flipped + end + else + local tx, ty = (spr.pos.x+12)>>3, (spr.pos.y+15)>>3 + if map.tile(tx,ty) < 16 and map.tile(tx,ty-1) < 16 and map.tile(tx,ty+1) > 0 then + spr.pos.x = spr.pos.x + 1 + else + spr.flipped = not spr.flipped + end + end + end +end diff --git a/data/modules/items.lua b/data/modules/items.lua index 8d21fe9..c821708 100644 --- a/data/modules/items.lua +++ b/data/modules/items.lua @@ -19,4 +19,5 @@ items = { { name="gota", label="gota", visual={x=80, y=56, w=8, h=8} }, { name="berserk", label="berserk", visual={x=16, y=24, w=16, h=16} }, { name="abad", label="abad", visual={x=16, y=0, w=16, h=16} }, + { name="dimoni", label="dimoni", visual={x=32, y=0, w=16, h=17} }, } diff --git a/data/modules/templates.lua b/data/modules/templates.lua index f593e18..0e0b1e1 100644 --- a/data/modules/templates.lua +++ b/data/modules/templates.lua @@ -278,6 +278,23 @@ function me.create(type, options) room = options.room, ia = ia.update_coin } + elseif key == "dimoni" then + sprite = { + type = key, + pos = options.pos,--{ x=100, y=4*12*8+71 }, + size = { w=16,h=17 }, + bbo = { left=3, top=2, right=3, bottom=0 }, + current_frame = 1, + current_wait = 1, + flipped = options.flipped, + surf = surf.load("gfx/dimoni.gif"), + animation = "dimoni_walk", + state = me.ALIVE, + enemy = true, + bulletproof = true, + room = options.room, + ia = ia.update_dimoni + } else error("Template not recognized") end