Add parallaxe effect

This commit is contained in:
Jean-André Santoni 2015-02-17 20:56:16 +01:00
parent 4774362047
commit 3729630b3e
2 changed files with 10 additions and 0 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

View File

@ -15,6 +15,8 @@ local add_entity_from_map = function(object)
end
function lutro.load()
bg1 = lutro.graphics.newImage(lutro.path .. "assets/forestbackground.png")
bg2 = lutro.graphics.newImage(lutro.path .. "assets/foresttrees.png")
map = tiled_load(lutro.path .. "assets/pagode.json")
tiled_load_objects(map, add_entity_from_map)
table.insert(entities, newNinja())
@ -31,6 +33,14 @@ end
function lutro.draw()
lutro.graphics.clear(0xff000000)
for i=0, 1 do
lutro.graphics.draw(bg1.data,
i*bg1.width + lutro.camera_x/6, 0, bg1.width, bg1.height)
lutro.graphics.draw(bg2.data,
i*bg2.width + lutro.camera_x/3, 0, bg2.width, bg2.height)
end
tiled_draw_layer(map.layers[1])
for i=1, #entities do
if entities[i].draw then