Protect-the-Wall


protect-play.ss

The teachpack protect-play.ss implements a "catch the balls" game. The game generates a random number of balls (between 10 and 20) that are moving from west to east. The goal is to keep as many balls as possible from hitting the eastern wall by moving around the paddle. The paddle can be moved with mouse clicks. Enjoy!

The teachpack provides four operations:

  • go : symbol -> void;
    opens a window (the playing field)
  • change-speed : number -> void;
    changes how quickly the game is displayed (not the speed of the balls)
  • change-width : number -> void;
    changes the width of the playing field
  • change-height : number -> void;
    changes the height of the playing field
  • Also compare with
    pingp-play.ss



    Sample session: Set teachpack to protect-play.ss execute and play:
    > (go 'MyName)
    > (change-speed 120)
    > (go 'MyName)

    > (change-wind 88)
    > (go 'MyName)

    protect.ss

    The teachpack protect.ss also provides the graphical help functions for a student implementation of the protect-the-wall game:
  • protect (list-of ball) move-balls remove-balls-hit-paddle remove-outside-balls balls-posn -> true
    that is, it consumes four values and runs the game.
  • The use of the operation is explained in more detail in subsection X.Y.