CATrophy Class Reference

Main class of Trophy. More...

#include <catrophy.h>

Inheritance diagram for CATrophy:

CAScreen List of all members.

Public Types

enum  Difficulty { Easy, Medium, Hard }

Public Member Functions

virtual int main (int argc, char **argv)
 The main function.
virtual char * get_title ()
 Gets the application title.
virtual void init_modules ()
 Inits modules.
virtual void deinit_modules ()
 Deinits modules.
void initCarTypes ()
 Initializes car types.
void deinitCarTypes ()
 Deinitializes car types.
void initGoodies ()
 Initializes goody types and instances.
void deinitGoodies ()
 Deinitializes goody instances.
void initPlayers ()
 Initializes the players.
void deinitPlayers ()
 Deinitializes and deletes the players.
void initNetwork ()
void deinitNetwork ()
void initPanel ()
 Initializes the panel on the left.
void deinitPanel ()
 Deinitializes the panel on the left.
void initTrackList ()
 Initializes the track list.
void initTrack (CL_String trackName)
 Initializes track with given name.
void deinitTrack ()
 Deinitializes and deletes current track.
void reconfigure ()
 Reconfigures parameters.
void resetGoodies ()
 Resets all goodies.
void resetFogBombs ()
 Resets all fog bombs.
void resetDustClowds ()
 Resets all dust clowds.
void resetPlayers ()
 Resets all players.
void runMenu ()
 Called by CATrophy::main() to start the menu in an std::endless loop.
bool runPositionTable (bool race)
 Called by CATrophy::runMenu() to start the position table in an std::endless loop.
void runCreditsScreen ()
 Called by CATrophy::runMenu() to start the credits screen in an std::endless loop.
void runServerInfo (bool success)
 Called by CATrophy::runMenu() to start the server info screen in an std::endless loop.
void runClientInfo (bool success)
 Starts the client info screen in an endless loop.
void startNewGame ()
 Starts a new game.
void startServer ()
void chooseNetGame ()
int addNetPlayer ()
void controlNetPlayer (int id, int xpos, int ypos, int dir)
 Controls the net player with given id.
int run ()
 Called by CATrophy::runMenu() to start the game in an std::endless loop.
void placeGoody ()
 Places a new goody (not always successful).
void setRanks ()
 Sets the ranks of the players during race.
int getSpeedLimit (int x, int y)
 Gets the speed limit for a coordinate of the map.
int getLapPart (int x, int y)
 Gets the lap part for a coordinate of the map.
int getLevel (int x, int y)
 Gets the level for a coordinate of the map.
bool checkCoordinate (int x, int y)
 Checks if the gifen coordinate is on the map and returns true if so.
int getTime ()
 Returns race time in msec.
char * getTimeString ()
 Race time as string.
void dropFogBomb (int x, int y, bool up)
 Drops a fog bomb on the given place.
void makeDustClowd (int x, int y, bool up)
 Created a dust clowd on the given place.
void measureFrameTime (bool start)
 Measures the time we needed to draw a frame.
void waitForSilence ()
 Waits until no key is pressed.
void buyCars ()
 Distributes cars to players which have enough money.
void buildScreen ()
 Builds the whole game screen.
void displayMap ()
 Displays the race map.
void displayPlayers (bool up)
 Displays players.
void displayGoodies (bool up)
 Displays the goodies.
void displayBridge ()
 Displays the bridge if there is any.
void displayFogBombs (bool up, bool bomb)
 Displays fog bombs.
void displayDustClowds (bool up)
 Displays dust clowds.
void displayCheckFlag ()
 Displays a waving check flag when the first player has reached the finish.
void displayStartingLights ()
 Displays the starting light animation.
void displayTrackPoints ()
 Displays track points.
void fadeScreen (bool in, CAScreen *screen, bool whole=true)
 Fades the screen in (true) or out (false).
void scroll ()
 Scrolls the map to center player 0.
void saveGame ()
void loadGame ()

Public Attributes

CALoadingScreen loading
 Loading screen.
bool pause
 Game paused?
bool sound
 Sound on/off.
int volume
 Sound volume.
bool fullScreen
 Fullscreen mode?
bool fast
 Fast mode (no screen fading) (command line argument --fast).
bool server
 Are we a server (command line argument --server).
bool client
 Are we a client (command line argument --client).
bool debug
 Debug mode (command line argument --debug).
bool trackInfo
 Show trackinfo (crosses and numbers on track points) (command line argument --trackinfo).
float framesPerSec
 Frames per second we can do at maximum.
CAPlayerplayer [CA_MAXPLAYERS]
 Array of Players. Created and destroed by this class.
CACarType carType [CA_NUMCARTYPES]
 Array of car types.
CAGoodyType goodyType [CA_NUMGOODYTYPES]
 Array of goodyTypes.
CAGoodygoody [CA_NUMGOODYTYPES][CA_NUMGOODIES]
 The goody instances. CA_NUMGOODIES of each type.
Difficulty difficulty
 Chosen difficulty (easy, medium, hard).
CATrack track
 Current track data.
CAStringList trackList
 Track directory names list.
int offsetX
 Offset of the background map in x.
int offsetY
 Offset of the background map in y.
CAPanelpanel
 Panel. Created and destroyed in this class.
int panelWidth
 Width of panel (can change).
int headerHeight
 Height of header in pixels.
int lightState
 State of the start lights 0: off 1: 1/3 on 2: 2/3 on 3: on 4: sliding away.
bool firstPlayerFinished
 first player has finished race
bool allowShooting
 In the beginning of each race, shooting is disabled.
CAFogBomb fogBomb [CA_MAXFOGBOMBS]
 Array of fog bombs.
int fogBombCounter
 current index for the fogBomb array.
CADustClowd dustClowd [CA_MAXDUSTCLOWDS]
 Array of dust clowds.
int dustClowdCounter
 current index for the dust Clowd array.
int width
 Total width (screen resolution in x).
int height
 Total height (screen resolution in y).
char serverIp [16]
 Ip set in the net options dialog or "auto".
int serverPort
 Server port number.

Detailed Description

Main class of Trophy.

There's only one global instance: 'CATrophy application'. It's usually accessed over the macro CA_APP. E.g.: CA_APP->buildScreen(); This class starts the Game, inits the moduls and displays things.

Author:
Andrew Mustun


Member Function Documentation

int CATrophy::main ( int  argc,
char **  argv 
) [virtual]

The main function.

Called by ClanLib main().

char * CATrophy::get_title (  )  [virtual]

Gets the application title.

Needed by ClanLib.

void CATrophy::init_modules (  )  [virtual]

Inits modules.

Called by ClanLib main().

void CATrophy::deinit_modules (  )  [virtual]

Deinits modules.

Called by ClanLib main().

void CATrophy::initPlayers (  ) 

Initializes the players.

As default, player[0] is human and the others are computer players. As soon as a network player joins, a computer player gets replaced by a net player.

void CATrophy::initTrackList (  ) 

Initializes the track list.

Track names are read fro the track directory (resources/tracks/...)

void CATrophy::reconfigure (  ) 

Reconfigures parameters.

Called by the configure menu.

void CATrophy::resetGoodies (  ) 

Resets all goodies.

Done before a new race.

void CATrophy::resetFogBombs (  ) 

Resets all fog bombs.

This happens before a new race.

void CATrophy::resetDustClowds (  ) 

Resets all dust clowds.

This happens before a new race.

void CATrophy::resetPlayers (  ) 

Resets all players.

Happens before a new game (car types, points, money).

bool CATrophy::runPositionTable ( bool  race  ) 

Called by CATrophy::runMenu() to start the position table in an std::endless loop.

Parameters:
race true: Show table for last race / false: Total results table
Returns:
true on success (User pressed Enter or Space) otherwise false (User pressed ESC)

void CATrophy::runServerInfo ( bool  success  ) 

Called by CATrophy::runMenu() to start the server info screen in an std::endless loop.

Parameters:
success true: Show info that the server is running. false: Show error message.

void CATrophy::runClientInfo ( bool  success  ) 

Starts the client info screen in an endless loop.

Parameters:
success true: Show info that the client is running. false: Show error message.

void CATrophy::startNewGame (  ) 

Starts a new game.

Called by the menu.

void CATrophy::controlNetPlayer ( int  id,
int  xpos,
int  ypos,
int  dir 
)

Controls the net player with given id.

Parameters:
id Net players ID
xpos x position of net player
ypos y position of net player
dir Direction (angle) of net player

int CATrophy::getLevel ( int  x,
int  y 
)

Gets the level for a coordinate of the map.

Returns:
0: Level on the point is down 1: Level on the point is up 2: Level on the point is not defined

void CATrophy::dropFogBomb ( int  x,
int  y,
bool  up 
)

Drops a fog bomb on the given place.

This function is called from evil players.

void CATrophy::makeDustClowd ( int  x,
int  y,
bool  up 
)

Created a dust clowd on the given place.

This function is called from sliding players.

void CATrophy::measureFrameTime ( bool  start  ) 

Measures the time we needed to draw a frame.

Used for calculating the frame rate.

void CATrophy::buildScreen (  )  [virtual]

Builds the whole game screen.

ONLY this function is called for this purpose.

Implements CAScreen.

void CATrophy::displayPlayers ( bool  up  ) 

Displays players.

Parameters:
up true: Players on bridges / false: Players under bridges

void CATrophy::displayFogBombs ( bool  up,
bool  bomb 
)

Displays fog bombs.

Parameters:
up true: Fog bombs on bridges / false: Fog bombs under bridges
bomb true: The bombs themselves / false the fog of exploded bombs

void CATrophy::displayDustClowds ( bool  up  ) 

Displays dust clowds.

Parameters:
up true: Dust clowds on bridges / false: Dust clowds under bridges

void CATrophy::fadeScreen ( bool  in,
CAScreen screen,
bool  whole = true 
)

Fades the screen in (true) or out (false).

Parameters:
in Fade in (true) or out (false)
screen Pointer to the screen which is of type CATrophy, CAMenu, CAPositionTableView or another class derived from CAScreen.
whole Fade the whole screen? Otherwise the top part (TROPHY) won't fade.


The documentation for this class was generated from the following files:
Generated on Tue Nov 28 06:48:29 2006 by  doxygen 1.5.0