Hi,
I am fairly new to game programming need some help with the logic of how to "generate a simple "skyline background" of buildings with different sizes.
Each time the program is launched, it should generate buildings of different sizes.
I need help with the logic of doing this, how should I generate buildings inside the screen, define limits, and so on.
And what would be the easiest way to do this? Should I use images for this or is it easier to generate rectangular shapes?
Thanks a lot in advance.
PyGame Generate Background?
Started by nmuntz, Sep 24 2008 08:47 AM
2 replies to this topic
#1
Posted 24 September 2008 - 08:47 AM
|
|
|
#2
Posted 29 October 2008 - 02:35 PM
Ok, what I would do, a 2 layer background, the sky and the buildings.
You could have premade clouds/stars or whatsoever, that are positionned randomly(It doesnt matter if a cloud is drawn on another)
For the buildings you could either generate each building(relatively hard), or you could have a series a pre-made buildings with known width.
So all you'd have to to is take one randomly (something like random.choose(list) -> returns a picked element from the list), make sure its not the same than the last, and then blit it("draw" it if you're not familiar with pygame) after the preceding one.
You could draw them until lets say 50 pixels after the right end of the screen, so you can scroll your background, from left to right I guess, and when the hidden 50 pixels are scrooled, you just "append" 2 or 3 new buildings. (without forgetting to remove the "old" buildings on the left)
If you need more explanations, ask, I'll try to answer!
You could have premade clouds/stars or whatsoever, that are positionned randomly(It doesnt matter if a cloud is drawn on another)
For the buildings you could either generate each building(relatively hard), or you could have a series a pre-made buildings with known width.
So all you'd have to to is take one randomly (something like random.choose(list) -> returns a picked element from the list), make sure its not the same than the last, and then blit it("draw" it if you're not familiar with pygame) after the preceding one.
You could draw them until lets say 50 pixels after the right end of the screen, so you can scroll your background, from left to right I guess, and when the hidden 50 pixels are scrooled, you just "append" 2 or 3 new buildings. (without forgetting to remove the "old" buildings on the left)
If you need more explanations, ask, I'll try to answer!
#3
Posted 26 November 2008 - 05:27 AM
thanks :D


Sign In
Create Account

Back to top









