diff --git a/data/gfx/gota.gif b/data/gfx/gota.gif new file mode 100644 index 0000000..1f02ed0 Binary files /dev/null and b/data/gfx/gota.gif differ diff --git a/data/gfx/sprites.gif b/data/gfx/sprites.gif index b793772..784d1e9 100644 Binary files a/data/gfx/sprites.gif and b/data/gfx/sprites.gif differ diff --git a/data/maps/rooms_background.gif b/data/maps/rooms_background.gif index 4165345..3f2282d 100644 Binary files a/data/maps/rooms_background.gif and b/data/maps/rooms_background.gif differ diff --git a/data/maps/rooms_foreground.gif b/data/maps/rooms_foreground.gif index b5893e6..dc5ea18 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 10dc6f7..fc1a2d8 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 fd5b18f..8afe30c 100644 --- a/data/modules/animations.lua +++ b/data/modules/animations.lua @@ -204,4 +204,32 @@ animations = { { frame={x=27,y=0,w=9,h=8}, wait=2 } } }, + ["gota_generador"] = { + cycle = {1,2,3,4,5,6,7,8}, + loop = false, + frames = { + { frame={x=0,y=0,w=8,h=8}, wait=2 }, + { frame={x=8,y=0,w=8,h=8}, wait=2 }, + { frame={x=16,y=0,w=8,h=8}, wait=2 }, + { frame={x=24,y=0,w=8,h=8}, wait=2 }, + { frame={x=32,y=0,w=8,h=8}, wait=2 }, + { frame={x=40,y=0,w=8,h=8}, wait=2 }, + { frame={x=48,y=0,w=8,h=8}, wait=50 }, + { frame={x=48,y=0,w=8,h=8}, wait=1 } + } + }, + ["gota"] = { + cycle = {1}, + loop = false, + frames = { + { frame={x=48,y=0,w=8,h=8}, wait=100 } + } + }, + ["esguit"] = { + cycle = {1}, + loop = false, + frames = { + { frame={x=56,y=0,w=8,h=8}, wait=100 } + } + }, } \ No newline at end of file diff --git a/data/modules/ia/gota.lua b/data/modules/ia/gota.lua new file mode 100644 index 0000000..21c2753 --- /dev/null +++ b/data/modules/ia/gota.lua @@ -0,0 +1,62 @@ + +function ia.update_gota(spr) + if spr.timer > 0 then + spr.invisible = true + spr.timer = spr.timer-1 + if spr.timer == 1 then + spr.animation_finished = nil + spr.current_frame = 1 + spr.current_wait = 1 + end + else + spr.invisible = nil; + if spr.animation_finished 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) + 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 = (spr.pos.x+4)>>3, (spr.pos.y+4)>>3 + + 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 = (spr.pos.x+4)>>3, (spr.pos.y+4)>>3 + + 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 + diff --git a/data/modules/items.lua b/data/modules/items.lua index 2c42335..80bb304 100644 --- a/data/modules/items.lua +++ b/data/modules/items.lua @@ -16,4 +16,5 @@ items = { { 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} }, + { name="gota", label="gota", visual={x=80, y=56, w=8, h=8} }, } diff --git a/data/modules/templates.lua b/data/modules/templates.lua index 32cc6fb..aa7a977 100644 --- a/data/modules/templates.lua +++ b/data/modules/templates.lua @@ -192,6 +192,56 @@ function me.create(type, options) room = options.room, ia = ia.update_rata } + elseif key == "gota" then + sprite = { + type = key, + pos = options.pos,--{ x=100, y=4*12*8+71 }, + size = { w=8,h=8 }, + bbo = { left=2, top=3, right=3, bottom=1 }, + current_frame = 1, + current_wait = 1, + flipped = options.flipped, + surf = surf.load("gfx/gota.gif"), + animation = "gota_generador", + state = me.ALIVE, + enemy = true, + timer = 0, + room = options.room, + ia = ia.update_gota + } + elseif key == "gota_caiguent" then + sprite = { + type = key, + pos = options.pos,--{ x=100, y=4*12*8+71 }, + size = { w=8,h=8 }, + bbo = { left=2, top=3, right=3, bottom=1 }, + current_frame = 1, + current_wait = 1, + flipped = options.flipped, + surf = surf.load("gfx/gota.gif"), + animation = "gota", + state = me.ALIVE, + enemy = true, + room = options.room, + ia = ia.update_gota_caiguent + } + elseif key == "gota_esguit" then + sprite = { + type = key, + pos = options.pos,--{ x=100, y=4*12*8+71 }, + dir = options.dir, + size = { w=8,h=8 }, + bbo = { left=2, top=3, right=3, bottom=1 }, + current_frame = 1, + current_wait = 1, + flipped = options.flipped, + surf = surf.load("gfx/gota.gif"), + animation = "esguit", + state = me.ALIVE, + enemy = true, + room = options.room, + ia = ia.update_gota_esguit + } else error("Template not recognized") end