Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Procedurally generating a background with Gosu
- - By Jarob22 (can't type) Date 2012-04-20 08:23
Hi,

I've been googling around and looking at the doc but I can't work out how to procedurally generate some background on a Gosu::Window such as for a platformer or suchlike. I would also want to bound the edges of the window so you can't go through the bottom and come out at the top, and be able to "move" left and right (I know the background would be moving, but you know what I mean).

Thanks in advance!
Parent - - By Jwosty Date 2012-04-20 12:53
I suggest having some sort of Tile class, and your window generates them in some clever way. You just have to call each of their update and draw methods.

As for the physics, you could look at CptnRuby as an example.
Parent - By Jarob22 (can't type) Date 2012-04-20 13:28
"Some sort of clever way"? What ways could those be? Sorry, but I'm a complete newb to 2d games programming and Gosu, and only about a month or two going with Ruby.
Parent - By RavensKrag Date 2012-04-20 18:19
Look at Texplay if you want to generate images at runtime.

To bound the player inside the window, just make sure the player's position does not exceed what is specified by the window size.  I'll leave the specifics for you to figure out, partially because it depends on what sort of game you're making.
Parent - By jlnr (dev) Date 2012-04-21 02:17
For constraining the scrolling, look at the CptnRuby example game.

A procedurally generated background is a bit more challenging. I actually forgot how I did it last time.
Up Topic Gosu / Gosu Exchange / Procedurally generating a background with Gosu

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill