CS306 Processing Systems and Structures Lockwood, Spring 2002
Vanessa Clark, Sam Gross, Crystal Miller

Juggle

Introduction

This program creates a juggling simulation game that allows the user to toss and catch three balls as long as the rules of juggling are maintained. The rules of juggling are as follows: there must always be more balls in the air than in the hands. The game begins with one ball in a hand and two balls in the air. From there, the user must use the keyboard keys to toss a ball from either hand. A unique aspect to this game is that the user can hold the toss key down longer to make the balls toss higher. However, the hand must return from the toss motion before the balls in the air fall past it. If a ball drops or a hand catches more than one ball, the game ends. Otherwise, play continues. The user can select various backgrounds of the game, as well as different faces of the juggler.

Key Guide
"f" key - changes juggler's face
"b" key - changes game background
"z" key - left hand toss
"/" key - right hand toss
"+" key - increase game speed
"-" key - decrease game speed
"n" key - new game
"q" key - quit


Problem Description

There are a few challenging aspects of this program. First, it requires directly handling input from the keyboard using an interrupt service routine, instead of using an external library routine for this purpose. Also, it requires continuously updating the screen since the positions of many objects in the game can change without user intervention. The program will also have to make use of the laws of physics to calculate the trajectories of the balls as they are thrown from one hand to the other.


Implementation

First of all, there is a keyboard handler that reads from the keyboard how long a key is pressed down. UpdateScreen, the procedure that calls all the other procedures in the program is run periodically to display the current state of the game. It calculates the velocities of the objects in the game, including the balls and arms and determines where to display them on the screen. The arms move in the same pattern when they throw each ball, but the balls move in a different (calculated) position depending on how long the key was pressed. The graphics used will be .bmp format and be displayed using mode 13h.


Procedures

  • drawObject

  • selectFace

  • selectBackground

  • throwBall

  • updateState

  • updateScreen

  • runGame

    Keyboard Handler