Commit 64f47124 authored by Delisa Mason's avatar Delisa Mason

feat: Add lerp & lead to camera mechanics

Swaps hump.camera for stalker-x
parent a27845e2
local Camera = require 'lib.camera'
return function ()
local system = {}
local camera = Camera()
camera:setFollowStyle('TOPDOWN')
function system.update(levelstate, dt)
levelstate.map:update(dt)
camera:update(dt)
camera:follow(levelstate.player.x, levelstate.player.y)
end
-- Renders map centering on player. Avoids going over the map edges.
......@@ -11,8 +17,8 @@ return function ()
local windowHeight = love.graphics.getHeight()
local mapMaxWidth = levelstate.map.width * levelstate.map.tilewidth
local mapMaxHeight = levelstate.map.height * levelstate.map.tileheight
local x = math.min(math.max(0, levelstate.player.x - windowWidth/2), mapMaxWidth - windowWidth)
local y = math.min(math.max(0, levelstate.player.y - windowHeight/2), mapMaxHeight - windowHeight)
local x = math.min(math.max(0, camera.x - windowWidth/2), mapMaxWidth - windowWidth)
local y = math.min(math.max(0, camera.y - windowHeight/2), mapMaxHeight - windowHeight)
levelstate.map:draw(-x, -y, 1, 1)
end
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment