Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Smooth Scrolling / Framerate
- By W00T Date 2010-05-19 19:07
I've been looking high and low, but i haven't been able to find any smooth-scrolling solutions for a tile-based game, Any suggestions?

Also, how to limit the framerate so one keypress doesn't send the player halfway across the screen?

Thanks in advance
- By jlnr (dev) Date 2010-05-20 02:57
Be creative, it's all just simple math. If you want scrolling that feels like it has a bit of inertia, just use 95% of the old camera position and 5% of the desired one, i.e.

target_cam_x(/y) = ...
cam_x(/y) = 0.95 * cam_x(/y) + 0.05 * target_cam_x(/y)


And don't limit the framerate, just change the response to the key being pressed. You can use a variable to start a countdown when the button is first pressed, decrease it to 0 by one step every tick, and only then move one more tile, reset the countdown etc. :)
- By W00T Date 2010-05-20 06:28
Thanks for the help, and I may be going into beginner-ish stuff here, but i'm a bit confused on how to implement a camera.
- By jlnr (dev) Date 2010-05-20 06:47
You can look at CptnRuby.rb for a basic (totally non-smooth) camera, it's being implemented via screen_x and screen_y variables that are then simply subtracted from all drawing operations. I am a bit hesitant to implement a more complex, smooth camera because there are so many ways to do it, and I don't want to force my design ideas on anyone ;)

Support for automatically adjusting the positions of a series of draw calls has been discussed here: http://www.libgosu.org/cgi-bin/mwf/topic_show.pl?tid=359

This still does not include the logic of the camera's own movement though.
Up Topic Gosu / Gosu Exchange / Smooth Scrolling / Framerate

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill