CAPlayer Class Reference

Covers all data and methods for a single player. More...

#include <caplayer.h>

List of all members.

Public Types

enum  ControlMode { Keyboard, Computer, Network }
enum  Direction {
  Vertical, Horizontal, Left, Right,
  Straight
}
enum  Speed { Accelerate, Decelerate, Constant }

Public Member Functions

 CAPlayer (int id, CL_String name, int carNumber, ControlMode controlMode=Keyboard)
 Constructor.
 ~CAPlayer ()
 Destructor.
void reset ()
 Resets this player.
void resetForRace ()
 Reset things before a new race starts.
void initPlayer (int routeNumber)
 Init a computer player.
void renderSprites (CAColor col)
 Renders the sprites for this player.
int getId () const
 Returns ID of this player.
void setId (int i)
 Sets ID of this player.
CL_String getName () const
 Returns name of this player.
void setName (CL_String n)
 Sets name of this player.
CAColor getColor () const
 Returns the color of this player.
void setColor (CAColor c, bool render=true)
 Sets a new color for this player.
void setCarNumber (int carNumber, bool render=true)
 Sets a new car for this player.
int getCarNumber ()
 Returns current car number (0-CA_NUMCARS).
void setNewCar (bool nc)
 Sets the newCar flag.
bool getNewCar ()
 Returns the newCar flag.
CACarTypegetCarType ()
 Returns pointer to car type.
ControlMode getControlMode ()
 Returns control mode of this player (Keyboard, Computer, Network).
void setControlMode (ControlMode cm)
 Sets a new control mode for this player.
float getDirection () const
 Returns the direction of this player in degrees (0=right, 90=bottom (!)).
void setDirection (float dir)
 Changes the direction and the frame of this sprite.
float getSpeed () const
 Returns the current speed of this player.
void setSpeed (float sp)
 Changes the speed of this sprite.
float getTurbo () const
 Returns turbo load left.
void setTurbo (float tb)
 Changes the turbo load of this sprite.
bool isUp ()
 Returns true if this player is currently on a bridge, false otherwise.
int getFrame () const
 Returns the current frame number.
void setFrame (int f)
 Sets a new frame number.
bool isActive ()
 Returns true if this player is active (true) or not (false).
void activate (bool yes=true)
 Activates or deactivates this player.
bool hasFinished ()
 Returns true if this player has finished the race successfully.
bool isDeath ()
 Returns true if this player died.
float getLife () const
 Returns the life this player has. (0-100).
void setLife (float l)
 Sets a new life amount.
int getBullets () const
 Returns number of bullets left.
void setBullets (int b)
 Sets number of bullets left.
int getFogBombs () const
 Returns number of fog bombs left (0-3).
void setFogBombs (int f)
 Sets number of fog bombs left (0-3).
int getRaceRank () const
 Returns current rank of this player in the current/last race.
void setRaceRank (int r)
 Sets rank for this player.
int getRaceTime ()
 Returns time used for the last race in millisecnds.
void setRaceTime (int t)
 Sets time used for the last race in millisecnds.
int getRacePoints ()
 Returns points for the last race.
void setRacePoints (int p)
 Sets points for the last race.
int getTotalRank () const
 Returns current rank of this player over all.
void setTotalRank (int r)
 Sets current rank of this player over all.
int getTotalPoints ()
 Returns total points over all.
void setTotalPoints (int p)
 Sets total points over all.
int getMoney () const
 Returns the players money.
void setMoney (int m)
 Sets the players money.
void keyControl ()
 Controls the player by keyboard.
void autoPilot ()
 Calculates route of computer players.
void advance ()
 Called on every "step" the game makes.
void checkCollisions ()
 Checks collisions of this sprite with others.
void checkFunctionMap ()
 Checks underlying function map.
bool checkEdgeState ()
 Returns true if all edges of the car are on the road.
void calcEdges ()
 Calculate edges of the sprite.
void shoot ()
 Shooting.
void hit (float amount)
 Player was hit.
void kill ()
 Player was killed.
void display (int offsetX, int offsetY)
 Displays the player on it's current position.
void move (float x, float y)
 Reimplemented for moving the shadow with the sprite.
void getPosition (float &xp, float &yp)
 Returns the players position in xp and yp.
float getX ()
 Returns the x position.
float getY ()
 Returns the y position.
void activateTurbo ()
 Activates turbo mode.
void deactivateTurbo ()
 Deactivates turbo mode.
float getPosition ()
 Returns the approximate position in laps as a float.
int getLapNumber ()
 Returns current lap number.
int getRouteNumber ()
 Returns current route number. Routes are programmed ways for computer players.
void addHitPoint (int x, int y)
 Adds a hit point for the next screen.
void resetHitPoints ()
 Resets all hit points.

Public Attributes

Speed speedMode
 speed mode. Accelerate, Decelerate, Constant
Direction directionMode
 direction mode. Left, Right, Straight
bool shootMode
 Shoot mode. on/off.


Detailed Description

Covers all data and methods for a single player.

Author:
Andrew Mustun


Constructor & Destructor Documentation

CAPlayer::CAPlayer ( int  id,
CL_String  name,
int  carNumber,
ControlMode  controlMode = Keyboard 
)

Constructor.

Parameters:
id Id of this player (for network) or -1 for no id
name Name of this player
carNumber The car number from 0 to CA_MAXPLAYERS
moving Is this sprite controlled by the player (Keyboard), the computer (Computer) or a net player (Network)


Member Function Documentation

void CAPlayer::initPlayer ( int  routeNumber  ) 

Init a computer player.

This method moves the player to the start point and gives the right direction.

Parameters:
routeNumber The initial route number for this player

void CAPlayer::renderSprites ( CAColor  col  ) 

Renders the sprites for this player.

The car image gets rotated and the color adjusted to 'color'.

void CAPlayer::setColor ( CAColor  col,
bool  render = true 
)

Sets a new color for this player.

Parameters:
col New car color
render Render new sprites?

void CAPlayer::setCarNumber ( int  carNumber,
bool  render = true 
)

Sets a new car for this player.

Parameters:
carNumber Car number (index of CATrophy::carType[])
render Render new sprites?

void CAPlayer::setNewCar ( bool  nc  )  [inline]

Sets the newCar flag.

Used for showing who has bought a new car in the position table.

void CAPlayer::keyControl (  ) 

Controls the player by keyboard.

Only called for keyboard (human) players. Computer players rather call 'autoPilot()'.

void CAPlayer::advance (  ) 

Called on every "step" the game makes.

The Sprite moves according to speed and direction.

void CAPlayer::hit ( float  amount  ) 

Player was hit.

Parameters:
amount How hard was the hit?

float CAPlayer::getPosition (  ) 

Returns the approximate position in laps as a float.

e.g. 3.5 means the player has finished 3.5 laps

void CAPlayer::resetHitPoints (  ) 

Resets all hit points.

This happens once for every screen.


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