cRaceTrack.h
上传用户:sycq158
上传日期:2008-10-22
资源大小:15361k
文件大小:6k
- #if !defined(AFX_CRACETRACK_H__2022F72B_F3CD_47F7_904E_11F2297090EE__INCLUDED_)
- #define AFX_CRACETRACK_H__2022F72B_F3CD_47F7_904E_11F2297090EE__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- #include <vector>
- #include <string>
- using namespace std;
- #include ".AppLibcSurface.h"
- #include ".AppLibcHitChecker.h"
- #include ".AppLibcMatrix.h"
- #include "cRaceCar.h"
- #define TURN_LEFT 10
- #define TURN_RIGHT 20
- #define TILE_SIZE 200
- // cRaceTrack 类主要用来控制游戏中的路径。它负责路径的载入,绘制,碰撞检测和控制当前在跑的赛车。
- class cRaceTrack
- {
- private:
-
- // 当前赛道上的赛车数目
- int m_iNumCars;
- // 赛道的行数和列数,每一单元都是40x40贴图
- int m_iCols;
- int m_iRows;
- // 可视的赛道数
- int m_iViewY;
- int m_iViewX;
- // 需要完成的圈数
- int m_iLaps;
- // 赛道名称
- char *m_sTrackName;
- // 状态变量:用来表示比赛是否开始,用来控制比赛开始时的信号灯显示
- // 如果这个值是0,则显示第一个信号,如果是2,则显示第二个信号,当值为2之后的m_lStartTime时间后,就不再绘制信号灯
- int m_iState;
- long m_lStartTime;
- // 使用哪种贴片(沙漠或者草地)
- UINT m_Tile;
- //赛道中用到的贴片曲面
- cSurface m_surfTile;
- //比赛结束时旗帜的曲面
- cSurface m_surfRaceCompleted;
- //下面所有定义的曲面都代表了一种赛道贴片
- cSurface m_surfDiagonalQ0;
- cSurface m_surfDiagonalQ1;
- cSurface m_surfDiagonalQ2;
- cSurface m_surfDiagonalQ3;
- cSurface m_surfMidDiagonalQ0;
- cSurface m_surfMidDiagonalQ1;
- cSurface m_surfMidDiagonalQ2;
- cSurface m_surfMidDiagonalQ3;
- cSurface m_surfBlackPointQ0;
- cSurface m_surfBlackPointQ1;
- cSurface m_surfBlackPointQ2;
- cSurface m_surfBlackPointQ3;
- cSurface m_surf_HZ_StartDiagonalQ0;
- cSurface m_surf_HZ_StartDiagonalQ1;
- cSurface m_surf_HZ_StartDiagonalQ2;
- cSurface m_surf_HZ_StartDiagonalQ3;
- cSurface m_surf_HZ_EndDiagonalQ0;
- cSurface m_surf_HZ_EndDiagonalQ1;
- cSurface m_surf_HZ_EndDiagonalQ2;
- cSurface m_surf_HZ_EndDiagonalQ3;
- cSurface m_surf_VR_StartDiagonalQ0;
- cSurface m_surf_VR_StartDiagonalQ1;
- cSurface m_surf_VR_StartDiagonalQ2;
- cSurface m_surf_VR_StartDiagonalQ3;
- cSurface m_surf_VR_EndDiagonalQ0;
- cSurface m_surf_VR_EndDiagonalQ1;
- cSurface m_surf_VR_EndDiagonalQ2;
- cSurface m_surf_VR_EndDiagonalQ3;
- cSurface m_surfSRaceRoadQ0;
- cSurface m_surfSRaceRoadQ1;
- cSurface m_surfSRaceRoadQ2;
- cSurface m_surfSRaceRoadQ3;
- cSurface m_surfHalfRoadQ0;
- cSurface m_surfHalfRoadQ1;
- cSurface m_surfHalfRoadQ2;
- cSurface m_surfHalfRoadQ3;
- cSurface m_surfFullRoadQ0;
- cSurface m_surfFullRoadQ1;
- cSurface m_surfFullRoadQ2;
- cSurface m_surfFullRoadQ3;
- cSurface m_surfFullRoadQ4;
- cSurface m_surfFullRoadQ5;
- cSurface m_surfFullRoadQ6;
- cSurface m_surfFullRoadQ7;
- cSurface m_surfFullRoadQ8;
- cSurface m_surfFullRoadQ9;
- cSurface m_surfFullRoadQ10;
- cSurface m_surfFullRoadQ11;
- cSurface m_surfFullRoadQ12;
- cSurface m_surfFullRoadQ13;
- cSurface m_surfFullRoadQ14;
- cSurface m_surfFullRoadQ15;
- cSurface m_surfFullRoadQ16;
- cSurface m_surfFullRoadQ17;
- cSurface m_surfCurveQ0;
- cSurface m_surfCurveQ1;
- cSurface m_surfCurveQ2;
- cSurface m_surfCurveQ3;
- cSurface m_surfEndCurveQ0;
- cSurface m_surfEndCurveQ1;
- cSurface m_surfEndCurveQ2;
- cSurface m_surfEndCurveQ3;
- cSurface m_surfMediumCurveQ0P1;
- cSurface m_surfMediumCurveQ0P2;
- cSurface m_surfMediumCurveQ0P3;
- cSurface m_surfMediumCurveQ1P1;
- cSurface m_surfMediumCurveQ1P2;
- cSurface m_surfMediumCurveQ1P3;
- cSurface m_surfMediumCurveQ2P1;
- cSurface m_surfMediumCurveQ2P2;
- cSurface m_surfMediumCurveQ2P3;
- cSurface m_surfMediumCurveQ3P1;
- cSurface m_surfMediumCurveQ3P2;
- cSurface m_surfMediumCurveQ3P3;
-
- cSurface m_surfEndMediumCurveQ0P1;
- cSurface m_surfEndMediumCurveQ0P2;
- cSurface m_surfEndMediumCurveQ0P3;
- cSurface m_surfEndMediumCurveQ1P1;
- cSurface m_surfEndMediumCurveQ1P2;
- cSurface m_surfEndMediumCurveQ1P3;
- cSurface m_surfEndMediumCurveQ2P1;
- cSurface m_surfEndMediumCurveQ2P2;
- cSurface m_surfEndMediumCurveQ2P3;
- cSurface m_surfEndMediumCurveQ3P1;
- cSurface m_surfEndMediumCurveQ3P2;
- cSurface m_surfEndMediumCurveQ3P3;
- //这个函数用来删除在赛道的主碰撞检测区域的每个贴片多边形区域
- void RemoveHitRegion();
- public:
- //这个精灵控制信号灯的动画
- cSprite m_sptrWait;
- //这是赛车数组,它代表了当前赛道中比赛的所有赛车,对于每一次的比赛,我们都需要将所有赛车加入到这个数组中
- cRaceCar* m_pRaceCars[4];
- // 这个矩阵拥有赛道中所有贴片信息
- cMatrix m_RoadMap;
- // 这个碰撞类拥有赛道中所有有效区域的信息。如果有车碰到了无效区域,则它要爆炸
- cHitChecker m_hcRoadMap;
- // 信号灯的声音缓冲
- cSound m_sndSemaphore;
-
- BYTE GetLocalCarID();
- void SetRemoteKeyboardStatus(BYTE bIdCar, BYTE bStatus);
- int GetAngle(int iCol, int iRow);
- void SetCarInfo(BYTE bID, BYTE bMask,
- DWORD dwElapseTime,
- BYTE bLaps,
- int iSpeed,
- BYTE bCarPosition,
- DWORD dwLastLapTime,
- unsigned short nCarX,
- unsigned short nCarY,
- BYTE bAngle,
- BYTE bCarState);
- char* GetFileName();
- string m_sFileName;
- int GetHeight();
- int GetWidth();
- cRaceCar* GetCar(int iPos);
- int GetNumberOfCars();
- int GetNumberOfLaps();
- char* GetTrackName();
- void GetCheckPointPosition(int *iX, int* iY,int iCheckPoint);
- // int TurnDirection(int iX, int iY, int iAngle);
- int GetRoadType(int iX, int iY);
- void AddCar(cRaceCar* pCar);
- void Process();
- int m_iMaxCheckPoint;
- int GetMaxCheckPoint();
- int GetCheckPoint(int iX, int iY);
- BOOL CarHittedRoad(cRaceCar* pCar, int iX = -1, int iY = -1);
- int GetViewY();
- int GetViewX();
- void AdjustView(cRaceCar* pPar);
- void GetStartPosition(int* iX, int* iY);
-
- BOOL ReadFromFile(char* lpszFile);
- void SetRoad(int iCol, int iRow, int iType);
- void Draw(int iDestX = 0, int iDestY = 0, int nX =-1 , int nY =-1 , int nWidth = 640, int nHeight = 480);
- void Destroy(BOOL bLastDestroy = FALSE);
- //cSurface m_surfMap;
- void SetTile(UINT iTile);
- void Create(int nWidth, int nHeight);
- cRaceTrack();
- virtual ~cRaceTrack();
- };
- #endif // !defined(AFX_CRACETRACK_H__2022F72B_F3CD_47F7_904E_11F2297090EE__INCLUDED_)