protect-play-lib.ss

The library protect-play-lib.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 library 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-lib.ss



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

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

    pingp-lib.ss

    The library pingp-lib.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 -> #t
    that is, it consumes four values and runs the game.
  • The use of the operation is explained in more detail in subsection X.Y.