class GameObj

This class represent a generic game object, with its speed, position etc

Inheritance:


Public Fields

[more]Point3f p
Position of a generic object in the game
[more]Point3f axis
Rotation Axis
[more]float angle
Direction (in degree)
[more]Point3f v
Speed Component (mt / sec)
[more]float av
Angular Speed (deg / sec)
[more]bool active
If the object is active or not
[more]Sphere3f B
Bounding sphere of the object

Public Methods

[more] GameObj()
Default constructor
[more] GameObj(const Point3f &_p, const float _angle)
constructor with given position and direction
[more] GameObj(const Point3f &_p, const float _angle, const Point3f &_v)
constructor with given position and direction and velocity
[more]int Draw()
Basic Redraw Function it does nothing
[more]void Update(int t)
Basic update function
[more]Point3f VDir()
Return the unitary direction vector
[more]bool Collide(GameObj *o)
This function check if the current object collide with the passed one
[more]void DrawBound()
Utility function that draw the bounding sphere
[more]bool operator < ( GameObj const & o ) const
Less operator needed for stl containers
[more]bool operator == ( GameObj const & o ) const
Equal operator needed for some stl containers.

Documentation

This class represent a generic game object, with its speed, position etc.. This class is the base class that is used to derive all the objects represented in the game: asteroids, ships bullets explosion and so on. Each GameObj has a specific position in the game space, a velocity vector, a heading (direction) angle (that can be obviously different from the velocity direction), a main rotation axis and an angular speed (think of asteroids inertia).

Version History

o GameObj()
Default constructor

o GameObj(const Point3f &_p, const float _angle)
constructor with given position and direction

o GameObj(const Point3f &_p, const float _angle, const Point3f &_v)
constructor with given position and direction and velocity

oPoint3f p
Position of a generic object in the game

oPoint3f axis
Rotation Axis

ofloat angle
Direction (in degree)

oPoint3f v
Speed Component (mt / sec)

ofloat av
Angular Speed (deg / sec)

obool active
If the object is active or not

oSphere3f B
Bounding sphere of the object

oint Draw()
Basic Redraw Function it does nothing. All derived classes should provide their own Draw functions. Version History
  • 0.1 First Release.
  • 0.4 Changed return value from void to int: now it return the number of drawn triangles

ovoid Update(int t)
Basic update function. It updates the position and the direction of the object according its current speed and the elapsed time (expressed as millisec).

oPoint3f VDir()
Return the unitary direction vector.

obool Collide(GameObj *o)
This function check if the current object collide with the passed one. The two objects collide if their bounding spheres has an intersection. Note that this is just a rough approximation of a real collision detetction. A much better solution could be obtained by substituting spheres with hierarchies of bounding objects and testing the intersection between the various levels of the hierarchies. Perhaps in next versions...

ovoid DrawBound()
Utility function that draw the bounding sphere

obool operator < ( GameObj const & o ) const
Less operator needed for stl containers

obool operator == ( GameObj const & o ) const
Equal operator needed for some stl containers.


Direct child classes:
Stars
Ship
GameObjTimed
Ast

Alphabetic index HTML hierarchy of classes or Java



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