The goal of this project was to create a simple space shooter game. I love Star Wars and was thrilled when I found a free OBJ file of the Millennium Falcon. After completing each task, I kept thinking of more and more things that I wanted to add. I'm proud of my final project but look forward to working on it more.
The main features I implemented were:
A start screen with instructions on how to start and quit
A free look camera based on mouse position that continuously moves forward
A cubemap of space that moves with the camera so you never fly outside the map
Texturing of the Millennium Falcon and asteroids
Blinn-Phong shading of the reticle and plasma beams
Sphere-to-sphere collision detection between the ship and the asteroids and between the asteroids and plasma beams fired by the user
Explosions: particle effects when the ship collides with an asteroid
Random movement and initial position of asteroids
Watch the video to see the features described above in action.
How To Play
w: Toggle speed boost Space: Start or restart game
f: Fire weapon Escape: Quit game
b: Barrel roll
This is the screen that loads on start up. It shows the title of the game, how to continue, and how to quit. This screen is an image created in Adobe Photoshop applied as a texture to a square OBJ file and placed in front of the camera.
Above is a screenshot of the Millennium Falcon flying through the asteroids. I'm really happy with how realistic everything looks due to the texturing. The asteroids shown move in a random direction until they reach the world boundary where they turn around to keep all the action close to the player.
Here, the Millennium Falcon is in the process of doing a barrel roll. Due to the fact that I am using sphere to sphere collision detection, doing a barrel roll has no effect on dodging asteroids. It's just for fun.
In this picture, the player has just shot an asteroid. The asteroid is engulfed in flames and is in the process of disappearing. In real time, it looks close enough to an explosion.
Finally, the player has just crashed into an asteroid. The particle effects can be seen here in the firey explosion. Check out the video above to see the explosion more clearly.
The biggest challenge I had was getting collision detection to work smoothly and properly. The method of collision detection I used was sphere-to-sphere collision detection. I did this because it was (supposed to be) easy to implement in the time I had to complete the project. What I did was "draw" a sphere around the Millennium Falcon and a sphere around every asteroid depending on its size. I then checked if the distance between the center of the ship and the center each asteroid was less than the sum of their radii. If it was, then I registered it as a collision. This method worked well for the asteroids, but the Millennium Falcon is not as spherical so its possible to register a collision above the ship when there shouldn't have been. In order to register fewer false-positives, I decreased the size of the spheres around the Millennium Falcon and the asteroids. In the future, I want to "draw" an axis-aligned bounding box around the Millennium Falcon and use that for collision detection.
Another challenge I had was getting the explosion effect to display properly. I was testing the effect in a previous lab we did for the class and it was working perfectly. However, when I tried to bring it into my final project, nothing was drawing on the screen! I thought that was ridiculous and I almost pulled my hair out trying to figure out what was wrong. In the end, I was using two different variable names for my alpha texture in my main.cpp and my fragment shader.
I still want to add text to the top left or right corners of the screen to says how many asteroids the user has destroyed, how fast the ship is moving, and how many lives the player has before the game is over. Next, I want to add sound to the game. I want to add John Williams' classic Star Wars main theme along with sound effects for when the player shoots or crashes. Finally, I want to work on geometry instancing to display the asteroids.