CS492 Game Design Project 1: Bouncing Balls

Due Friday, September 15

For this assignment, develop a ball class, using the following header file:

#ifndef BALL_H
#define BALL_H

#define GRAVITY 10 // In units/second

class Ball {
		float xpos, ypos;
		float xvel, yvel;
		Ball(float xp, float yp, float xv, float yv) : xpos(xp), ypos(yp), xvel(xv), yvel(yv) {} 

		void update(float time);
		void draw();

Implement the methods in a separate file with .cpp extension. update should update the position of the ball, using GRAVITY. The time paramter is in seconds, so if you have a 60 hz refresh rate and the framerate is synchronized to the refresh rate, this will be 1/60. The ball should bounce upon reaching the "ground", and rebound with some fraction of its initial velocity. Draw should draw a glutSolidSphere for the ball.
Write a program in a different file that creates several instances of your ball class and draws them in 3d, showing that they bounce. Use appropriate settings so that the bouncing balls can be clearly seen. This can include lighting, use of gluPerspective and/or gluLookAt, etc, but doesn't have to. The standard view covers a cube, -1 to 1 in all dimensions, so if you scale your balls and movements into this space, the default camera location will work just fine. In this case, locate the "floor" at -1 on the y axis, or maybe slightly higher to better show the bounce.

Turning in the assignment

Upload your completed project as a single file (.zip, .tar, etc) to the class website. Name it using your name and project 1.