You are on page 1of 1

Stairs Simulation Challenge

PROBLEM:
To simulate the amount of people on a set of stairs with 20 steps.

Create a screen as shown on a 600 by 400 screen to represent the stairs and the people on the
stairs. Note that the height of the people does not matter.

People will move up the stairs at a rate of 1 step per second.


Every second there is a 1 in 10 chance of another person stepping onto the bottom of the stairs.
When they step on the stairs, they are on the left most step.
After reaching the top step, a person then steps off the stairs.
A person is represented by a Blue, Green or Red line (equal random chance for each).
The simulation starts with a single person on the first step.
You must keep track of how many seconds have passed in the simulation.
The simulation finishes when there is no one on the stairs any more.
Pause the screen for ten seconds before closing.

You can see a full simulation here.

Adding Text to the Pygame Screen


#defining fonts
myFont = pygame.font.SysFont("Times New Roman",30) # define where colours are

#add this code where you want the words to display


text = myFont.render("Hello World!" , 1, (255, 0, 0)) #string, 1, colour - keep as 1
screen.blit(text, (200,200,400,100)) #rectangle represents where the text will be

You might also like