Hi. I have a problem with code that I'm working on nowadays. Please check my .love file:
- cam.love
- (178.05 KiB) Downloaded 124 times
It's advanced hamster ball, player can move character with left/up/right/down key, but player can also move camera with w/a/s/d and zoom in/out camera with q, e key. It works well but this is where the problem begins.
- 1.png (823.41 KiB) Viewed 5445 times
When I zoom in/zoom out, currently camera is fixed at top left corner. But I'd like to change it - if I zoom in / zoom out, I'd like to fix camera at central place of the screen. So I might change position of camera when I zoom in/zoom out. My question is - how much?
Code: Select all
if love.keyboard.isDown("q") then
-- scale down
camscale = camscale - 0.2 * dt
-- camx = camx - ???
-- camy = camy - ???
elseif love.keyboard.isDown("e") then
--scale up
camscale = camscale + 0.2 * dt
-- camx = camx + ???
-- camy = camy + ???
end
- 2.png (926.91 KiB) Viewed 5445 times
I think bit it's common question to ask, but I couldn't find answer at the forum. So if are there any reference to check please share. Thanks for sparing your time at reading this post and have a nice day.