Page 1 of 1

HUMP camera lib script question

Posted: Sat Oct 16, 2010 6:53 am
by weilies
hi vrld,

Some question bout your camera script. Thanks for your guide all the time, especially the scripts provided
i have created a simple script, where arrow keys control my ball movement, WSAD keys control camera movement

And on right top corner, i show my debug messages, where they will always stick on screen even camera is moved
I realized there are 2 issue here, when i try to ZOOM my camera,
- it's not possible to scale everything EXCEPT my debug font
- and also while scaling the object, my debug font (which is image) will look ugly (attachment 20)
- also, can we zoom on particular X,Y point instead of always zoom the center?

Anyway to resolve two issues above?

Thanks again for the camera script!

Re: HUMP camera lib script question

Posted: Sat Oct 16, 2010 7:19 am
by bmelts
I can't speak to the mechanics of HUMP, but the ugly image font is a bug which was recently fixed in the repository - that won't be a problem once 0.7.0 comes out. (Well, it'll still look blurry when scaled, but there won't be those hideous yellow lines.)

Re: HUMP camera lib script question

Posted: Sat Oct 16, 2010 12:39 pm
by vrld
Without looking at your code yet, but based on
weilies wrote:when i try to ZOOM my camera,
- it's not possible to scale everything EXCEPT my debug font
I guess you don't use camera:predraw() and camera:postdraw() correctly, but position the debug message so that it will appear where you want it to. That is not necessary. Put everything that should be seen by the camera into a camera:predraw()/camera:postdraw() pair and print the debug info afterwards:

Code: Select all

function love.draw()
    cam:predraw()
    ... draw game-objects here ...
    cam:postdraw()
    ... draw hud/debug info/everything that should not be affected by the camera here ...
end
also, can we zoom on particular X,Y point instead of always zoom the center?
I am not sure what you mean by that, but it guess not (like with a real camera).
A zoom to a specific point is a combination of zooming and moving the camera, so you will need to adjust the camera position accordingly.

Edit: also, for setting the camera position you should not do

Code: Select all

gCamera = Camera(vector(vectorX, vectorY), vecZoom)
which creates a new camera object, but rather

Code: Select all

gCamera.pos = vector(vectorX, vectorY)
Zooming is also done by updating the zoom-field of the camera object (the documentation is lacking in that respect):

Code: Select all

gCamera.zoom = gCamera.zoom + (cameraZoomSpeed * dt)