class GameSession: public GameSection

This class represent a Game session

Inheritance:


Public Fields

[more]list<Ast *> MediumAst
The list of MediumSize Asteroids
[more]list<Ast *> SmallAst
The list of SmallSize Asteroids
[more]list<Bullet *> ActiveBullet
The list of all the active bullets
[more]list<Ast*> ActiveAst
The list of all the active Asteroid
[more]list<GameObj *> ActiveObj
The list of all the generic active objects
[more]Ship* S
The only Spaceship in game.
[more]int SpaceSize
The size of the Game Space (in mt)
[more]int deadpause
Used to delay the creation of the new ship
[more]bool PauseFlag
True if the game is paused;

Public Methods

[more]void Update(int dt)
This function updates All the active objects
[more]void Draw()
This function draws all the active objects
[more]void Clip(Point3f &p)
This function clip the position of an object against the screen boundary
[more]void Shoot()
Shoot a bullet
[more]void Key(unsigned char key)
Manage key pression
[more]void SKey(int key)
Manage special key pression
[more]void Init()
Start the game
[more]void Pause()
Pause the game
[more]void End()
Game Over;
[more]void AstShipCollision(Ast *a)
Check the collision between the asteroids and the ship If the ship is hit by an asteroid the ship is inactivated (e
[more]void BulletAstCollision(Bullet *b)
Check the collision between a bullet and all the asteroids

Public

[more] AstNum=8
Default Number of Asteroids at startup

Inherited from GameSection:

Public Fields

oint ScreenW
oint ScreenH

Documentation

This class represent a Game session. It contain all the data needed during the game play, active game objects, score, lives and so on. Version History

o AstNum=8
Default Number of Asteroids at startup

olist<Ast *> MediumAst
The list of MediumSize Asteroids. It is prefilled with 2*AstNum Medium Asteroids

olist<Ast *> SmallAst
The list of SmallSize Asteroids. It is prefilled with 2* AstNum Small Asteroids

olist<Bullet *> ActiveBullet
The list of all the active bullets

olist<Ast*> ActiveAst
The list of all the active Asteroid

olist<GameObj *> ActiveObj
The list of all the generic active objects

oShip* S
The only Spaceship in game.

ovoid Update(int dt)
This function updates All the active objects. This is done by traversig the three list (ActiveAst, ActiveBullet and ActiveObj) and calling the Update virtual function for each of them. If an object become inactive after an update it is removed by the list and deallocated here. During the traversal of ActiveAst list we also check for AstShipCollision. During the traversal of ActiveBullet list we check for BulletAstCollision Note that this function traverse again the ActiveAst list (quadratically!).

ovoid Draw()
This function draws all the active objects. The ActiveObj list (the one containing explosions) is drawn as the last list to correctly draw the explosion transparency effects.

ovoid Clip(Point3f &p)
This function clip the position of an object against the screen boundary

ovoid Shoot()
Shoot a bullet. What kind of (and how many!) bullet is shot depends on the current type of ship stored in member S;

ovoid Key(unsigned char key)
Manage key pression.

ovoid SKey(int key)
Manage special key pression. It should start the thrust (up arrow), the rotation (left/right arrow) and side thrust (alt+left/right) of the ship.

ovoid Init()
Start the game. From version 0.4 it does also all the opengl init stuff, and the creation of all asteroids (larger and smaller)

ovoid Pause()
Pause the game

ovoid End()
Game Over;

oint SpaceSize
The size of the Game Space (in mt)

ovoid AstShipCollision(Ast *a)
Check the collision between the asteroids and the ship If the ship is hit by an asteroid the ship is inactivated (e.g. it will not be drawn) for a couple of seconds by setting the deadpause member variable.

ovoid BulletAstCollision(Bullet *b)
Check the collision between a bullet and all the asteroids. If an asteroid is hit the bullet and the asteroid are deactivated, a new explosion is added to the ActiveObj list and two new smaller asteroids are extracted from the prebuilt list of asteroids.

oint deadpause
Used to delay the creation of the new ship. After a ship-asteroid collision the AstShipCollision function set this to wait for two secs.

obool PauseFlag
True if the game is paused;


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.