- [NEW] Alguns ajustos en habitacions
- [FIX] Càlcul del tile més robust
This commit is contained in:
1 parent
af2c8fb68d
commit
7b63f963b0
17 files changed
+38
-32
No files matched your search
@@ -15,14 +15,14 @@ function ia.update_berserk(spr)
|
||||
local advance = 1
|
||||
if sprites.hero.pos.y == spr.pos.y-1 then advance = 2 end
|
||||
if spr.flipped then
|
||||
local tx, ty = (spr.pos.x+3)>>3, (spr.pos.y+15)>>3
|
||||
local tx, ty = sprites.get_tile(spr.pos.x+3), sprites.get_tile(spr.pos.y+15)
|
||||
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 - advance
|
||||
else
|
||||
spr.flipped = not spr.flipped
|
||||
end
|
||||
else
|
||||
local tx, ty = (spr.pos.x+12)>>3, (spr.pos.y+15)>>3
|
||||
local tx, ty = sprites.get_tile(spr.pos.x+12), sprites.get_tile(spr.pos.y+15)
|
||||
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 + advance
|
||||
else
|
||||
|
||||
@@ -3,12 +3,12 @@ function ia.update_brick(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
|
||||
local tx, ty = sprites.get_tile(spr.pos.x), sprites.get_tile(spr.pos.y)
|
||||
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
|
||||
local tx, ty = sprites.get_tile(spr.pos.x+2), sprites.get_tile(spr.pos.y)
|
||||
if rooms.is_outside(tx,ty) then sprites.remove(spr) return end
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
function ia.update_bullet(spr)
|
||||
local tx, ty, ty2 = (spr.pos.x+2)>>3, (spr.pos.y+1)>>3, (spr.pos.y+2)>>3
|
||||
local tx, ty, ty2 = sprites.get_tile(spr.pos.x+2), sprites.get_tile(spr.pos.y+1), sprites.get_tile(spr.pos.y+2)
|
||||
|
||||
if rooms.is_outside(tx,ty) then sprites.remove(spr) return end
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ function ia.update_clau(spr)
|
||||
local x2,y2,w2,h2 = util.aabb(sprites.hero)
|
||||
if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then
|
||||
if sprites.hero.give_key(spr.color) then
|
||||
local tx, ty = (spr.pos.x)>>3, (spr.pos.y)>>3
|
||||
local tx, ty = sprites.get_tile(spr.pos.x), sprites.get_tile(spr.pos.y)
|
||||
map.surf(rooms.surf_items)
|
||||
map.tile(tx,ty,0)
|
||||
sprites.remove(spr)
|
||||
|
||||
@@ -4,7 +4,7 @@ function ia.update_coin(spr)
|
||||
local x1,y1,w1,h1 = util.aabb(spr)
|
||||
local x2,y2,w2,h2 = util.aabb(sprites.hero)
|
||||
if util.check_aabb_collision(x1,y1,w1,h1, x2,y2,w2,h2) then
|
||||
local tx, ty = (spr.pos.x)>>3, (spr.pos.y)>>3
|
||||
local tx, ty = sprites.get_tile(spr.pos.x), sprites.get_tile(spr.pos.y)
|
||||
map.surf(rooms.surf_items)
|
||||
map.tile(tx,ty,0)
|
||||
|
||||
|
||||
@@ -13,14 +13,14 @@ function ia.update_dimoni(spr)
|
||||
end
|
||||
|
||||
if spr.flipped then
|
||||
local tx, ty = (spr.pos.x+3)>>3, (spr.pos.y+15)>>3
|
||||
local tx, ty = sprites.get_tile(spr.pos.x+3), sprites.get_tile(spr.pos.y+15)
|
||||
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+12)>>3, (spr.pos.y+15)>>3
|
||||
local tx, ty = sprites.get_tile(spr.pos.x+12), sprites.get_tile(spr.pos.y+15)
|
||||
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
|
||||
|
||||
@@ -27,7 +27,7 @@ function gota_esguita(spr)
|
||||
end
|
||||
|
||||
function ia.update_gota_caiguent(spr)
|
||||
local tx, ty = (spr.pos.x+4)>>3, (spr.pos.y+4)>>3
|
||||
local tx, ty = sprites.get_tile(spr.pos.x+4), sprites.get_tile(spr.pos.y+4)
|
||||
|
||||
if rooms.is_outside(tx,ty) then sprites.remove(spr) return end
|
||||
|
||||
@@ -49,7 +49,7 @@ function ia.update_gota_caiguent(spr)
|
||||
end
|
||||
|
||||
function ia.update_gota_esguit(spr)
|
||||
local tx, ty = (spr.pos.x+4)>>3, (spr.pos.y+4)>>3
|
||||
local tx, ty = sprites.get_tile(spr.pos.x+4), sprites.get_tile(spr.pos.y+4)
|
||||
|
||||
if rooms.is_outside(tx,ty) then sprites.remove(spr) return end
|
||||
|
||||
|
||||
+13
-12
@@ -3,7 +3,7 @@ function ia.update_hero()
|
||||
|
||||
if sprites.hero.state == templates.DEAD then
|
||||
if sprites.hero.cooldown > 0 then
|
||||
local tx1, tx2, ty = (sprites.hero.pos.x+4)>>3, (sprites.hero.pos.x+11)>>3, (sprites.hero.pos.y+1)>>3
|
||||
local tx1, tx2, ty = sprites.get_tile(sprites.hero.pos.x+4), sprites.get_tile(sprites.hero.pos.x+11), sprites.get_tile(sprites.hero.pos.y+1)
|
||||
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
|
||||
@@ -57,7 +57,7 @@ function ia.update_hero()
|
||||
-- Si li han pegat...
|
||||
if sprites.hero.has_been_hit then
|
||||
if sprites.hero.flipped then
|
||||
local tx, ty = (sprites.hero.pos.x+12)>>3, (sprites.hero.pos.y+16)>>3
|
||||
local tx, ty = sprites.get_tile(sprites.hero.pos.x+12), sprites.get_tile(sprites.hero.pos.y+16)
|
||||
if map.tile(tx,ty) < 16 and map.tile(tx,ty-1) < 16 then
|
||||
if tx>rooms.pos.x+19 then
|
||||
game.change_room(1,0)
|
||||
@@ -66,7 +66,7 @@ function ia.update_hero()
|
||||
end
|
||||
end
|
||||
else
|
||||
local tx, ty = (sprites.hero.pos.x+3)>>3, (sprites.hero.pos.y+16)>>3
|
||||
local tx, ty = sprites.get_tile(sprites.hero.pos.x+3), sprites.get_tile(sprites.hero.pos.y+16)
|
||||
if map.tile(tx,ty) < 16 and map.tile(tx,ty-1) < 16 then
|
||||
if tx<rooms.pos.x then
|
||||
game.change_room(-1,0)
|
||||
@@ -96,7 +96,7 @@ function ia.update_hero()
|
||||
if sprites.hero.jumping > 0 then
|
||||
anim = "hero_jump"
|
||||
move_anim = "hero_jump"
|
||||
local tx1, tx2, ty = (sprites.hero.pos.x+4)>>3, (sprites.hero.pos.x+11)>>3, (sprites.hero.pos.y)>>3
|
||||
local tx1, tx2, ty = sprites.get_tile(sprites.hero.pos.x+4), sprites.get_tile(sprites.hero.pos.x+11), sprites.get_tile(sprites.hero.pos.y)
|
||||
--draw.rect(tx1<<3,ty<<3,8,8,8)
|
||||
--draw.rect(tx2<<3,ty<<3,8,8,28)
|
||||
if map.tile(tx1,ty) < 16 and map.tile(tx2,ty) < 16 then
|
||||
@@ -113,14 +113,14 @@ function ia.update_hero()
|
||||
else
|
||||
-- SI NO ESTÀ BOTANT...
|
||||
-- SI ESTÀ EN UNES ESCALERES...
|
||||
local txm, ty = (sprites.hero.pos.x+8)>>3, (sprites.hero.pos.y+8)>>3
|
||||
local txm, ty = sprites.get_tile(sprites.hero.pos.x+8), sprites.get_tile(sprites.hero.pos.y+8)
|
||||
if (map.tile(txm,ty) > 0 and map.tile(txm,ty) < 16) or (map.tile(txm,ty+1) > 0 and map.tile(txm,ty+1) < 16) then
|
||||
anim = "hero_stairs_idle"
|
||||
move_anim = "hero_stairs"
|
||||
-- SI PULSA AMUNT...
|
||||
if key.down(key.UP) or pad.down(pad.UP) then
|
||||
anim = move_anim
|
||||
local tx1, tx2, ty = (sprites.hero.pos.x+8)>>3, (sprites.hero.pos.x+11)>>3, (sprites.hero.pos.y)>>3
|
||||
local tx1, tx2, ty = sprites.get_tile(sprites.hero.pos.x+8), sprites.get_tile(sprites.hero.pos.x+11), sprites.get_tile(sprites.hero.pos.y)
|
||||
if map.tile(tx1,ty) < 16 then --or map.tile(tx2,ty) < 16 then
|
||||
if ty+1<rooms.pos.y then
|
||||
game.change_room(0,-1)
|
||||
@@ -131,7 +131,7 @@ function ia.update_hero()
|
||||
-- SI PULSA AVALL...
|
||||
elseif key.down(key.DOWN) or pad.down(pad.DOWN) then
|
||||
anim = move_anim
|
||||
local tx1, tx2, ty = (sprites.hero.pos.x+4)>>3, (sprites.hero.pos.x+11)>>3, (sprites.hero.pos.y+1)>>3
|
||||
local tx1, tx2, ty = sprites.get_tile(sprites.hero.pos.x+4), sprites.get_tile(sprites.hero.pos.x+11), sprites.get_tile(sprites.hero.pos.y+1)
|
||||
if map.tile(tx1,ty+2) < 16 or map.tile(tx2,ty+2) < 16 then
|
||||
if ty+2>rooms.pos.y+12 then
|
||||
game.change_room(0,1)
|
||||
@@ -142,12 +142,13 @@ function ia.update_hero()
|
||||
end
|
||||
else
|
||||
-- SI NO ESTÀ EN UNES ESCALERES...
|
||||
local tx1, txm, tx2, ty = (sprites.hero.pos.x+4)>>3, (sprites.hero.pos.x+8)>>3, (sprites.hero.pos.x+11)>>3, (sprites.hero.pos.y+1)>>3
|
||||
local tx1, txm, tx2, ty = sprites.get_tile(sprites.hero.pos.x+4), sprites.get_tile(sprites.hero.pos.x+8), sprites.get_tile(sprites.hero.pos.x+11), (sprites.hero.pos.y+1)/8
|
||||
-- SI ESTÀ CAIGUENT...
|
||||
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 rooms.pos.y<84 and ty+2>rooms.pos.y+12 then
|
||||
|
||||
if rooms.pos.y<84 and sprites.hero.pos.y>=0 and ty+2>rooms.pos.y+12 then
|
||||
game.change_room(0,1)
|
||||
else
|
||||
if sprites.hero.pos.y >= 808 then
|
||||
@@ -177,7 +178,7 @@ function ia.update_hero()
|
||||
if (map.tile(txm,ty+2) < 16 and map.tile(txm,ty+2) > 0) then
|
||||
if key.down(key.DOWN) or pad.down(pad.DOWN) then
|
||||
anim = "hero_stairs"
|
||||
--local tx1, tx2, ty = (sprites.hero.pos.x+4)>>3, (sprites.hero.pos.x+11)>>3, (sprites.hero.pos.y+1)>>3
|
||||
--local tx1, tx2, ty = sprites.get_tile(sprites.hero.pos.x+4), sprites.get_tile(sprites.hero.pos.x+11), sprites.get_tile(sprites.hero.pos.y+1)
|
||||
--if map.tile(tx1,ty+2) < 16 or map.tile(tx2,ty+2) < 16 then
|
||||
sprites.hero.pos.x = (txm << 3)-4
|
||||
sprites.hero.pos.y = sprites.hero.pos.y + 1
|
||||
@@ -204,7 +205,7 @@ function ia.update_hero()
|
||||
if key.down(key.LEFT) or pad.down(pad.LEFT) then
|
||||
sprites.hero.flipped = true
|
||||
anim = move_anim
|
||||
local tx, ty = (sprites.hero.pos.x+3)>>3, (sprites.hero.pos.y+16)>>3
|
||||
local tx, ty = sprites.get_tile(sprites.hero.pos.x+3), sprites.get_tile(sprites.hero.pos.y+16)
|
||||
if map.tile(tx,ty) < 16 and map.tile(tx,ty-1) < 16 then
|
||||
if tx<rooms.pos.x then
|
||||
game.change_room(-1,0)
|
||||
@@ -215,7 +216,7 @@ function ia.update_hero()
|
||||
elseif key.down(key.RIGHT) or pad.down(pad.RIGHT) then
|
||||
sprites.hero.flipped = false
|
||||
anim = move_anim
|
||||
local tx, ty = (sprites.hero.pos.x+12)>>3, (sprites.hero.pos.y+16)>>3
|
||||
local tx, ty = sprites.get_tile(sprites.hero.pos.x+12), sprites.get_tile(sprites.hero.pos.y+16)
|
||||
if map.tile(tx,ty) < 16 and map.tile(tx,ty-1) < 16 then
|
||||
if tx>rooms.pos.x+19 then
|
||||
game.change_room(1,0)
|
||||
|
||||
@@ -13,14 +13,14 @@ function ia.update_mummy(spr)
|
||||
end
|
||||
|
||||
if spr.flipped then
|
||||
local tx, ty = (spr.pos.x+3)>>3, (spr.pos.y+15)>>3
|
||||
local tx, ty = sprites.get_tile(spr.pos.x+3), sprites.get_tile(spr.pos.y+15)
|
||||
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+12)>>3, (spr.pos.y+15)>>3
|
||||
local tx, ty = sprites.get_tile(spr.pos.x+12), sprites.get_tile(spr.pos.y+15)
|
||||
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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
function ia.update_palo(spr)
|
||||
local tx, ty, ty2 = (spr.pos.x+2)>>3, (spr.pos.y+1)>>3, (spr.pos.y+2)>>3
|
||||
local tx, ty, ty2 = sprites.get_tile(spr.pos.x+2), sprites.get_tile(spr.pos.y+1), sprites.get_tile(spr.pos.y+2)
|
||||
|
||||
if rooms.is_outside(tx,ty) then sprites.remove(spr) return end
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ function ia.update_porta(spr)
|
||||
end
|
||||
elseif spr.state == templates.DYING then
|
||||
if spr.current_frame == 15 then
|
||||
local tx, ty = (spr.pos.x)>>3, (spr.pos.y)>>3
|
||||
local tx, ty = sprites.get_tile(spr.pos.x), sprites.get_tile(spr.pos.y)
|
||||
map.surf(rooms.surf_items)
|
||||
map.tile(tx,ty,0)
|
||||
map.surf(rooms.surf_foreground)
|
||||
|
||||
@@ -12,14 +12,14 @@ function ia.update_rata(spr)
|
||||
end
|
||||
|
||||
if spr.flipped then
|
||||
local tx, ty = (spr.pos.x-1)>>3, (spr.pos.y+7)>>3
|
||||
local tx, ty = sprites.get_tile(spr.pos.x-1), sprites.get_tile(spr.pos.y+7)
|
||||
if map.tile(tx,ty) < 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
|
||||
local tx, ty = sprites.get_tile(spr.pos.x+9), sprites.get_tile(spr.pos.y+7)
|
||||
if map.tile(tx,ty) < 16 and map.tile(tx,ty+1) > 0 then
|
||||
spr.pos.x = spr.pos.x + 1
|
||||
else
|
||||
|
||||
@@ -12,14 +12,14 @@ function ia.update_ratpenat(spr)
|
||||
end
|
||||
|
||||
if spr.flipped then
|
||||
local tx, ty = (spr.pos.x-1)>>3, (spr.pos.y)>>3
|
||||
local tx, ty = sprites.get_tile(spr.pos.x-1), sprites.get_tile(spr.pos.y)
|
||||
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
|
||||
local tx, ty = sprites.get_tile(spr.pos.x+9), sprites.get_tile(spr.pos.y)
|
||||
if map.tile(tx,ty) < 16 then
|
||||
spr.pos.x = spr.pos.x + 1
|
||||
else
|
||||
|
||||
Reference in new issue
Block a user