diff --git a/data/gfx/ratpenat.gif b/data/gfx/ratpenat.gif new file mode 100644 index 0000000..6c88f67 Binary files /dev/null and b/data/gfx/ratpenat.gif differ diff --git a/data/gfx/sprites.gif b/data/gfx/sprites.gif index 8aa320e..d4c8145 100644 Binary files a/data/gfx/sprites.gif and b/data/gfx/sprites.gif differ diff --git a/data/maps/rooms_items.gif b/data/maps/rooms_items.gif index ae5b0e1..34c1fef 100644 Binary files a/data/maps/rooms_items.gif and b/data/maps/rooms_items.gif differ diff --git a/data/modules/animations.lua b/data/modules/animations.lua index 7302147..830a99c 100644 --- a/data/modules/animations.lua +++ b/data/modules/animations.lua @@ -249,4 +249,13 @@ animations = { { frame={x=32,y=0,w=16,h=17}, offset={normal={x=0,y=-2}, flipped={x=0,y=-2}}, wait=4 } } }, + ["ratpenat"] = { + cycle = {1,2,3,2}, + loop = true, + frames = { + { frame={x=0,y=0,w=8,h=8}, wait=4 }, + { frame={x=8,y=0,w=8,h=8}, wait=4 }, + { frame={x=16,y=0,w=8,h=8}, wait=4 } + } + }, } \ No newline at end of file diff --git a/data/modules/ia/ratpenat.lua b/data/modules/ia/ratpenat.lua new file mode 100644 index 0000000..e38aa30 --- /dev/null +++ b/data/modules/ia/ratpenat.lua @@ -0,0 +1,29 @@ + +function ia.update_ratpenat(spr) + map.surf(rooms.surf_foreground) + 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-1)>>3, (spr.pos.y)>>3 + if map.tile(tx,ty) < 16 then + spr.pos.x = spr.pos.x - 1 + else + spr.flipped = not spr.flipped + end + else + local tx, ty = (spr.pos.x+9)>>3, (spr.pos.y)>>3 + if map.tile(tx,ty) < 16 then + spr.pos.x = spr.pos.x + 1 + else + spr.flipped = not spr.flipped + end + end +end diff --git a/data/modules/items.lua b/data/modules/items.lua index c821708..512ac3c 100644 --- a/data/modules/items.lua +++ b/data/modules/items.lua @@ -20,4 +20,5 @@ items = { { 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} }, + { name="ratpenat", label="ratpenat", visual={x=16, y=64, w=8, h=8} }, } diff --git a/data/modules/templates.lua b/data/modules/templates.lua index 0e0b1e1..d64a438 100644 --- a/data/modules/templates.lua +++ b/data/modules/templates.lua @@ -295,6 +295,22 @@ function me.create(type, options) room = options.room, ia = ia.update_dimoni } + elseif key == "ratpenat" then + sprite = { + type = key, + pos = options.pos,--{ x=100, y=4*12*8+71 }, + size = { w=8,h=8 }, + bbo = { left=1, top=1, right=1, bottom=1 }, + current_frame = 1, + current_wait = 1, + flipped = options.flipped, + surf = surf.load("gfx/ratpenat.gif"), + animation = "ratpenat", + state = me.ALIVE, + enemy = true, + room = options.room, + ia = ia.update_ratpenat + } else error("Template not recognized") end