mirror of
https://github.com/libretro/lutro-platformer.git
synced 2024-11-23 16:19:46 +00:00
Compute camera position after resolving collisions
This commit is contained in:
parent
4e6759c030
commit
e6b791857e
10
main.lua
10
main.lua
@ -51,7 +51,17 @@ function lutro.update(dt)
|
||||
entities[i]:update(dt)
|
||||
end
|
||||
end
|
||||
|
||||
detect_collisions()
|
||||
|
||||
-- camera
|
||||
camera_x = - ninja.x + SCREEN_WIDTH/2 - ninja.width/2;
|
||||
if camera_x > 0 then
|
||||
camera_x = 0
|
||||
end
|
||||
if camera_x < -(map.width * map.tilewidth) + SCREEN_WIDTH then
|
||||
camera_x = -(map.width * map.tilewidth) + SCREEN_WIDTH
|
||||
end
|
||||
end
|
||||
|
||||
function lutro.draw()
|
||||
|
@ -169,15 +169,6 @@ function ninja:update(dt)
|
||||
self.anim = anim;
|
||||
|
||||
self.anim:update(dt)
|
||||
|
||||
-- camera
|
||||
camera_x = - self.x + SCREEN_WIDTH/2 - self.width/2;
|
||||
if camera_x > 0 then
|
||||
camera_x = 0
|
||||
end
|
||||
if camera_x < -(map.width * map.tilewidth) + SCREEN_WIDTH then
|
||||
camera_x = -(map.width * map.tilewidth) + SCREEN_WIDTH
|
||||
end
|
||||
end
|
||||
|
||||
function ninja:draw()
|
||||
|
Loading…
Reference in New Issue
Block a user