diff --git a/data/gfx/morcus.gif b/data/gfx/morcus.gif index 16ba539..afb6b7d 100644 Binary files a/data/gfx/morcus.gif and b/data/gfx/morcus.gif differ diff --git a/data/modules/animations.lua b/data/modules/animations.lua index 026c6d6..14c019f 100644 --- a/data/modules/animations.lua +++ b/data/modules/animations.lua @@ -265,4 +265,15 @@ animations = { { frame={x=16,y=0,w=8,h=8}, wait=4 } } }, + ["polseta"] = { + cycle = {1,2,3,4,5}, + loop = false, + frames = { + { frame={x=112,y=9,w=4,h=4}, wait=3 }, + { frame={x=112,y=13,w=4,h=4}, wait=3 }, + { frame={x=116,y=9,w=4,h=4}, wait=3 }, + { frame={x=116,y=13,w=4,h=4}, wait=3 }, + { frame={x=116,y=13,w=4,h=4}, wait=1 } + } + }, } \ No newline at end of file diff --git a/data/modules/ia/gota.lua b/data/modules/ia/gota.lua index b2266e3..f7d7f1f 100644 --- a/data/modules/ia/gota.lua +++ b/data/modules/ia/gota.lua @@ -58,3 +58,10 @@ function ia.update_gota_esguit(spr) spr.pos.x = spr.pos.x + spr.dir.x end +function ia.update_polseta(spr) + if spr.current_frame==5 then sprites.remove(spr) return end + + spr.dir.y = spr.dir.y + 0.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/ia/hero.lua b/data/modules/ia/hero.lua index b5c6c65..8eee8a4 100644 --- a/data/modules/ia/hero.lua +++ b/data/modules/ia/hero.lua @@ -109,7 +109,7 @@ function ia.update_hero() sprites.hero.jumping = 0 sprites.hero.jump_throttle = 10 end - sprites.hero.jumping = sprites.hero.jumping - 1 + sprites.hero.jumping = sprites.hero.jumping - 1 --0.47 else -- SI NO ESTÀ BOTANT... -- SI ESTÀ EN UNES ESCALERES... @@ -161,16 +161,16 @@ function ia.update_hero() -- SI NO ESTÀ CAIGUENT... if tile_under_me1==84 then map.tile(tx1,ty+2,68) - local broken_tile = templates.create("brick", {pos={x=tx1<<3, y=(ty+2)<<3}, flipped=sprites.hero.flipped}) + local broken_tile = templates.create("brick", {pos={x=sprites.tile_to_pixel(tx1), y=sprites.tile_to_pixel(ty+2)}, flipped=sprites.hero.flipped}) table.insert(sprites.list, broken_tile) end if tile_under_me2==84 then map.tile(tx2,ty+2,68) - local broken_tile = templates.create("brick", {pos={x=tx2<<3, y=(ty+2)<<3}, flipped=sprites.hero.flipped}) + local broken_tile = templates.create("brick", {pos={x=sprites.tile_to_pixel(tx2), y=sprites.tile_to_pixel(ty+2)}, flipped=sprites.hero.flipped}) table.insert(sprites.list, broken_tile) end if tile_under_me1>=16 or tile_under_me1>=16 then - sprites.hero.pos.y = (ty<<3)-1 + sprites.hero.pos.y = sprites.tile_to_pixel(ty)-1 end anim = "hero_stand" if sprites.hero.state == templates.ALIVE then sprites.save_safe_pos() end @@ -188,6 +188,10 @@ function ia.update_hero() -- SI POLSA BOTAR... if ( key.down(key.X) or pad.down(pad.A) ) and sprites.hero.jump_throttle == 0 then sprites.hero.jumping = 17 + table.insert(sprites.list, templates.create("polseta", {pos={x=sprites.hero.pos.x+6, y=sprites.hero.pos.y+16}, dir={x=-0.7,y=-0.3}, flipped=sprites.hero.flipped})) + table.insert(sprites.list, templates.create("polseta", {pos={x=sprites.hero.pos.x+8, y=sprites.hero.pos.y+15}, dir={x=-0.5,y=-0.1}, flipped=sprites.hero.flipped})) + table.insert(sprites.list, templates.create("polseta", {pos={x=sprites.hero.pos.x+10, y=sprites.hero.pos.y+16}, dir={x=0.7,y=-0.3}, flipped=sprites.hero.flipped})) + table.insert(sprites.list, templates.create("polseta", {pos={x=sprites.hero.pos.x+12, y=sprites.hero.pos.y+15}, dir={x=0.5,y=-0.1}, flipped=sprites.hero.flipped})) -- SI POLSA DISPAR... elseif (sprites.hero.gun_cooldown==0) and (key.down(key.Z) or pad.down(pad.B)) then diff --git a/data/modules/sprites.lua b/data/modules/sprites.lua index 00f1af1..0f62007 100644 --- a/data/modules/sprites.lua +++ b/data/modules/sprites.lua @@ -14,6 +14,11 @@ function sprites.get_tile(num) return math.floor(num/8); end +function sprites.tile_to_pixel(num) + return math.floor(num)*8; +end + + function sprites.remove(sprite) for i,v in ipairs(sprites.list) do if v == sprite then diff --git a/data/modules/templates.lua b/data/modules/templates.lua index 172e790..3eb7f77 100644 --- a/data/modules/templates.lua +++ b/data/modules/templates.lua @@ -328,6 +328,23 @@ function me.create(type, options) room = options.room, ia = ia.update_ratpenat } + elseif key == "polseta" then + sprite = { + type = key, + pos = options.pos,--{ x=100, y=4*12*8+71 }, + dir = options.dir, + size = { w=4,h=4 }, + bbo = { left=0, top=0, right=0, bottom=0 }, + current_frame = 1, + current_wait = 1, + flipped = options.flipped, + surf = surf.load("gfx/morcus.gif"), + animation = "polseta", + state = me.ALIVE, + enemy = true, + room = options.room, + ia = ia.update_polseta + } else error("Template not recognized") end