diff --git a/data/animations.lua b/data/animations.lua index 64e2c46..519ef14 100644 --- a/data/animations.lua +++ b/data/animations.lua @@ -100,4 +100,10 @@ animations = { { frame={x=32,y=0,w=13,h=7}, wait=100 }, } }, + ["brick"] = { + cycle = {1}, + frames = { + { frame={x=48,y=0,w=8,h=8}, wait=100 }, + } + }, } \ No newline at end of file diff --git a/data/misc.gif b/data/misc.gif index fae2c66..c5ed9cf 100644 Binary files a/data/misc.gif and b/data/misc.gif differ diff --git a/data/sprites.lua b/data/sprites.lua index 012bf75..d6905e1 100644 --- a/data/sprites.lua +++ b/data/sprites.lua @@ -221,6 +221,20 @@ sprites = { end end, + update_brick = function(spr) + if spr.timeout > 0 then + spr.timeout = spr.timeout - 1 + if spr.timeout == 0 then + local tx, ty = spr.pos.x>>3, spr.pos.y>>3 + map.tile(tx,ty,0) + end + else + spr.pos.y = spr.pos.y + 2 + local tx, ty = (spr.pos.x+2)>>3, (spr.pos.y)>>3 + if rooms.is_outside(tx,ty) then sprites.remove(spr) return end + end + end, + update_hero = function() --game.draw_light(sprites.hero.pos.x, sprites.hero.pos.y,100) @@ -228,11 +242,14 @@ sprites = { local anim = "hero_stand" local move_anim = "hero_walk" + -- Si estem en cooldown desde l'ultim dispar, decrementem el contador if sprites.hero.cooldown > 0 then sprites.hero.cooldown = sprites.hero.cooldown - 1 end + -- si està en l'animació de disparar, no podem fer res i eixim ja if sprites.hero.shooting then + -- A no ser que siga l'ultim frame, en tal cas tornem a estar de peu i au if sprites.hero.current_frame==3 then sprites.hero.shooting = false if sprites.hero.flipped then sprites.hero.pos.x=sprites.hero.pos.x+8 end @@ -241,6 +258,7 @@ sprites = { return end end + -- SI ESTÀ BOTANT... if sprites.hero.jumping > 0 then anim = "hero_jump" @@ -294,7 +312,9 @@ sprites = { --draw.rect(tx1<<3, (ty+2)<<3,8,8,8) --draw.rect(tx2<<3, (ty+2)<<3,8,8,28) -- SI ESTÀ CAIGUENT... - if map.tile(tx1,ty+2) == 0 and map.tile(tx2,ty+2) == 0 then + local tile_under_me1 = map.tile(tx1,ty+2) + local tile_under_me2 = map.tile(tx2,ty+2) + if tile_under_me1 == 0 and tile_under_me2 == 0 then if ty+2>rooms.pos.y+11 then game.change_room(0,1) else @@ -302,6 +322,16 @@ sprites = { end else -- 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}) + 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}) + table.insert(sprites.list, broken_tile) + end sprites.hero.pos.y = (ty<<3)-1 anim = "hero_stand" -- SI ESTÀ SOBRE UNES ESCALERES I POLSA AVALL... diff --git a/data/templates.lua b/data/templates.lua index 7d3ef44..ecada9b 100644 --- a/data/templates.lua +++ b/data/templates.lua @@ -52,6 +52,21 @@ templates = { light_oy = 4, ia = sprites.update_coin } + elseif type == "brick" then + sprite = { + type = type, + pos = options.pos,--{ x=100, y=4*12*8+71 }, + size = { w=8,h=8 }, + bbo = { left=0, top=0, right=0, bottom=0 }, + current_frame = 1, + current_wait = 1, + flipped = options.flipped, + surf = surf.load("misc.gif"), + animation = "brick", + state = templates.ALIVE, + timeout = 10, + ia = sprites.update_brick + } else error("Template not recognized") end