Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / window.draw_quad() help
- - By jeremywoertink Date 2012-07-19 20:50
I have a score that's fixed to the upper left corner of the screen, so as I move, it stays in place. I wanted to put a background color on it, so I used draw_quad, but when I move, the rectangle also moves...

Here's the code I'm using.

https://gist.github.com/3146716

It looks like it draws it in the correct position when the game first starts, but after the character falls, the (x,y) position stays the same, but the rest of the rectangle resizes. What's the best way to handle this?

Thanks,
~Jeremy
Parent - - By Spooner Date 2012-07-19 22:57
GUI elements should be drawn after the game-view is drawn, or they will always be drawn at the same place on the map, not the same place on the screen. That is, put the font and quad calls _after_ the translate block. There is no point translating the score then trying to un-translate it again!

https://gist.github.com/3147420 (with some other clarity improvements, which you can take or leave)
Parent - - By jeremywoertink Date 2012-07-19 23:20
oh sweet! Thanks! I guess I misunderstood how translate worked. Makes sense now. I love the cleaner code :)
Parent - By Spooner Date 2012-07-19 23:48
Your way was fine, but a bit over-complicated. The reason it didn't work was because you only added the camera position to a few of the coordinates in the quad, so some of its vertices were being "pulled" along with the camera.
Up Topic Gosu / Gosu Exchange / window.draw_quad() help

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill