Breakout Game

As part of the course for the Fall 2009 semester, each student is required to submit two completed games. One written in C++ and the other in Java. The games must be created from the ground up, but the class exercises serve as good reference for the students to work off of.

The goals of this project are for the students to learn fundamental OOP concepts including how to: Create Graphical User Interfaces, handle user inputs, perform collision detection and the ability to save and retrieve game status using files.

For collision detection: The most simple way to detect the collision for the spheres used in breakout were to start by computing the distances between the objects. In order for collision the distance between the center points of the two objects must be less than the sum of the two radii. Once determined in collision, the program must then apply the law of reflection. To calculate the vector at which the collision should reflect the ball can be calculated as follows (Vo representing the new Vector, Vi representing the initial, N as the normal vector):

1. The sum of Vo and (-Vi) is a vector in the same direction as Normal N. Therefore, we can write Vo - Vi = sN, where s is twice Vi's projection on N. Basically s is twice the inner product between (-Vi) and N, or 2 (-Vi) N.

2. Substituting for s we find: Vo = Vi - 2 (Vi N) N

3. Assuming Vi = (xi, yi), N = (xn, yn), and Vo = (xo, yo) We find that xo = xi - 2 (xi xn + yi yn) xn yo = yi - 2 (xi xn + yi yn) yn

By setting the vector for the ball's velocity to Vo=(xo, yo) we have successfully determined the vector at which the ball should reflect at.

This is one of the most vital tasks in creating the Breakout Game and by successfully determining this we are now one step further to the final game.

Alumni Liaison

Questions/answers with a recent ECE grad

Ryne Rayburn