A Steroid 0.3 This is the documentation of the third version of A Steroid. The new features added in this version are:
- Object Bounds
- Ship-Asteroid and Bullet-Asteroid Collision Detection
- Explosions
In this version the objects begin to interact each other. We want to know if an asteroid is hit by a bullet or it is rolling over the user ship. For this reason we have added to the GameObj class a member variable where to store a bounding sphere of the GameObj itself and a member function to test the collision. We have also modified the GameSession classes adding two new member functions to test the collision between asteroids and the ship and between bullets and asteroids. Also the GameSession:update has been modified to check the various collision and display the results i.e. explosions that were modeled into an new Exp class.
Some other modification involved some performance optimization obtained by enabling culling and disabling twosided illumination in the myGLInit() function. Note that this assume that we always gives the faces in the correct counter-clockwise vertex ordering.
Exercises:
- Lighted Explosions. Every esplosion enable a light for its lifetime turning it off when become inactive. Opengl lights are limited in number so allows that only three lights can be allocated by explosions
- FireBall Bullet. Define a new bullet class with the following behaviour: when the bullet is fired it goes slowly for two secs, then it explode into a large number of small bullets.
Some Problems:
- Some class are similar and there is some duplication of code (e.g. bullet and exp)
- The flow of the game (intro -> game -> death -> game -> death -> gameover...) is not well modelled by the single GameSession Class. Some things that are pertinent to the various game sections (e.g. keyboard management are outside the GameSession class and wired into the glut-callbacks). Perhaps a generic GameSection class with interfaces for all the glut callbacks and various derived class as (intro, demo, game, highscore and so on) could make a better work
- The Ast3dFract class has some problems, the creation of a fractal asteroid is a time consuming process (include also some file loading), new asteroids are created every time some asteroid explodes slowing down the game. Probably can be solved with a copy constructor. Moreover larger asteroids should be more detailed than smaller one. Probably also the fact that the asteroid size is in a limited range should be coded in the base class ast.
- The Mesh class has some problem in rendering, and various performance issues (probably we should switch to vertex arrays...)
- Some classes (all the 2D classes) are no more used and they could be removed by the project.
Alphabetic index Hierarchy of classes