Department of Mathematics, Computer Science, and
                Statistics
St.
                Lawrence University
Zonohedron
 

What is this object?

...

Links
Overview
Schedule
Grading Info
Class Notes

 

CS 140: Introduction to Computer Programming


CLASS CREATION #7
Tuesday, November 27

Today you will add a score feature to our multibounce.py program.  I have broken this process down into the following steps.

  • Initialize a variable called score to be zero at the start of the program.
  • Create a function showscore(score): that will render the value of score and display it in the upper left corner of the screen, but not right up against the edge.  (TIP: it will help to convert this number to a string first.)
  • Call this function at both places within the program that redraw the screen.  Just be sure to put it before the pygame.display.flip() command.
  • Figure out precisely where in the program we might be able to detect a bounce off the paddle.  (There are two possible places.)
  • Write code at this spot that will increase the score by the number of balls on the screen.  This way it will pay to keep lots of balls bouncing!

If you need any guidance do not hesitate to flag down Dr. V, Spencer, or ask a neighbor for help.  Once your program is running satisfactorily, be sure to have Dr. V try it out so that he can give you credit for your creation.