- [NEW] Ja camina, bota, cau, puja i baixa escales i cordes
@@ -6,6 +6,12 @@ animations = {
|
|||||||
{ frame={x=0,y=0,w=16,h=17}, wait=2 },
|
{ frame={x=0,y=0,w=16,h=17}, wait=2 },
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
["hero_jump"] = {
|
||||||
|
cycle = {1},
|
||||||
|
frames = {
|
||||||
|
{ frame={x=32,y=0,w=16,h=17}, wait=2 },
|
||||||
|
}
|
||||||
|
},
|
||||||
["hero_walk"] = {
|
["hero_walk"] = {
|
||||||
cycle = {1,2,1,3},
|
cycle = {1,2,1,3},
|
||||||
frames = {
|
frames = {
|
||||||
@@ -13,5 +19,18 @@ animations = {
|
|||||||
{ frame={x=16,y=0,w=16,h=17}, wait=2 },
|
{ frame={x=16,y=0,w=16,h=17}, wait=2 },
|
||||||
{ frame={x=32,y=0,w=16,h=17}, wait=2 }
|
{ frame={x=32,y=0,w=16,h=17}, wait=2 }
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
["hero_stairs_idle"] = {
|
||||||
|
cycle = {1},
|
||||||
|
frames = {
|
||||||
|
{ frame={x=48,y=0,w=16,h=17}, wait=2 }
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
["hero_stairs"] = {
|
||||||
|
cycle = {1,2},
|
||||||
|
frames = {
|
||||||
|
{ frame={x=48,y=0,w=16,h=17}, wait=2 },
|
||||||
|
{ frame={x=48,y=0,w=16,h=17}, wait=2, reversed=true }
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@ game = {
|
|||||||
enable = function()
|
enable = function()
|
||||||
app.update = game.update
|
app.update = game.update
|
||||||
sys.beat(2)
|
sys.beat(2)
|
||||||
shader.enable();
|
--shader.enable();
|
||||||
end,
|
end,
|
||||||
|
|
||||||
update = function()
|
update = function()
|
||||||
|
|||||||
@@ -35,10 +35,11 @@ rooms = {
|
|||||||
draw.surf(0,0,160,96,0,0)
|
draw.surf(0,0,160,96,0,0)
|
||||||
|
|
||||||
sprites.init()
|
sprites.init()
|
||||||
|
|
||||||
--map.surf(rooms.surf_background)
|
--map.surf(rooms.surf_background)
|
||||||
--for y=0,12*8 do
|
--for y=0,12*8 do
|
||||||
-- for x=0,20*8 do
|
-- for x=0,20*8 do
|
||||||
-- map.tile(x,y,1)
|
-- map.tile(x,y,38)
|
||||||
-- end
|
-- end
|
||||||
--end
|
--end
|
||||||
--map.surf(rooms.surf_foreground)
|
--map.surf(rooms.surf_foreground)
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 227 B After Width: | Height: | Size: 227 B |
|
Before Width: | Height: | Size: 274 B After Width: | Height: | Size: 300 B |
BIN
data/sprites.gif
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
@@ -10,7 +10,9 @@ sprites = {
|
|||||||
size= { w=16, h=17 },
|
size= { w=16, h=17 },
|
||||||
bbo = { left=0, top=0, right=0, bottom=0 },
|
bbo = { left=0, top=0, right=0, bottom=0 },
|
||||||
flipped = false,
|
flipped = false,
|
||||||
|
jumping = 0,
|
||||||
animation = "hero_stand",
|
animation = "hero_stand",
|
||||||
|
stairs = false,
|
||||||
current_frame = 1,
|
current_frame = 1,
|
||||||
current_wait = 1
|
current_wait = 1
|
||||||
}
|
}
|
||||||
@@ -24,20 +26,87 @@ sprites = {
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
check_sprite_collision = function()
|
||||||
|
return false
|
||||||
|
end,
|
||||||
|
|
||||||
|
check_tile_collision = function()
|
||||||
|
|
||||||
|
end,
|
||||||
|
|
||||||
update = function()
|
update = function()
|
||||||
sprites.update_sprite(sprites.hero)
|
sprites.update_sprite(sprites.hero)
|
||||||
|
|
||||||
|
-- Update hero
|
||||||
|
local anim = "hero_stand"
|
||||||
|
local move_anim = "hero_walk"
|
||||||
|
if sprites.hero.jumping > 0 then
|
||||||
|
anim = "hero_jump"
|
||||||
|
local tx1, tx2, ty = (sprites.hero.pos.x+4)>>3, (sprites.hero.pos.x+11)>>3, (sprites.hero.pos.y)>>3
|
||||||
|
if map.tile(tx1,ty) == 0 and map.tile(tx2,ty) == 0 then
|
||||||
|
sprites.hero.pos.y = sprites.hero.pos.y - 2
|
||||||
|
end
|
||||||
|
sprites.hero.jumping = sprites.hero.jumping - 2
|
||||||
|
else
|
||||||
|
local txm, ty = (sprites.hero.pos.x+8)>>3, (sprites.hero.pos.y+8)>>3
|
||||||
|
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"
|
||||||
|
if key.down(key.UP) then
|
||||||
|
anim = move_anim
|
||||||
|
local tx1, tx2, ty = (sprites.hero.pos.x+4)>>3, (sprites.hero.pos.x+11)>>3, (sprites.hero.pos.y)>>3
|
||||||
|
if map.tile(tx1,ty) < 16 or map.tile(tx2,ty) < 16 then
|
||||||
|
sprites.hero.pos.y = sprites.hero.pos.y - 1
|
||||||
|
end
|
||||||
|
elseif key.down(key.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
|
||||||
|
if map.tile(tx1,ty+2) < 16 or map.tile(tx2,ty+2) < 16 then
|
||||||
|
sprites.hero.pos.y = sprites.hero.pos.y + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
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
|
||||||
|
draw.rect(tx1<<3, (ty+2)<<3,8,8,8)
|
||||||
|
draw.rect(tx2<<3, (ty+2)<<3,8,8,28)
|
||||||
|
if map.tile(tx1,ty+2) == 0 and map.tile(tx2,ty+2) == 0 then
|
||||||
|
sprites.hero.pos.y = sprites.hero.pos.y + 2
|
||||||
|
else
|
||||||
|
sprites.hero.pos.y = (ty<<3)-1
|
||||||
|
anim = "hero_stand"
|
||||||
|
if (map.tile(txm,ty+2) < 16 and map.tile(txm,ty+2) > 0) then
|
||||||
|
if key.down(key.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
|
||||||
|
--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
|
||||||
|
--end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if key.down(key.SPACE) then
|
||||||
|
sprites.hero.jumping = 16
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
if key.down(key.LEFT) then
|
if key.down(key.LEFT) then
|
||||||
sprites.hero.flipped = true
|
sprites.hero.flipped = true
|
||||||
sprites.set_animation(sprites.hero, "hero_walk")
|
anim = move_anim
|
||||||
|
local tx, ty = (sprites.hero.pos.x+3)>>3, (sprites.hero.pos.y+16)>>3
|
||||||
|
if map.tile(tx,ty) < 16 and map.tile(tx,ty-1) < 16 then
|
||||||
sprites.hero.pos.x = sprites.hero.pos.x - 1
|
sprites.hero.pos.x = sprites.hero.pos.x - 1
|
||||||
|
end
|
||||||
elseif key.down(key.RIGHT) then
|
elseif key.down(key.RIGHT) then
|
||||||
sprites.hero.flipped = false
|
sprites.hero.flipped = false
|
||||||
sprites.set_animation(sprites.hero, "hero_walk")
|
anim = move_anim
|
||||||
|
local tx, ty = (sprites.hero.pos.x+13)>>3, (sprites.hero.pos.y+16)>>3
|
||||||
|
if map.tile(tx,ty) < 16 and map.tile(tx,ty-1) < 16 then
|
||||||
sprites.hero.pos.x = sprites.hero.pos.x + 1
|
sprites.hero.pos.x = sprites.hero.pos.x + 1
|
||||||
else
|
|
||||||
sprites.set_animation(sprites.hero, "hero_stand")
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
sprites.set_animation(sprites.hero, anim)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
update_sprite = function(sprite)
|
update_sprite = function(sprite)
|
||||||
@@ -64,6 +133,7 @@ sprites = {
|
|||||||
draw_sprite = function(sprite)
|
draw_sprite = function(sprite)
|
||||||
local cycle = animations[sprite.animation].cycle[sprite.current_frame]
|
local cycle = animations[sprite.animation].cycle[sprite.current_frame]
|
||||||
local frame = animations[sprite.animation].frames[cycle]
|
local frame = animations[sprite.animation].frames[cycle]
|
||||||
draw.surf(frame.frame.x, frame.frame.y, frame.frame.w, frame.frame.h, sprite.pos.x, sprite.pos.y, sprite.size.w, sprite.size.h, sprite.flipped)
|
local reversed = frame.reversed or false
|
||||||
|
draw.surf(frame.frame.x, frame.frame.y, frame.frame.w, frame.frame.h, sprite.pos.x, sprite.pos.y, sprite.size.w, sprite.size.h, (not reversed) ~= (not sprite.flipped))
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
BIN
data/tiles.gif
|
Before Width: | Height: | Size: 952 B After Width: | Height: | Size: 960 B |