diff --git a/data/gfx/rata.gif b/data/gfx/rata.gif new file mode 100644 index 0000000..94c46d0 Binary files /dev/null and b/data/gfx/rata.gif differ diff --git a/data/gfx/sprites.gif b/data/gfx/sprites.gif index 61de319..b793772 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 15740ed..b5893e6 100644 Binary files a/data/maps/rooms_foreground.gif and b/data/maps/rooms_foreground.gif differ diff --git a/data/maps/rooms_items.gif b/data/maps/rooms_items.gif index 4149f4a..10dc6f7 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 5f81ee7..fd5b18f 100644 --- a/data/modules/animations.lua +++ b/data/modules/animations.lua @@ -194,4 +194,14 @@ animations = { { frame={x=0,y=0,w=16,h=16}, wait=100 } } }, + ["rata"] = { + cycle = {1,2,3,4,2}, + loop = true, + frames = { + { frame={x=0,y=0,w=9,h=8}, wait=2 }, + { frame={x=9,y=0,w=9,h=8}, wait=2 }, + { frame={x=18,y=0,w=9,h=8}, wait=2 }, + { frame={x=27,y=0,w=9,h=8}, wait=2 } + } + }, } \ No newline at end of file diff --git a/data/modules/ia/rata.lua b/data/modules/ia/rata.lua new file mode 100644 index 0000000..f4ff14d --- /dev/null +++ b/data/modules/ia/rata.lua @@ -0,0 +1,28 @@ + +function ia.update_rata(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() + end + end + + if spr.flipped then + local tx, ty = (spr.pos.x-1)>>3, (spr.pos.y+7)>>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+9)>>3, (spr.pos.y+7)>>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 diff --git a/data/modules/items.lua b/data/modules/items.lua index 4be19a1..2c42335 100644 --- a/data/modules/items.lua +++ b/data/modules/items.lua @@ -15,4 +15,5 @@ items = { { name="sucubo 50", label="sucubo50", visual={x=0, y=64, w=16, h=16} }, { 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} }, } diff --git a/data/modules/templates.lua b/data/modules/templates.lua index 9aebf06..32cc6fb 100644 --- a/data/modules/templates.lua +++ b/data/modules/templates.lua @@ -176,6 +176,22 @@ function me.create(type, options) room = options.room, ia = ia.update_nemesio } + elseif key == "rata" then + sprite = { + type = key, + pos = options.pos,--{ x=100, y=4*12*8+71 }, + size = { w=9,h=8 }, + bbo = { left=0, top=5, right=0, bottom=0 }, + current_frame = 1, + current_wait = 1, + flipped = options.flipped, + surf = surf.load("gfx/rata.gif"), + animation = "rata", + state = me.ALIVE, + enemy = true, + room = options.room, + ia = ia.update_rata + } else error("Template not recognized") end