I'm printing out the camera coordinates like you suggested, and they seem to change with the s key. But nothing on the screen moves. I feel like I'm missing some basic thing.
Here's the code, and I'll attach a .love which illustrates the issue
Code: Select all
function love.load()
Camera = require "lib.camera"
viewx = 100; viewy = 100
cam = Camera(viewx, viewy, 0)
debug = false
width = 1024; height = 512
love.window.setMode(1024, 512, {vsync=false})
end
function love.keypressed(key)
if key == "escape" then
love.event.push("quit")
elseif key == "w" then
viewy = viewy-1
elseif key == "a" then
viewx = viewx-1
elseif key == "s" then
viewy = viewy+1
elseif key == "d" then
viewx = viewx+1
end
end
function love.update(dt)
local dx, dy = viewx - cam.x, viewy - cam.y
cam:move(dx/2, dy/2)
ex, why = cam:pos()
campos = "camera x: " .. ex .. "\ncamera y: " .. why
end
function love.draw()
love.graphics.setBackgroundColor(50, 100, 50)
love.graphics.rectangle("fill",50,50,50,50)
love.graphics.print("press a,s,d,f\nnothing moves", 110, 50)
love.graphics.print(campos, 250, 220)
end