Lost Password?


Go Back   CodeCall Programming Forum > Software Development > Python

Python Discussion forum for Python, a high-level language with simple syntax, but yet powerful.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-24-2008, 12:47 PM
nmuntz nmuntz is offline
Newbie
 
Join Date: Sep 2008
Posts: 1
Rep Power: 0
nmuntz is on a distinguished road
Lightbulb PyGame Generate Background?

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 10-29-2008, 06:35 PM
manux manux is offline
Newbie
 
Join Date: Oct 2008
Posts: 26
Rep Power: 1
manux is on a distinguished road
Default Re: PyGame Generate Background?

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!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 11-26-2008, 08:27 AM
gaffaro's Avatar   
gaffaro gaffaro is offline
Newbie
 
Join Date: Jul 2008
Posts: 10
Rep Power: 0
gaffaro is on a distinguished road
Default Re: PyGame Generate Background?

thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tournament Generate Whitey PHP Forum 6 08-28-2008 06:58 AM
Help with Background Image! PascalPro Visual Basic Programming 5 06-24-2008 08:09 AM
Generating random background... bentoh General Programming 5 01-24-2008 08:47 AM
What do you think of Pygame? monkey_instinct Python 3 01-03-2008 12:44 PM
Generate text with transparent background AfTriX PHP Tutorials 1 01-08-2007 03:13 AM


All times are GMT -5. The time now is 08:40 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads