- // RACE X
- //
- // Written by Mauricio Teichmann Ritter
- //
- // Copyright (C) 2002, Brazil. All rights reserved.
- //
- //
- #include ".AppLibcSprite.h"
- #include ".applibchitchecker.h"
- #include ".applibcsound.h"
- #include <vector>
- #include <string>
- using namespace std;
- #if !defined(AFX_CRACECAR_H__599011FD_F0E9_4C8A_AAC5_ECA4A9FF481B__INCLUDED_)
- #define AFX_CRACECAR_H__599011FD_F0E9_4C8A_AAC5_ECA4A9FF481B__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- #define CTRL_COMPUTER 1
- #define CTRL_USER 2
- #define CTRL_NETWORK_REMOTE 3
- #define CTRL_NETWORK_LOCAL 4
- #define CARSTATE_OK 1
- #define CARSTATE_CRASHED_WALL 2
- #define CARSTATE_CRASHED_CAR 3
- #define CARSTATE_RACECOMPLETED 4
- typedef vector<long> LONGVECTOR;
- // cRaceCar定义了参加游戏的每辆赛车,这些赛车包括了颜色,id和选手名字属性
- class cRaceCar
- {
- private:
- int iTurnCar;
- //定义赛车爆炸时间
- int iCrashTime;
- //到一个检查站的距离(用来定位)
- int m_iDistanceToNextCheckPoint;
- //赛车位置
- int m_iPosition;
- //声音缓冲
- cSound m_pSound;
- cSound m_pCrashSound;
- //存储每一圈用时的Vector
- LONGVECTOR m_vcLapTimes;
- long m_lCurrentTime;
- //这些是赛车发生碰撞时用到的备用变量
- //如果赛车在发生碰撞后要重置状态,则使用这些变量
- int m_fBackupIncrementX;
- int m_fBackupIncrementY;
- int m_fBackupDirectionY;
- int m_fBackupDirectionX;
- int m_iBackupAngle;
- float m_fBackupPosY;
- float m_fBackupPosX;
- int iBackupTurnCar;
- int m_iBackupDistanceToNextCheckPoint;
- //赛车当前状态
- int m_iCarState;
- void TurnCarRight();
- void TurnCarLeft();
- //定义赛车如何控制(电脑,人,还是网络)
- int m_iControlType;
- //定义如何增加X 和Y 位置
- int m_fIncrementX;
- int m_fIncrementY;
- //赛车当前速度
- int m_iSpeed;
- //赛车最高速度
- int m_iMaxSpeed;
- //赛车在赛道地图上的当前位置
- float m_fPosY;
- float m_fPosX;
- //上次赛车转向的时间
- long m_lLastTurn;
- //赛车上次加速时间
- long m_lLastSpeedIncr;
- // 标志X和Y的方向
- int m_fDirectionY;
- int m_fDirectionX;
- //多边形边界
- POINT *m_pBound;
- public:
- void MoveForward(int iSpeed);
- void Backup();
- DWORD m_dwElapseTime;
- void AddLapTime(DWORD dwTime);
- void SetSpeed(int iValue);
- BYTE m_bLastSent_Speed;
- BYTE m_bLastSent_Position;
- BYTE m_bLastSent_CarState;
- BYTE m_bLastSent_Laps;
- BYTE m_bLastSent_Angle;
- DWORD m_dwLastSent_LastLapTime;
- unsigned short m_nLastSent_PosX;
- unsigned short m_nLastSent_PosY;
- BYTE m_bRemoteKeyboardStatus;
- int m_iAngle;
- BYTE GetID();
- void SetID(BYTE iValue);
- BYTE m_bID;
- int GetCarColor();
- long GetLastLapTime();
- long GetLapElapseTime(int iLap = -1);
- int GetDistanceToNextCheckPoint();
- void SetPosition(int iPosition);
- int GetPosition();
- int m_iLaps;
- int m_iBackupSprite;
- void Crashed();
- int GetCarState();
- void SetCarState(int iState);
- void Idle();
- void HitCar();
- void BreakCar();
- void Accelerate();
- int GetControlType();
- void SetControlType(int iType);
- int GetSpeed();
- int m_iCheckPoint;
- int GetLastCheckPoint();
- void SetLastCheckPoint(int iLastCheckPoint);
- cHitChecker m_hcRaceCar;
- void GetPos(int* iX, int* iY);
- void Process(void* pTrack);
- void Destroy();
- void Create(int iColor);
- void Draw(int nViewX, int nViewY);
- void SetPos(int iX, int iY);
- cSprite m_sprCar;
- cSprite m_sprCarExplode_0;
- cSprite m_sprCarExplode_45;
- cSprite m_sprCarExplode_90;
- cSprite m_sprCarExplode_135;
- cSprite m_sprCarExplode_180;
- cSprite m_sprCarExplode_225;
- cSprite m_sprCarExplode_270;
- cSprite m_sprCarExplode_315;
- cRaceCar();
- virtual ~cRaceCar();
- protected:
- int m_iColor;
- void RotateBound(int iAngle);
- };
- #endif // !defined(AFX_CRACECAR_H__599011FD_F0E9_4C8A_AAC5_ECA4A9FF481B__INCLUDED_)