I was hoping to make a simple 2D camera so that most of my code could be drawn relatively instead of always having to get an offset x,y, but I think I'm missing something :)
I tried this (really basic, I know, but before I hack around anymore I thought I'd ask):
def initialize(window, x=0,y=0)
@window = window
@x,@y = x,y
Oh and the assumption is that you would then use it as:
#... normal drawing code
This ends up not having any effect, any suggestions?
I think it would be pretty nice for a lot of games, a combination camera / clipping would let you do some decent windowing, etc.
Like you, I tried to use the gl translate method so that I could use "local" coordinates while rendering the widgets inside other widgets in my gui library.
It didn't work and I deduced (never bothered to really check) that gosu caches the drawings so they all happen at the end of the draw function making any gl methods wrapped around your drawing code mostly useless.
You could try using the gl block (never tried, though) or just monkey patch the image drawn function.
Hmm, you can always monkey-patch all versions of Image#draw I think... I thought about the following once:
translate(camera.x, camera.y) do
But hm, I didn't think it was perfect enough to just take the extra work to add it. Mostly because the code won't be that simple once you want to have parallax scrolling, and the game I mainly work on has parallax scrolling even within the object list.
Hi sorry, if this post is considered as Necro-posting
But here's some code I've produced ( for castlevania ), in order to have a nice smooth parallax scrolling(with several backgrounds) with a camera following the player in a map of a given size.
Basically the camera class is in charge to convert the absolute coordinates "or real coordinates" into screen coordinates and to keep the player in the center of the screen.
Here is the code:http://pastebin.com/f7e26b916
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill