You are on page 1of 2

Windshield Challenge

PROBLEM:
Your program is to simulate the windshield of a car going through 10000 bugs.

The wipers of a car can only access a semi-circle of the windshield.

You are to write a program that simulates the percentage of bugs that would not be wiped
clean by the wipers.

In the picture above, the bugs are red; the windshield is grey (you choose a good grey colour) with a
black outline.

The wipers are represented by the semi-circle.

The red area of bugs not cleared should be drawn with each new bug (show a small delay).

Simulate for 10000 bugs, each of which has a random chance of hitting anywhere on the windshield.

Leave your finished windshield on the screen for a few seconds.

See next page on how to add text.

Rubric:
Level 1 Level 2 Level 3 Level 4

-There is a program, -Output is not correct -There are some -All steps are followed
but it shows no but there is some problems in the precisely so that
understanding of demonstration of output, not all Intended Image
concepts (pygame, understanding instructions were appears clearly
loops, random followed exactly but it
-Code is efficient
numbers) is mostly correct
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

More Advanced - Getting the Size of the Text


#getting the size of text
textWidth, textHeight = myFont.size("Hello World!")

You can then try to center the text within a rectangle.

You might also like