caplayer.h

00001 #ifndef CAPLAYER_H
00002 #define CAPLAYER_H
00003 
00004 #include <string>
00005 #include <ClanLib/core.h>
00006 #include <ClanLib/display.h>
00007 
00008 #include "cacolor.h"
00009 #include "camath.h"
00010 
00011 struct CACarType;
00012 
00013 
00017 class CAPlayer {
00018 public:
00019     enum ControlMode { Keyboard, Computer, Network };
00020     enum Direction   { Left, Right, Straight };
00021     enum Speed       { Accelerate, Decelerate, Constant };
00022 
00023     CAPlayer( int id, CL_String name,
00024               int carNumber,
00025               ControlMode controlMode=Keyboard );
00026     ~CAPlayer();
00027 
00028     void   reset();
00029     void   resetForRace();
00030 
00031     void   initPlayer( int routeNumber );
00032     void   renderSprites( CAColor col );
00033 
00035     int    getId() const {
00036         return id;
00037     }
00039     void   setId( int i ) {
00040         id=i;
00041     }
00042 
00044     CL_String getName() const {
00045         return name;
00046     }
00048     void   setName( CL_String n ) {
00049         name=n;
00050     }
00051 
00053     CAColor  getColor() const {
00054         return color;
00055     }
00056     void     setColor( CAColor c, bool render=true );
00057 
00058     void     setCarNumber( int carNumber, bool render=true );
00060     int      getCarNumber() {
00061         return carNumber;
00062     }
00063 
00067     void     setNewCar( bool nc ) {
00068         newCar=nc;
00069     }
00071     bool     getNewCar() {
00072         return newCar;
00073     }
00074 
00076     CACarType* getCarType() {
00077         return carType;
00078     }
00079 
00081     ControlMode getControlMode() {
00082         return controlMode;
00083     }
00085     void setControlMode( ControlMode cm ) {
00086         controlMode = cm;
00087     }
00088 
00090     float  getDirection() const {
00091         return direction;
00092     }
00093     void   setDirection(float dir);
00094 
00096     float  getSpeed() const {
00097         return speed;
00098     }
00099     void   setSpeed( float sp );
00100 
00102     float  getTurbo() const {
00103         return turbo;
00104     }
00105     void   setTurbo( float tb );
00106 
00108     bool   isUp() {
00109         return up;
00110     }
00111 
00113     int    getFrame() const {
00114         return frame;
00115     }
00117     void   setFrame( int f ) {
00118         frame=f;
00119     }
00120 
00122     bool   isActive() {
00123         return active;
00124     }
00126     void   activate( bool yes=true ) {
00127         active=yes;
00128     }
00129 
00131     bool   hasFinished() {
00132         return finished;
00133     }
00134 
00136     bool   isDeath() {
00137         return death;
00138     }
00139 
00141     float  getLife() const {
00142         return life;
00143     }
00145     void   setLife( float l ) {
00146         life = (l>100 ? 100 : l);
00147     }
00148 
00150     int    getBullets() const {
00151         return bullets;
00152     }
00154     void   setBullets(int b) {
00155         bullets = (b>100 ? 100 : b);
00156     }
00157 
00159     int    getFogBombs() const {
00160         return fogBombs;
00161     }
00163     void   setFogBombs(int f) {
00164         fogBombs = (f>3 ? 3 : f);
00165     }
00166 
00168     int    getRaceRank() const {
00169         return raceRank;
00170     }
00172     void   setRaceRank(int r) {
00173         raceRank = r;
00174     }
00175 
00177     int    getRaceTime() {
00178         return raceTime;
00179     }
00181     void   setRaceTime( int t ) {
00182         raceTime = t;
00183     }
00184 
00186     int    getRacePoints() {
00187         return racePoints;
00188     }
00190     void   setRacePoints( int p ) {
00191         racePoints = p;
00192     }
00193 
00195     int    getTotalRank() const {
00196         return totalRank;
00197     }
00199     void   setTotalRank(int r) {
00200         totalRank = r;
00201     }
00202 
00204     int    getTotalPoints() {
00205         return totalPoints;
00206     }
00208     void   setTotalPoints( int p ) {
00209         totalPoints = p;
00210     }
00211 
00213     int    getMoney() const {
00214         return money;
00215     }
00217     void   setMoney( int m ) {
00218         money = m;
00219     }
00220 
00221     void   keyControl();
00222     void   autoPilot();
00223 
00224     void   advance();
00225     void   checkCollisions();
00226     void   checkFunctionMap();
00228     bool   checkEdgeState() {
00229         return (edgeState[0] && edgeState[1] && edgeState[2] && edgeState[3]);
00230     }
00231 
00232     void   calcEdges();
00233 
00234     void   shoot();
00235     void   hit( float amount );
00236     void   kill();
00237 
00238     void   display( int offsetX, int offsetY );
00239     void   move( float x, float y );
00241     void   getPosition( float &xp, float &yp ) {
00242         xp=x;
00243         yp=y;
00244     }
00246     float  getX() {
00247         return x;
00248     }
00250     float  getY() {
00251         return y;
00252     }
00253 
00254     void   activateTurbo();
00255     void   deactivateTurbo();
00256 
00257     float  getPosition();
00259     int    getLapNumber() {
00260         return lapNumber;
00261     }
00263     int    getRouteNumber() {
00264         return routeNumber;
00265     }
00266 
00267     void   addHitPoint( int x, int y );
00268     void   resetHitPoints();
00269 
00270 private:
00272 
00273     int         id;
00275     CL_String   name;
00277     bool        active;
00279     bool        up;
00281     int         frame;
00283     CAColor     color;
00284 
00286     CACarType*  carType;
00288     int         carNumber;
00290     bool        newCar;
00292     CL_Surface* sprite[CA_FPR];
00293 
00297     ControlMode controlMode;
00298 
00300     float  speed;
00302     float  cMaxSpeed;
00304     float  newDirection;
00308     float  direction;
00310     bool   blockDirection;
00311 
00313     int edge[4][2];
00315     bool edgeState[4];
00316 
00318     float explFrame;
00320     float x;
00322     float y;
00324     float ox;
00326     float oy;
00327 
00329     float vx;
00331     float vy;
00332 
00334     int    routePoint;
00336     int    routeNumber;
00337 
00339     float  life;
00341     int    armor;
00343     float  turbo;
00345     bool   turboActive;
00347     int    money;
00349     int    bullets;
00351     int    fogBombs;
00352 
00354     int    lapNumber;
00356     unsigned int lapParts;
00358     int    lastLapPart;
00360     bool   finished;
00362     bool   death;
00364     int    raceTime;
00366     int    raceRank;
00368     int    racePoints;
00370     int    totalRank;
00372     int    totalPoints;
00373 
00375     int    hitPoint[CA_MAXHITPOINTS][2];
00377     int    hitPointCounter;
00378 
00379 
00380 public:
00382 
00383     Speed      speedMode;
00385     Direction  directionMode;
00387     bool       shootMode;
00388 
00389 };
00390 
00391 #endif
00392 
00393 // EOF

Generated on Tue Nov 28 06:48:28 2006 by  doxygen 1.5.0