StarTrekV3_Linux  Version3
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Pages
TEngine Class Reference

#include <Engine.h>

Public Member Functions

void Move (double a_dLagCount)
 Move all sprite objects according to speed and lagtime. More...
 
void Do_ai ()
 Call AI routines of the sprites. More...
 
void Add (TSprite *const a_pSprite)
 Add a sprite to the Engine. The engine OWNS the sprite from this moment and handles destruction. More...
 
void Draw_sensor (int a_nX, int a_nY, TShip *const a_pPlayer)
 Draws a small sensor screen. More...
 
void DrawHud (TShip *const a_pPlayer)
 Draws a HUD Targetline pointing to a locked ship. More...
 
void SetOrigin (double a_dX, double a_dY)
 Sets the camera center. More...
 
void Folow (TSprite *const a_pSprite)
 Move camera to this sprite. More...
 
void Draw ()
 Draw all spritese. More...
 
void Kill ()
 Free all destroyed sprites. More...
 
void Sort ()
 Z sort the sprites. More...
 
void Clear (bool a_blKeepPlayer)
 Clear the engine, remove all sprites. More...
 
double GetDx ()
 Get Camera X position. More...
 
double GetDy ()
 Get Camera Y position. More...
 
TSpriteSeek (int a_nID, double a_dViewDistance, double a_dX, double a_dY)
 Seek for a certain sprite, returns the closest sprite with given parameters. More...
 
TSpriteSeek (int a_nMember, bool a_blEnemy, double a_dViewDistance, double a_dX, double a_dY)
 Seek for a certain sprite, returns the closest sprite with given parameters. More...
 
TSpriteSeekstarbase (int a_nMember, bool a_blEnemy, double a_dViewDistance, double a_dX, double a_dY)
 Seek for a certain starbase with given parameters. More...
 
bool Detect_collision (TSprite *a_pSprite1, TSprite *a_pSprite2)
 Collision detection function Circulair collision, distance based. More...
 
 TEngine (int a_nWidth, int a_nHeight)
 Engine constructor. More...
 
 ~TEngine ()
 Virtual Destructor. More...
 
bool Save (ofstream &a_SaveStream)
 Saves the Engine contents to an output stream. More...
 
bool Load (ifstream &a_LoadStream)
 Loads contents from an input stream into the Engine. More...
 

Public Attributes

bool m_blSensorStatic
 
int m_nScreenWidth
 
int m_nScreenHeight
 
int m_nScreenMidX
 
int m_nScreenMidY
 
ALLEGRO_COLOR m_clBLACK
 
ALLEGRO_COLOR m_clWHITE
 
ALLEGRO_COLOR m_clGREEN
 
ALLEGRO_COLOR m_clYELLOW
 
ALLEGRO_COLOR m_clBROWN
 
ALLEGRO_COLOR m_clBLUE
 
ALLEGRO_COLOR m_clRED
 
ALLEGRO_COLOR m_clMAGENTA
 
ALLEGRO_COLOR m_clAQUA
 
ALLEGRO_COLOR m_clATHM
 
bool m_blKeys [KEY_MAX]
 

Friends

class TShip
 
class Sector
 

Detailed Description

This is the container class for all sprites. It handles AI calling, Moving, Collision detection and drawing. The engine position is a camera position, everything is drawn with these values as an offset. Sprites beyond the screen boundaries will not be drawn, but will have their AI code called, moved etc.

Constructor & Destructor Documentation

TEngine::TEngine ( int  a_nWidth,
int  a_nHeight 
)

Engine constructor.

Parameters
inta_nWidth Screen width
inta_nHeight Screenheight
TEngine::~TEngine ( )

Virtual Destructor.

Member Function Documentation

void TEngine::Add ( TSprite *const  a_pSprite)

Add a sprite to the Engine. The engine OWNS the sprite from this moment and handles destruction.

Parameters
TSprite* const a_pSprite Pointer to a sprite
void TEngine::Clear ( bool  a_blKeepPlayer)

Clear the engine, remove all sprites.

Parameters
boola_blKeepPlayer Keep the player (Enterprise)
bool TEngine::Detect_collision ( TSprite a_pSprite1,
TSprite a_pSprite2 
)

Collision detection function Circulair collision, distance based.

Parameters
TSprite* a_pSprite1 first sprite
TSprite* a_pSprite2 Second sprite
Returns
true if sprites collide
void TEngine::Do_ai ( )

Call AI routines of the sprites.

void TEngine::Draw ( )

Draw all spritese.

void TEngine::Draw_sensor ( int  a_nX,
int  a_nY,
TShip *const  a_pPlayer 
)

Draws a small sensor screen.

Parameters
inta_nX screen X position
inta_nY screen Y position
TShip* const a_pPlayer Pointer to the player
void TEngine::DrawHud ( TShip *const  a_pPlayer)

Draws a HUD Targetline pointing to a locked ship.

Parameters
TShip* const a_pPlayer Pointer to the player
void TEngine::Folow ( TSprite *const  a_pSprite)

Move camera to this sprite.

Parameters
TSprite* const a_pSprite A sprite
double TEngine::GetDx ( )

Get Camera X position.

double TEngine::GetDy ( )

Get Camera Y position.

void TEngine::Kill ( )

Free all destroyed sprites.

bool TEngine::Load ( ifstream &  a_LoadStream)

Loads contents from an input stream into the Engine.

Parameters
ifstream& a_LoadStream The stream to deserialize from
Returns
true on succes
void TEngine::Move ( double  a_dLagCount)

Move all sprite objects according to speed and lagtime.

Parameters
doublea_dLagCount Time since last cycle
bool TEngine::Save ( ofstream &  a_SaveStream)

Saves the Engine contents to an output stream.

Parameters
ofstream& a_SaveStream The stream to serialize to
Returns
true on succes
TSprite * TEngine::Seek ( int  a_nID,
double  a_dViewDistance,
double  a_dX,
double  a_dY 
)

Seek for a certain sprite, returns the closest sprite with given parameters.

Parameters
inta_nID the ID of a sprite ( sprite Type) see types.h
doublea_dViewDistance distance to X,Y to search
doublea_dX X position of search center
doublea_dY Y position of search center
Returns
A pointer to a sprite or NULL if nothing was found
TSprite * TEngine::Seek ( int  a_nMember,
bool  a_blEnemy,
double  a_dViewDistance,
double  a_dX,
double  a_dY 
)

Seek for a certain sprite, returns the closest sprite with given parameters.

Parameters
inta_nID the ID of a sprite ( sprite Type) see types.h
boola_blEnemy Look for friend or enemy
doublea_dViewDistance distance to X,Y to search
doublea_dX X position of search center
doublea_dY Y position of search center
Returns
A pointer to a sprite or NULL if nothing was found
TSprite * TEngine::Seekstarbase ( int  a_nMember,
bool  a_blEnemy,
double  a_dViewDistance,
double  a_dX,
double  a_dY 
)

Seek for a certain starbase with given parameters.

Parameters
inta_nMember the group the starbase should belong to types.h
boola_blEnemy Look for friend or enemy, if enemy the function looks for a starbase belonging to an enemy of the given group
doublea_dViewDistance distance to X,Y to search
doublea_dX X position of search center
doublea_dY Y position of search center
Returns
A pointer to a sprite or NULL if nothing was found
void TEngine::SetOrigin ( double  a_dX,
double  a_dY 
)

Sets the camera center.

Parameters
inta_dX camera X position
inta_dY camera Y position
void TEngine::Sort ( )

Z sort the sprites.

Friends And Related Function Documentation

friend class Sector
friend
friend class TShip
friend

Member Data Documentation

bool TEngine::m_blKeys[KEY_MAX]
bool TEngine::m_blSensorStatic
ALLEGRO_COLOR TEngine::m_clAQUA
ALLEGRO_COLOR TEngine::m_clATHM
ALLEGRO_COLOR TEngine::m_clBLACK
ALLEGRO_COLOR TEngine::m_clBLUE
ALLEGRO_COLOR TEngine::m_clBROWN
ALLEGRO_COLOR TEngine::m_clGREEN
ALLEGRO_COLOR TEngine::m_clMAGENTA
ALLEGRO_COLOR TEngine::m_clRED
ALLEGRO_COLOR TEngine::m_clWHITE
ALLEGRO_COLOR TEngine::m_clYELLOW
int TEngine::m_nScreenHeight
int TEngine::m_nScreenMidX
int TEngine::m_nScreenMidY
int TEngine::m_nScreenWidth

The documentation for this class was generated from the following files: