Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Horizontal scrolling and C++
- - By reixons Date 2011-01-17 10:43
Hi everyone! I am a new user of GOSU and I have almost found anything I needed either in the reference or in the tutorials but now, I am trying to solve a specific issue and I don't really know how to do it properly.
I am working on a 2D platformer in which I would like to use horizontal scrolling. I don't really know how to move the "2D camera" in GOSU. I have looked at some functions of the Bitmap class but I don't really know if that is the proper way... So if you could tell me any tutorial, doc or sth to perform scrolling, it would be nice!

Thanks in advance!
Parent - - By lol_o2 Date 2011-01-17 18:00
Make a variable to hold horizontal position. Each image should be drawn subtracting this value from x position.
I don't know C++ so much, but in Ruby it looks like this: image.draw(image_x - screen_x , image_y)
When screen_x increases, images are going to the left. For drawing you can also use translate method.
Parent - By jlnr (dev) Date 2011-01-17 19:31
Yep, translation is the way to go. You can call graphics().pushTransform(Gosu::translate(-cameraX, -cameraY)), then draw everything, then popTransform() again.
- By reixons Date 2011-01-17 21:13
Thanks guys!
Up Topic Gosu / Gosu Exchange / Horizontal scrolling and C++

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill