cRaceTrack.cpp
上传用户:sycq158
上传日期:2008-10-22
资源大小:15361k
文件大小:72k
源码类别:

游戏

开发平台:

Visual C++

  1. // RACE X
  2. //
  3. // Written by Mauricio Teichmann Ritter
  4. //
  5. // Copyright (C) 2002, Brazil. All rights reserved.
  6. // 
  7. //
  8. #include "stdafx.h"
  9. #include "RaceX.h"
  10. #include "cRaceTrack.h"
  11. #include ".applibcapplication.h"
  12. #include <stdio.h>
  13. #include <search.h>
  14. #include <math.h>
  15. //////////////////////////////////////////////////////////////////////
  16. // Construction/Destruction
  17. //////////////////////////////////////////////////////////////////////
  18. cRaceTrack::cRaceTrack()
  19. {
  20. m_iCols = 0;
  21. m_iRows = 0;
  22. m_iViewX = 0;
  23. m_iViewY = 0;
  24. m_iNumCars = 0;
  25. m_pRaceCars[0] = NULL;
  26. m_pRaceCars[1] = NULL;
  27. m_pRaceCars[2] = NULL;
  28. m_pRaceCars[3] = NULL;
  29. m_iMaxCheckPoint = 0;
  30. m_sTrackName = NULL;
  31. m_iLaps = 0;
  32. }
  33. cRaceTrack::~cRaceTrack()
  34. {
  35. }
  36. void cRaceTrack::Create(int nWidth, int nHeight)
  37. {
  38. m_iState = 0;
  39. m_lStartTime = 0;
  40. // 创建拥有赛道贴片数据的数组
  41. m_RoadMap.Create(nWidth,nHeight);
  42. // 创建碰撞检测矩形区域
  43. m_hcRoadMap.CreateRectBound(nWidth * 40, nHeight * 40);
  44. // 初始化宽度和高度变量
  45. m_iCols = nWidth;
  46. m_iRows = nHeight;
  47. static BOOL IsLoaded = FALSE;
  48. if(!IsLoaded)
  49. {
  50. // 初始化信号灯声音
  51. m_sndSemaphore.Create(MAKEINTRESOURCE(IDR_SEMAPHORE), DSBCAPS_CTRL3D, DS3DALG_NO_VIRTUALIZATION);
  52. m_sndSemaphore.m_pSoundBuffer->SetCurrentPosition( 0 );
  53. IsLoaded = TRUE;
  54. }
  55. }
  56. void cRaceTrack::SetTile(UINT iTile)
  57. {
  58. //载入碰撞贴片到曲面:草贴片或者沙漠贴片
  59. m_surfTile.Create(200,200);
  60. switch(iTile)
  61. {
  62. case 1:
  63. m_surfTile.LoadBitmap(GetMainApp()->m_hInst, IDB_TILE_GRASS, 0, 0, 200, 200);
  64. break;
  65. case 2:
  66. m_surfTile.LoadBitmap(GetMainApp()->m_hInst, IDB_TILE_SAND, 0, 0, 200, 200);
  67. break;
  68. }
  69. }
  70. void cRaceTrack::Destroy(BOOL bLastDestroy)
  71. {
  72. // Clean up everything
  73. m_surfTile.Destroy();
  74. m_surfDiagonalQ0.Destroy();
  75. m_surfDiagonalQ1.Destroy();
  76. m_surfDiagonalQ2.Destroy();
  77. m_surfDiagonalQ3.Destroy();
  78. m_surfMidDiagonalQ0.Destroy();
  79. m_surfMidDiagonalQ1.Destroy();
  80. m_surfMidDiagonalQ2.Destroy();
  81. m_surfMidDiagonalQ3.Destroy();
  82. m_surfBlackPointQ0.Destroy();
  83. m_surfBlackPointQ1.Destroy();
  84. m_surfBlackPointQ2.Destroy();
  85. m_surfBlackPointQ3.Destroy();
  86. m_surf_HZ_StartDiagonalQ0.Destroy();
  87. m_surf_HZ_StartDiagonalQ1.Destroy();
  88. m_surf_HZ_StartDiagonalQ2.Destroy();
  89. m_surf_HZ_StartDiagonalQ3.Destroy();
  90. m_surf_HZ_EndDiagonalQ0.Destroy();
  91. m_surf_HZ_EndDiagonalQ1.Destroy();
  92. m_surf_HZ_EndDiagonalQ2.Destroy();
  93. m_surf_HZ_EndDiagonalQ3.Destroy();
  94. m_surf_VR_StartDiagonalQ0.Destroy();
  95. m_surf_VR_StartDiagonalQ1.Destroy();
  96. m_surf_VR_StartDiagonalQ2.Destroy();
  97. m_surf_VR_StartDiagonalQ3.Destroy();
  98. m_surf_VR_EndDiagonalQ0.Destroy();
  99. m_surf_VR_EndDiagonalQ1.Destroy();
  100. m_surf_VR_EndDiagonalQ2.Destroy();
  101. m_surf_VR_EndDiagonalQ3.Destroy();
  102. m_surfSRaceRoadQ0.Destroy();
  103. m_surfSRaceRoadQ1.Destroy();
  104. m_surfSRaceRoadQ2.Destroy();
  105. m_surfSRaceRoadQ3.Destroy();
  106. m_surfHalfRoadQ0.Destroy();
  107. m_surfHalfRoadQ1.Destroy();
  108. m_surfHalfRoadQ2.Destroy();
  109. m_surfHalfRoadQ3.Destroy();
  110. m_surfCurveQ0.Destroy();
  111. m_surfCurveQ1.Destroy();
  112. m_surfCurveQ2.Destroy();
  113. m_surfCurveQ3.Destroy();
  114. m_surfEndCurveQ0.Destroy();
  115. m_surfEndCurveQ1.Destroy();
  116. m_surfEndCurveQ2.Destroy();
  117. m_surfEndCurveQ3.Destroy();
  118. m_surfFullRoadQ0.Destroy();
  119. m_surfFullRoadQ1.Destroy();
  120. m_surfFullRoadQ2.Destroy();
  121. m_surfFullRoadQ3.Destroy();
  122. m_surfFullRoadQ4.Destroy();
  123. m_surfFullRoadQ5.Destroy();
  124. m_surfFullRoadQ6.Destroy();
  125. m_surfFullRoadQ7.Destroy();
  126. m_surfFullRoadQ8.Destroy();
  127. m_surfFullRoadQ9.Destroy();
  128. m_surfFullRoadQ10.Destroy();
  129. m_surfFullRoadQ11.Destroy();
  130. m_surfFullRoadQ12.Destroy();
  131. m_surfFullRoadQ13.Destroy();
  132. m_surfFullRoadQ14.Destroy();
  133. m_surfFullRoadQ15.Destroy();
  134. m_surfFullRoadQ16.Destroy();
  135. m_surfFullRoadQ17.Destroy();
  136. m_surfMediumCurveQ0P1.Destroy();
  137. m_surfMediumCurveQ1P1.Destroy();
  138. m_surfMediumCurveQ2P1.Destroy();
  139. m_surfMediumCurveQ3P1.Destroy();
  140. m_surfMediumCurveQ0P2.Destroy();
  141. m_surfMediumCurveQ1P2.Destroy();
  142. m_surfMediumCurveQ2P2.Destroy();
  143. m_surfMediumCurveQ3P2.Destroy();
  144. m_surfMediumCurveQ0P3.Destroy();
  145. m_surfMediumCurveQ1P3.Destroy();
  146. m_surfMediumCurveQ2P3.Destroy();
  147. m_surfMediumCurveQ3P3.Destroy();
  148. m_surfEndMediumCurveQ0P1.Destroy();
  149. m_surfEndMediumCurveQ1P1.Destroy();
  150. m_surfEndMediumCurveQ2P1.Destroy();
  151. m_surfEndMediumCurveQ3P1.Destroy();
  152. m_surfEndMediumCurveQ0P2.Destroy();
  153. m_surfEndMediumCurveQ1P2.Destroy();
  154. m_surfEndMediumCurveQ2P2.Destroy();
  155. m_surfEndMediumCurveQ3P2.Destroy();
  156. m_surfEndMediumCurveQ0P3.Destroy();
  157. m_surfEndMediumCurveQ1P3.Destroy();
  158. m_surfEndMediumCurveQ2P3.Destroy();
  159. m_surfEndMediumCurveQ3P3.Destroy();
  160. //m_surfMap.Destroy();
  161. m_RoadMap.Destroy();
  162. m_sptrWait.Destroy();
  163. m_hcRoadMap.Destroy();
  164. m_surfRaceCompleted.Destroy();
  165. // Destroy all the cars also
  166. for(int i=0;i<m_iNumCars;i++)
  167. {
  168. m_pRaceCars[i]->Destroy();
  169. }
  170. if(m_sTrackName != NULL)
  171. {
  172. free(m_sTrackName);
  173. m_sTrackName = NULL;
  174. }
  175. m_iCols = 0;
  176. m_iRows = 0;
  177. m_iViewX = 0;
  178. m_iViewY = 0;
  179. m_iNumCars = 0;
  180. m_pRaceCars[0] = NULL;
  181. m_pRaceCars[1] = NULL;
  182. m_pRaceCars[2] = NULL;
  183. m_pRaceCars[3] = NULL;
  184. m_iMaxCheckPoint = 0;
  185. m_sTrackName = NULL;
  186. m_iLaps = 0;
  187. if(bLastDestroy)
  188. m_sndSemaphore.Destroy();
  189. }
  190. // 这个函数用来在屏幕中绘制赛道
  191. void cRaceTrack::Draw(int iDestX, int iDestY, int nX, int nY, int nWidth, int nHeight)
  192. {
  193. // First we create to reference variables, to know in which position we磖e
  194. // gonna draw the track
  195. // If we receive the nX and nY parameters we磍l draw the track using these
  196. // values (this is used in the select track screen)
  197. // If we don磘 inform this values, we磍l use the current view of the player
  198. // that are stored in the m_iView variables
  199. int iRefX, iRefY;
  200. if(nX == -1)
  201. {
  202. iRefX = m_iViewX;
  203. iRefY = m_iViewY;
  204. }
  205. else
  206. {
  207. iRefX = nX;
  208. iRefY = nY;
  209. }
  210. #define TILE_SIZE 200
  211. #define ITEM_SIZE 40
  212. int iSizeX, iSizeY;
  213. int iTmpX = iDestX, iTmpY = iDestY;
  214. // First we磍l start drawing the tile
  215. // We need to draw the tile based on the current view of the iRef variables
  216. while(iTmpX < iDestX+nWidth)
  217. {
  218. while(iTmpY < iDestY+nHeight)
  219. {
  220. if(iTmpX+TILE_SIZE > iDestX+nWidth)
  221. iSizeX = TILE_SIZE - ((iTmpX+TILE_SIZE)-(iDestX+nWidth));
  222. else
  223. iSizeX = TILE_SIZE;
  224. if(iTmpY+TILE_SIZE > iDestY+nHeight)
  225. iSizeY = TILE_SIZE - ((iTmpY+TILE_SIZE)-(iDestY+nHeight));
  226. else
  227. iSizeY = TILE_SIZE;
  228. m_surfTile.Draw(GetMainApp()->m_pBackBuffer, iTmpX, iTmpY, iRefX % TILE_SIZE, iRefY % TILE_SIZE, iSizeX-(iRefX % TILE_SIZE), iSizeY-(iRefY % TILE_SIZE));
  229. iTmpY += TILE_SIZE - iRefY % TILE_SIZE;
  230. iRefY = 0;
  231. }
  232. iTmpX += TILE_SIZE - iRefX % TILE_SIZE;
  233. iTmpY = iDestY;
  234. if(nX == -1)
  235. {
  236. iRefY = m_iViewY;
  237. }
  238. else
  239. {
  240. iRefY = nY;
  241. }
  242. iRefX = 0;
  243. }
  244. int iItemX, iItemY;
  245. iTmpX = iDestX;
  246. iTmpY = iDestY;
  247. // Reset the iRef variables (since we use it in the loop to draw the tiles)
  248. if(nX == -1)
  249. {
  250. iRefX = m_iViewX;
  251. iRefY = m_iViewY;
  252. }
  253. else
  254. {
  255. iRefX = nX;
  256. iRefY = nY;
  257. }
  258. // Based on the tile matrix, we磍l identify which tiles are visible to the
  259. // currently view
  260. // The ItemX and ItemY will hold the Column and Row of the first visible
  261. // tile
  262. iItemX = iRefX / ITEM_SIZE;
  263. iItemY = iRefY / ITEM_SIZE;
  264. // The iMaxCol and iMaxRow will hold the maximum column and row that we need
  265. // to show to the user
  266. int iMaxCol = ceil((double)iRefX / ITEM_SIZE)+ceil((double)nWidth/(double)ITEM_SIZE);
  267. int iMaxRow = ceil((double)iRefY / ITEM_SIZE)+ceil((double)nHeight/(double)ITEM_SIZE);
  268. if(iMaxCol > m_iCols)
  269. iMaxCol = m_iCols;
  270. if(iMaxRow > m_iRows)
  271. iMaxRow = m_iRows;
  272. // Now we磍l loop based on the first visible Column and Row (iItemX and iItemY)
  273. // and based on the iMaxCol and iMaxRow
  274. for(int iCol = iItemX;iCol<iMaxCol;iCol++)
  275. {
  276. for(int iRow = iItemY;iRow<iMaxRow;iRow++)
  277. {
  278. // If we have a tile associated with the current position
  279. // of the iteration, draw it.
  280. if(m_RoadMap.GetValue(iCol,iRow) != 0)
  281. {
  282. if(iTmpX+ITEM_SIZE > iDestX+nWidth)
  283. iSizeX = ITEM_SIZE - ((iTmpX+ITEM_SIZE)-(iDestX+nWidth));
  284. else
  285. iSizeX = ITEM_SIZE;
  286. if(iTmpY+ITEM_SIZE > iDestY+nHeight)
  287. iSizeY = ITEM_SIZE - ((iTmpY+ITEM_SIZE)-(iDestY+nHeight));
  288. else
  289. iSizeY = ITEM_SIZE;
  290. // The Road type is the LOWORD portion of the DWORD array
  291. int iType = LOWORD(m_RoadMap.GetValue(iCol,iRow));
  292. if(iSizeX > 0 && iSizeY > 0)
  293. {
  294. // Based on the Road Type, draw the tile in the correct position
  295. switch(iType + ID_ROADTYPE_SRACEROADQ0 - 1)
  296. {
  297. case ID_ROADTYPE_DIAGONALQ0:
  298. m_surfDiagonalQ0.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  299. break;
  300. case ID_ROADTYPE_DIAGONALQ1:
  301. m_surfDiagonalQ1.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  302. break;
  303. case ID_ROADTYPE_DIAGONALQ2:
  304. m_surfDiagonalQ2.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  305. break;
  306. case ID_ROADTYPE_DIAGONALQ3:
  307. m_surfDiagonalQ3.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  308. break;
  309. case ID_ROADTYPE_MIDDIAGONALQ0:
  310. m_surfMidDiagonalQ0.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  311. break;
  312. case ID_ROADTYPE_MIDDIAGONALQ1:
  313. m_surfMidDiagonalQ1.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  314. break;
  315. case ID_ROADTYPE_MIDDIAGONALQ2:
  316. m_surfMidDiagonalQ2.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  317. break;
  318. case ID_ROADTYPE_MIDDIAGONALQ3:
  319. m_surfMidDiagonalQ3.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  320. break;
  321. case ID_ROADTYPE_BLACKPOINTQ0:
  322. m_surfBlackPointQ0.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  323. break;
  324. case ID_ROADTYPE_BLACKPOINTQ1:
  325. m_surfBlackPointQ1.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  326. break;
  327. case ID_ROADTYPE_BLACKPOINTQ2:
  328. m_surfBlackPointQ2.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  329. break;
  330. case ID_ROADTYPE_BLACKPOINTQ3:
  331. m_surfBlackPointQ3.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  332. break;
  333. case ID_ROADTYPE_HZ_STARTDIAGONALQ0:
  334. m_surf_HZ_StartDiagonalQ0.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  335. break;
  336. case ID_ROADTYPE_HZ_STARTDIAGONALQ1:
  337. m_surf_HZ_StartDiagonalQ1.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  338. break;
  339. case ID_ROADTYPE_HZ_STARTDIAGONALQ2:
  340. m_surf_HZ_StartDiagonalQ2.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  341. break;
  342. case ID_ROADTYPE_HZ_STARTDIAGONALQ3:
  343. m_surf_HZ_StartDiagonalQ3.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  344. break;
  345. case ID_ROADTYPE_VR_STARTDIAGONALQ0:
  346. m_surf_VR_StartDiagonalQ0.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  347. break;
  348. case ID_ROADTYPE_VR_STARTDIAGONALQ1:
  349. m_surf_VR_StartDiagonalQ1.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  350. break;
  351. case ID_ROADTYPE_VR_STARTDIAGONALQ2:
  352. m_surf_VR_StartDiagonalQ2.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  353. break;
  354. case ID_ROADTYPE_VR_STARTDIAGONALQ3:
  355. m_surf_VR_StartDiagonalQ3.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  356. break;
  357. case ID_ROADTYPE_HZ_ENDDIAGONALQ0:
  358. m_surf_HZ_EndDiagonalQ0.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  359. break;
  360. case ID_ROADTYPE_HZ_ENDDIAGONALQ1:
  361. m_surf_HZ_EndDiagonalQ1.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  362. break;
  363. case ID_ROADTYPE_HZ_ENDDIAGONALQ2:
  364. m_surf_HZ_EndDiagonalQ2.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  365. break;
  366. case ID_ROADTYPE_HZ_ENDDIAGONALQ3:
  367. m_surf_HZ_EndDiagonalQ3.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  368. break;
  369. case ID_ROADTYPE_VR_ENDDIAGONALQ0:
  370. m_surf_VR_EndDiagonalQ0.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  371. break;
  372. case ID_ROADTYPE_VR_ENDDIAGONALQ1:
  373. m_surf_VR_EndDiagonalQ1.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  374. break;
  375. case ID_ROADTYPE_VR_ENDDIAGONALQ2:
  376. m_surf_VR_EndDiagonalQ2.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  377. break;
  378. case ID_ROADTYPE_VR_ENDDIAGONALQ3:
  379. m_surf_VR_EndDiagonalQ3.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  380. break;
  381. case ID_ROADTYPE_SRACEROADQ0:
  382. m_surfSRaceRoadQ0.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  383. break;
  384. case ID_ROADTYPE_SRACEROADQ1:
  385.   m_surfSRaceRoadQ1.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  386. break;
  387. case ID_ROADTYPE_SRACEROADQ2:
  388. m_surfSRaceRoadQ2.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  389. break;
  390. case ID_ROADTYPE_SRACEROADQ3:
  391. m_surfSRaceRoadQ3.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  392. break;
  393. case ID_ROADTYPE_ROADQ0:
  394. m_surfHalfRoadQ0.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  395. break;
  396. case ID_ROADTYPE_ROADQ1:
  397. m_surfHalfRoadQ1.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  398. break;
  399. case ID_ROADTYPE_ROADQ2:
  400. m_surfHalfRoadQ2.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  401. break;
  402. case ID_ROADTYPE_ROADQ3:
  403. m_surfHalfRoadQ3.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  404. break;
  405. case ID_ROADTYPE_CURVEQ0:
  406. m_surfCurveQ0.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  407. break;
  408. case ID_ROADTYPE_CURVEQ1:
  409. m_surfCurveQ1.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  410. break;
  411. case ID_ROADTYPE_CURVEQ2:
  412. m_surfCurveQ2.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  413. break;
  414. case ID_ROADTYPE_CURVEQ3:
  415. m_surfCurveQ3.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  416. break;
  417. case ID_ROADTYPE_ENDCURVEQ0:
  418. m_surfEndCurveQ0.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  419. break;
  420. case ID_ROADTYPE_ENDCURVEQ1:
  421. m_surfEndCurveQ1.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  422. break;
  423. case ID_ROADTYPE_ENDCURVEQ2:
  424. m_surfEndCurveQ2.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  425. break;
  426. case ID_ROADTYPE_ENDCURVEQ3:
  427. m_surfEndCurveQ3.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  428. break;
  429. case ID_ROADTYPE_FULLROADQ0:
  430. m_surfFullRoadQ0.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  431. break;
  432. case ID_ROADTYPE_FULLROADQ1:
  433. m_surfFullRoadQ1.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  434. break;
  435. case ID_ROADTYPE_FULLROADQ2:
  436. m_surfFullRoadQ2.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  437. break;
  438. case ID_ROADTYPE_FULLROADQ3:
  439. m_surfFullRoadQ3.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  440. break;
  441. case ID_ROADTYPE_FULLROADQ4:
  442. m_surfFullRoadQ4.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  443. break;
  444. case ID_ROADTYPE_FULLROADQ5:
  445. m_surfFullRoadQ5.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  446. break;
  447. case ID_ROADTYPE_FULLROADQ6:
  448. m_surfFullRoadQ6.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  449. break;
  450. case ID_ROADTYPE_FULLROADQ7:
  451. m_surfFullRoadQ7.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  452. break;
  453. case ID_ROADTYPE_FULLROADQ8:
  454. m_surfFullRoadQ8.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  455. break;
  456. case ID_ROADTYPE_FULLROADQ9:
  457. m_surfFullRoadQ9.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  458. break;
  459. case ID_ROADTYPE_FULLROADQ10:
  460. m_surfFullRoadQ10.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  461. break;
  462. case ID_ROADTYPE_FULLROADQ11:
  463. m_surfFullRoadQ11.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  464. break;
  465. case ID_ROADTYPE_FULLROADQ12:
  466. m_surfFullRoadQ12.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  467. break;
  468. case ID_ROADTYPE_FULLROADQ13:
  469. m_surfFullRoadQ13.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  470. break;
  471. case ID_ROADTYPE_FULLROADQ14:
  472. m_surfFullRoadQ14.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  473. break;
  474. case ID_ROADTYPE_FULLROADQ15:
  475. m_surfFullRoadQ15.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  476. break;
  477. case ID_ROADTYPE_FULLROADQ16:
  478. m_surfFullRoadQ16.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  479. break;
  480. case ID_ROADTYPE_FULLROADQ17:
  481. m_surfFullRoadQ17.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  482. break;
  483. case ID_ROADTYPE_MEDIUMCURVEQ0P1:
  484. m_surfMediumCurveQ0P1.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  485. break;
  486. case ID_ROADTYPE_MEDIUMCURVEQ0P2:
  487. m_surfMediumCurveQ0P2.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  488. break;
  489. case ID_ROADTYPE_MEDIUMCURVEQ0P3:
  490. m_surfMediumCurveQ0P3.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  491. break;
  492. case ID_ROADTYPE_MEDIUMCURVEQ1P1:
  493. m_surfMediumCurveQ1P1.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  494. break;
  495. case ID_ROADTYPE_MEDIUMCURVEQ1P2:
  496. m_surfMediumCurveQ1P2.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  497. break;
  498. case ID_ROADTYPE_MEDIUMCURVEQ1P3:
  499. m_surfMediumCurveQ1P3.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  500. break;
  501. case ID_ROADTYPE_MEDIUMCURVEQ2P1:
  502. m_surfMediumCurveQ2P1.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  503. break;
  504. case ID_ROADTYPE_MEDIUMCURVEQ2P2:
  505. m_surfMediumCurveQ2P2.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  506. break;
  507. case ID_ROADTYPE_MEDIUMCURVEQ2P3:
  508. m_surfMediumCurveQ2P3.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  509. break;
  510. case ID_ROADTYPE_MEDIUMCURVEQ3P1:
  511. m_surfMediumCurveQ3P1.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  512. break;
  513. case ID_ROADTYPE_MEDIUMCURVEQ3P2:
  514. m_surfMediumCurveQ3P2.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  515. break;
  516. case ID_ROADTYPE_MEDIUMCURVEQ3P3:
  517. m_surfMediumCurveQ3P3.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  518. break;
  519. case ID_ROADTYPE_ENDMEDIUMCURVEQ0P1:
  520. m_surfEndMediumCurveQ0P1.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  521. break;
  522. case ID_ROADTYPE_ENDMEDIUMCURVEQ0P2:
  523. m_surfEndMediumCurveQ0P2.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  524. break;
  525. case ID_ROADTYPE_ENDMEDIUMCURVEQ0P3:
  526. m_surfEndMediumCurveQ0P3.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  527. break;
  528. case ID_ROADTYPE_ENDMEDIUMCURVEQ1P1:
  529. m_surfEndMediumCurveQ1P1.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  530. break;
  531. case ID_ROADTYPE_ENDMEDIUMCURVEQ1P2:
  532. m_surfEndMediumCurveQ1P2.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  533. break;
  534. case ID_ROADTYPE_ENDMEDIUMCURVEQ1P3:
  535. m_surfEndMediumCurveQ1P3.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  536. break;
  537. case ID_ROADTYPE_ENDMEDIUMCURVEQ2P1:
  538. m_surfEndMediumCurveQ2P1.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  539. break;
  540. case ID_ROADTYPE_ENDMEDIUMCURVEQ2P2:
  541. m_surfEndMediumCurveQ2P2.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  542. break;
  543. case ID_ROADTYPE_ENDMEDIUMCURVEQ2P3:
  544. m_surfEndMediumCurveQ2P3.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  545. break;
  546. case ID_ROADTYPE_ENDMEDIUMCURVEQ3P1:
  547. m_surfEndMediumCurveQ3P1.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  548. break;
  549. case ID_ROADTYPE_ENDMEDIUMCURVEQ3P2:
  550. m_surfEndMediumCurveQ3P2.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  551. break;
  552. case ID_ROADTYPE_ENDMEDIUMCURVEQ3P3:
  553. m_surfEndMediumCurveQ3P3.Draw(GetMainApp()->m_pBackBuffer,iTmpX, iTmpY, iRefX % ITEM_SIZE, iRefY % ITEM_SIZE, iSizeX-(iRefX % ITEM_SIZE), iSizeY-(iRefY % ITEM_SIZE) );
  554. break;
  555. }
  556. }
  557. }
  558. iTmpY += ITEM_SIZE - iRefY % ITEM_SIZE;
  559. iRefY = 0;
  560. }
  561. iTmpX += ITEM_SIZE - iRefX % ITEM_SIZE;
  562. iTmpY = iDestY;
  563. if(nX == -1)
  564. {
  565. iRefY = m_iViewY;
  566. }
  567. else
  568. {
  569. iRefY = nY;
  570. }
  571. iRefX = 0;
  572. }
  573. }
  574. void cRaceTrack::SetRoad(int iCol, int iRow, int iType)
  575. {
  576. // Set something in the Road Map (just used for testing, we use track files);
  577. m_RoadMap.SetValue(iCol, iRow, MAKELONG(iType,0));
  578. }
  579. void cRaceTrack::RemoveHitRegion()
  580. {
  581. //载入一组曲面,用来构建赛道地图,每个曲面代表一个道路贴片
  582. // 开始比赛的旗帜曲面
  583. m_surfSRaceRoadQ0.Create(40,40, RGB(255,255,255));
  584. m_surfSRaceRoadQ0.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_SRACEROADQ0, 0, 0, 40, 40);
  585. m_surfSRaceRoadQ1.Create(40,40, RGB(255,255,255));
  586. m_surfSRaceRoadQ1.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_SRACEROADQ1, 0, 0, 40, 40);
  587. m_surfSRaceRoadQ2.Create(40,40, RGB(255,255,255));
  588. m_surfSRaceRoadQ2.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_SRACEROADQ2, 0, 0, 40, 40);
  589. m_surfSRaceRoadQ3.Create(40,40, RGB(255,255,255));
  590. m_surfSRaceRoadQ3.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_SRACEROADQ3, 0, 0, 40, 40);
  591. // 一半赛道的曲面
  592. m_surfHalfRoadQ0.Create(40,40, RGB(255, 255, 255));
  593. m_surfHalfRoadQ0.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_ROADQ0, 0, 0, 40, 40);
  594. m_surfHalfRoadQ1.Create(40,40, RGB(255, 255, 255));
  595. m_surfHalfRoadQ1.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_ROADQ1, 0, 0, 40, 40);
  596. m_surfHalfRoadQ2.Create(40,40, RGB(255, 255, 255));
  597. m_surfHalfRoadQ2.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_ROADQ2, 0, 0, 40, 40);
  598. m_surfHalfRoadQ3.Create(40,40, RGB(255, 255, 255));
  599. m_surfHalfRoadQ3.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_ROADQ3, 0, 0, 40, 40);
  600. m_surfFullRoadQ0.Create(40,40);
  601. m_surfFullRoadQ0.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_FULLROADQ0, 0, 0, 40, 40);
  602. m_surfFullRoadQ1.Create(40,40);
  603. m_surfFullRoadQ1.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_FULLROADQ1, 0, 0, 40, 40);
  604. m_surfFullRoadQ2.Create(40,40);
  605. m_surfFullRoadQ2.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_FULLROADQ2, 0, 0, 40, 40);
  606. m_surfFullRoadQ3.Create(40,40);
  607. m_surfFullRoadQ3.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_FULLROADQ3, 0, 0, 40, 40);
  608. m_surfFullRoadQ4.Create(40,40);
  609. m_surfFullRoadQ4.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_FULLROADQ4, 0, 0, 40, 40);
  610. m_surfFullRoadQ5.Create(40,40);
  611. m_surfFullRoadQ5.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_FULLROADQ5, 0, 0, 40, 40);
  612. m_surfFullRoadQ6.Create(40,40);
  613. m_surfFullRoadQ6.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_FULLROADQ6, 0, 0, 40, 40);
  614. m_surfFullRoadQ7.Create(40,40);
  615. m_surfFullRoadQ7.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_FULLROADQ7, 0, 0, 40, 40);
  616. m_surfFullRoadQ8.Create(40,40);
  617. m_surfFullRoadQ8.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_FULLROADQ8, 0, 0, 40, 40);
  618. m_surfFullRoadQ9.Create(40,40);
  619. m_surfFullRoadQ9.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_FULLROADQ9, 0, 0, 40, 40);
  620. m_surfFullRoadQ10.Create(40,40);
  621. m_surfFullRoadQ10.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_FULLROADQ10, 0, 0, 40, 40);
  622. m_surfFullRoadQ11.Create(40,40);
  623. m_surfFullRoadQ11.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_FULLROADQ11, 0, 0, 40, 40);
  624. m_surfFullRoadQ12.Create(40,40);
  625. m_surfFullRoadQ12.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_FULLROADQ12, 0, 0, 40, 40);
  626. m_surfFullRoadQ13.Create(40,40);
  627. m_surfFullRoadQ13.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_FULLROADQ13, 0, 0, 40, 40);
  628. m_surfFullRoadQ14.Create(40,40);
  629. m_surfFullRoadQ14.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_FULLROADQ14, 0, 0, 40, 40);
  630. m_surfFullRoadQ15.Create(40,40);
  631. m_surfFullRoadQ15.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_FULLROADQ15, 0, 0, 40, 40);
  632. m_surfFullRoadQ16.Create(40,40);
  633. m_surfFullRoadQ16.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_FULLROADQ16, 0, 0, 40, 40);
  634. m_surfFullRoadQ17.Create(40,40);
  635. m_surfFullRoadQ17.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_FULLROADQ17, 0, 0, 40, 40);
  636. m_surfCurveQ0.Create(40,40, RGB(255, 255, 255));
  637. m_surfCurveQ0.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_CURVEQ0, 0, 0, 40, 40);
  638. m_surfCurveQ1.Create(40,40, RGB(255, 255, 255));
  639. m_surfCurveQ1.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_CURVEQ1, 0, 0, 40, 40);
  640. m_surfCurveQ2.Create(40,40, RGB(255, 255, 255));
  641. m_surfCurveQ2.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_CURVEQ2, 0, 0, 40, 40);
  642. m_surfCurveQ3.Create(40,40, RGB(255, 255, 255));
  643. m_surfCurveQ3.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_CURVEQ3, 0, 0, 40, 40);
  644. m_surfEndCurveQ0.Create(40,40, RGB(255, 255, 255));
  645. m_surfEndCurveQ0.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_ENDCURVEQ0, 0, 0, 40, 40);
  646. m_surfEndCurveQ1.Create(40,40, RGB(255, 255, 255));
  647. m_surfEndCurveQ1.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_ENDCURVEQ1, 0, 0, 40, 40);
  648. m_surfEndCurveQ2.Create(40,40, RGB(255, 255, 255));
  649. m_surfEndCurveQ2.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_ENDCURVEQ2, 0, 0, 40, 40);
  650. m_surfEndCurveQ3.Create(40,40, RGB(255, 255, 255));
  651. m_surfEndCurveQ3.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_ENDCURVEQ3, 0, 0, 40, 40);
  652. m_surfMediumCurveQ0P1.Create(40,40, RGB(255, 255, 255));
  653. m_surfMediumCurveQ0P1.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_MEDIUMCURVEQ0P1, 0, 0, 40, 40);
  654. m_surfMediumCurveQ0P2.Create(40,40, RGB(255, 255, 255));
  655. m_surfMediumCurveQ0P2.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_MEDIUMCURVEQ0P2, 0, 0, 40, 40);
  656. m_surfMediumCurveQ0P3.Create(40,40, RGB(255, 255, 255));
  657. m_surfMediumCurveQ0P3.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_MEDIUMCURVEQ0P3, 0, 0, 40, 40);
  658. m_surfMediumCurveQ1P1.Create(40,40, RGB(255, 255, 255));
  659. m_surfMediumCurveQ1P1.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_MEDIUMCURVEQ1P1, 0, 0, 40, 40);
  660. m_surfMediumCurveQ1P2.Create(40,40, RGB(255, 255, 255));
  661. m_surfMediumCurveQ1P2.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_MEDIUMCURVEQ1P2, 0, 0, 40, 40);
  662. m_surfMediumCurveQ1P3.Create(40,40, RGB(255, 255, 255));
  663. m_surfMediumCurveQ1P3.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_MEDIUMCURVEQ1P3, 0, 0, 40, 40);
  664. m_surfMediumCurveQ2P1.Create(40,40, RGB(255, 255, 255));
  665. m_surfMediumCurveQ2P1.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_MEDIUMCURVEQ2P1, 0, 0, 40, 40);
  666. m_surfMediumCurveQ2P2.Create(40,40, RGB(255, 255, 255));
  667. m_surfMediumCurveQ2P2.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_MEDIUMCURVEQ2P2, 0, 0, 40, 40);
  668. m_surfMediumCurveQ2P3.Create(40,40, RGB(255, 255, 255));
  669. m_surfMediumCurveQ2P3.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_MEDIUMCURVEQ2P3, 0, 0, 40, 40);
  670. m_surfMediumCurveQ3P1.Create(40,40, RGB(255, 255, 255));
  671. m_surfMediumCurveQ3P1.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_MEDIUMCURVEQ3P1, 0, 0, 40, 40);
  672. m_surfMediumCurveQ3P2.Create(40,40, RGB(255, 255, 255));
  673. m_surfMediumCurveQ3P2.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_MEDIUMCURVEQ3P2, 0, 0, 40, 40);
  674. m_surfMediumCurveQ3P3.Create(40,40, RGB(255, 255, 255));
  675. m_surfMediumCurveQ3P3.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_MEDIUMCURVEQ3P3, 0, 0, 40, 40);
  676. m_surfEndMediumCurveQ0P1.Create(40,40, RGB(255, 255, 255));
  677. m_surfEndMediumCurveQ0P1.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_ENDMEDIUMCURVEQ0P1, 0, 0, 40, 40);
  678. m_surfEndMediumCurveQ0P2.Create(40,40, RGB(255, 255, 255));
  679. m_surfEndMediumCurveQ0P2.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_ENDMEDIUMCURVEQ0P2, 0, 0, 40, 40);
  680. m_surfEndMediumCurveQ0P3.Create(40,40, RGB(255, 255, 255));
  681. m_surfEndMediumCurveQ0P3.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_ENDMEDIUMCURVEQ0P3, 0, 0, 40, 40);
  682. m_surfEndMediumCurveQ1P1.Create(40,40, RGB(255, 255, 255));
  683. m_surfEndMediumCurveQ1P1.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_ENDMEDIUMCURVEQ1P1, 0, 0, 40, 40);
  684. m_surfEndMediumCurveQ1P2.Create(40,40, RGB(255, 255, 255));
  685. m_surfEndMediumCurveQ1P2.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_ENDMEDIUMCURVEQ1P2, 0, 0, 40, 40);
  686. m_surfEndMediumCurveQ1P3.Create(40,40, RGB(255, 255, 255));
  687. m_surfEndMediumCurveQ1P3.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_ENDMEDIUMCURVEQ1P3, 0, 0, 40, 40);
  688. m_surfEndMediumCurveQ2P1.Create(40,40, RGB(255, 255, 255));
  689. m_surfEndMediumCurveQ2P1.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_ENDMEDIUMCURVEQ2P1, 0, 0, 40, 40);
  690. m_surfEndMediumCurveQ2P2.Create(40,40, RGB(255, 255, 255));
  691. m_surfEndMediumCurveQ2P2.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_ENDMEDIUMCURVEQ2P2, 0, 0, 40, 40);
  692. m_surfEndMediumCurveQ2P3.Create(40,40, RGB(255, 255, 255));
  693. m_surfEndMediumCurveQ2P3.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_ENDMEDIUMCURVEQ2P3, 0, 0, 40, 40);
  694. m_surfEndMediumCurveQ3P1.Create(40,40, RGB(255, 255, 255));
  695. m_surfEndMediumCurveQ3P1.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_ENDMEDIUMCURVEQ3P1, 0, 0, 40, 40);
  696. m_surfEndMediumCurveQ3P2.Create(40,40, RGB(255, 255, 255));
  697. m_surfEndMediumCurveQ3P2.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_ENDMEDIUMCURVEQ3P2, 0, 0, 40, 40);
  698. m_surfEndMediumCurveQ3P3.Create(40,40, RGB(255, 255, 255));
  699. m_surfEndMediumCurveQ3P3.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_ENDMEDIUMCURVEQ3P3, 0, 0, 40, 40);
  700. // 赛道三角区域
  701. m_surfDiagonalQ0.Create(40,40, RGB(255, 255, 255));
  702. m_surfDiagonalQ0.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_DIAGONALQ0, 0, 0, 40, 40);
  703. m_surfDiagonalQ1.Create(40,40, RGB(255, 255, 255));
  704. m_surfDiagonalQ1.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_DIAGONALQ1, 0, 0, 40, 40);
  705. m_surfDiagonalQ2.Create(40,40, RGB(255, 255, 255));
  706. m_surfDiagonalQ2.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_DIAGONALQ2, 0, 0, 40, 40);
  707. m_surfDiagonalQ3.Create(40,40, RGB(255, 255, 255));
  708. m_surfDiagonalQ3.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_DIAGONALQ3, 0, 0, 40, 40);
  709. m_surfMidDiagonalQ0.Create(40,40, RGB(255, 255, 255));
  710. m_surfMidDiagonalQ0.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_MIDDIAGONALQ0, 0, 0, 40, 40);
  711. m_surfMidDiagonalQ1.Create(40,40, RGB(255, 255, 255));
  712. m_surfMidDiagonalQ1.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_MIDDIAGONALQ1, 0, 0, 40, 40);
  713. m_surfMidDiagonalQ2.Create(40,40, RGB(255, 255, 255));
  714. m_surfMidDiagonalQ2.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_MIDDIAGONALQ2, 0, 0, 40, 40);
  715. m_surfMidDiagonalQ3.Create(40,40, RGB(255, 255, 255));
  716. m_surfMidDiagonalQ3.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_MIDDIAGONALQ3, 0, 0, 40, 40);
  717. m_surfBlackPointQ0.Create(40,40, RGB(255, 255, 255));
  718. m_surfBlackPointQ0.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_BLACKPOINTQ0, 0, 0, 40, 40);
  719. m_surfBlackPointQ1.Create(40,40, RGB(255, 255, 255));
  720. m_surfBlackPointQ1.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_BLACKPOINTQ1, 0, 0, 40, 40);
  721. m_surfBlackPointQ2.Create(40,40, RGB(255, 255, 255));
  722. m_surfBlackPointQ2.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_BLACKPOINTQ2, 0, 0, 40, 40);
  723. m_surfBlackPointQ3.Create(40,40, RGB(255, 255, 255));
  724. m_surfBlackPointQ3.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_BLACKPOINTQ3, 0, 0, 40, 40);
  725. m_surf_HZ_StartDiagonalQ0.Create(40,40, RGB(255, 255, 255));
  726. m_surf_HZ_StartDiagonalQ0.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_HZ_STARTDIAGONALQ0, 0, 0, 40, 40);
  727. m_surf_HZ_StartDiagonalQ1.Create(40,40, RGB(255, 255, 255));
  728. m_surf_HZ_StartDiagonalQ1.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_HZ_STARTDIAGONALQ1, 0, 0, 40, 40);
  729. m_surf_HZ_StartDiagonalQ2.Create(40,40, RGB(255, 255, 255));
  730. m_surf_HZ_StartDiagonalQ2.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_HZ_STARTDIAGONALQ2, 0, 0, 40, 40);
  731. m_surf_HZ_StartDiagonalQ3.Create(40,40, RGB(255, 255, 255));
  732. m_surf_HZ_StartDiagonalQ3.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_HZ_STARTDIAGONALQ3, 0, 0, 40, 40);
  733. m_surf_HZ_EndDiagonalQ0.Create(40,40, RGB(255, 255, 255));
  734. m_surf_HZ_EndDiagonalQ0.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_HZ_ENDDIAGONALQ0, 0, 0, 40, 40);
  735. m_surf_HZ_EndDiagonalQ1.Create(40,40, RGB(255, 255, 255));
  736. m_surf_HZ_EndDiagonalQ1.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_HZ_ENDDIAGONALQ1, 0, 0, 40, 40);
  737. m_surf_HZ_EndDiagonalQ2.Create(40,40, RGB(255, 255, 255));
  738. m_surf_HZ_EndDiagonalQ2.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_HZ_ENDDIAGONALQ2, 0, 0, 40, 40);
  739. m_surf_HZ_EndDiagonalQ3.Create(40,40, RGB(255, 255, 255));
  740. m_surf_HZ_EndDiagonalQ3.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_HZ_ENDDIAGONALQ3, 0, 0, 40, 40);
  741. m_surf_VR_StartDiagonalQ0.Create(40,40, RGB(255, 255, 255));
  742. m_surf_VR_StartDiagonalQ0.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_VR_STARTDIAGONALQ0, 0, 0, 40, 40);
  743. m_surf_VR_StartDiagonalQ1.Create(40,40, RGB(255, 255, 255));
  744. m_surf_VR_StartDiagonalQ1.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_VR_STARTDIAGONALQ1, 0, 0, 40, 40);
  745. m_surf_VR_StartDiagonalQ2.Create(40,40, RGB(255, 255, 255));
  746. m_surf_VR_StartDiagonalQ2.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_VR_STARTDIAGONALQ2, 0, 0, 40, 40);
  747. m_surf_VR_StartDiagonalQ3.Create(40,40, RGB(255, 255, 255));
  748. m_surf_VR_StartDiagonalQ3.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_VR_STARTDIAGONALQ3, 0, 0, 40, 40);
  749. m_surf_VR_EndDiagonalQ0.Create(40,40, RGB(255, 255, 255));
  750. m_surf_VR_EndDiagonalQ0.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_VR_ENDDIAGONALQ0, 0, 0, 40, 40);
  751. m_surf_VR_EndDiagonalQ1.Create(40,40, RGB(255, 255, 255));
  752. m_surf_VR_EndDiagonalQ1.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_VR_ENDDIAGONALQ1, 0, 0, 40, 40);
  753. m_surf_VR_EndDiagonalQ2.Create(40,40, RGB(255, 255, 255));
  754. m_surf_VR_EndDiagonalQ2.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_VR_ENDDIAGONALQ2, 0, 0, 40, 40);
  755. m_surf_VR_EndDiagonalQ3.Create(40,40, RGB(255, 255, 255));
  756. m_surf_VR_EndDiagonalQ3.LoadBitmap(GetMainApp()->m_hInst, ID_ROADTYPE_VR_ENDDIAGONALQ3, 0, 0, 40, 40);
  757. // This point arrays are used to remove the polygonal regions of each tile
  758. // in the hit checking structure
  759. // When we create the race track, we create a big rectangle that consider
  760. // all the racetrack invalid. When we call this function, we remove the
  761. // polygonal regions of this big rectangle, based on 
  762. // the tile positions and tile types.
  763. POINT ptsDiagonalQ0[] = { {2,40}, {40,40}, {40,2} };
  764. POINT ptsDiagonalQ1[] = { {0,2}, {37,40}, {0,40} };
  765. POINT ptsDiagonalQ2[] = { {2,0}, {41,41}, {40,0} };
  766. POINT ptsDiagonalQ3[] = { {0,38}, {38,0}, {0,0} };
  767. POINT pts_VR_StartDiagonalQ0[] = { {2,0}, {20,18}, {21,41}, 
  768. {40,41}, {40,0} };
  769. POINT pts_VR_StartDiagonalQ1[] = { {0,0}, {39,0}, {19,19}, 
  770. {19,40}, {0,40} };
  771. POINT pts_VR_StartDiagonalQ2[] = { {19,0}, {40,0}, {40,40}, 
  772. {0,40}, {19,20} };
  773. POINT pts_VR_StartDiagonalQ3[] = { {0,0}, {19,0}, {19,20}, 
  774. {40,40}, {0,40} };
  775. POINT pts_HZ_EndDiagonalQ0[] = { {0,40}, {22,17}, {40,17}, 
  776. {40,40} };
  777. POINT pts_HZ_EndDiagonalQ1[] = { {0,17}, {18,17}, {40,40}, 
  778. {0,40} };
  779. POINT pts_HZ_EndDiagonalQ2[] = { {0,0}, {40,0}, {40,18}, 
  780. {18,18} };
  781. POINT pts_HZ_EndDiagonalQ3[] = { {0,0}, {40,0}, {21,18}, 
  782. {0,18} };
  783. POINT pts_HZ_StartDiagonalQ0[] = { {0,17}, {23,17}, {40,0}, 
  784. {40,40}, {0,40} };
  785. POINT pts_HZ_StartDiagonalQ1[] = { {0,0}, {18,18}, {40,18}, 
  786. {40,40}, {0,40} };
  787. POINT pts_HZ_StartDiagonalQ2[] = { {0,0}, {40,0}, {40,40}, 
  788. {18,18}, {0,18} };
  789. POINT pts_HZ_StartDiagonalQ3[] = { {0,0}, {40,0}, {40,18}, 
  790. {20,18}, {0,40} };
  791. POINT ptsCurveQ0[] = { {0,16}, {12,16}, {18,11}, {19,0},
  792. {40,0}, {40,40}, {0,40}};
  793. POINT ptsCurveQ1[] = { {0,0}, {20,0}, {21,11}, {27,17},
  794. {40,17}, {40,40}, {0,40}};
  795. POINT ptsCurveQ2[] = { {-1,-1}, {41,-1}, {41,41}, {19,41},
  796. {19,26}, {12,18}, {-1,18}};
  797. POINT ptsCurveQ3[] = { {-1,-1}, {40,-1}, {40,19}, {30,20},
  798. {20,28}, {19,41}, {-1,41}};
  799. POINT ptsEndCurveQ0[] = { {40,16}, {25,17}, {19,25}, {19,40},
  800. {40,40}};
  801. POINT ptsEndCurveQ1[] = { {0,16}, {12,17}, {20,25}, {21,40},
  802. {0,40}};
  803. POINT ptsEndCurveQ2[] = { {18,-1}, {20,12}, {27,20}, {41,19},
  804. {41,-1}};
  805. POINT ptsEndCurveQ3[] = { {-1,-1}, {20,-1}, {19,12}, {12,19},
  806. {-1,20}};
  807. POINT ptsMediumCurveQ0P1[] = { {18,0}, {40,0}, {40,40}, {0,40},
  808. {11,27}, {16,13}};
  809. POINT ptsMediumCurveQ1P1[] = { {-1,-1}, {21,-1}, {22,14}, {28,29},
  810. {38,41}, {-1,41}};
  811. POINT ptsMediumCurveQ2P1[] = { {3,-1}, {41,-1}, {41,41}, {19,41},
  812. {18,25}, {11,11}};
  813. POINT ptsMediumCurveQ3P1[] = { {-1,-1}, {36,-1}, {28,10}, {21,24},
  814. {21,41}, {-1,41}};
  815. POINT ptsMediumCurveQ0P3[] = { {0,16}, {41,0}, {41,41}, {0,41}};
  816. POINT ptsMediumCurveQ1P3[] = { {41,16}, {-1,-1}, {-1,41}, {41,41}};
  817. POINT ptsMediumCurveQ2P3[] = { {-1,17}, {41,36}, {41,-1}, {-1,-1}};
  818. POINT ptsMediumCurveQ3P3[] = { {-1,36}, {41,18}, {41,-1}, {-1,-1}};
  819. POINT ptsEndMediumCurveQ0P1[] = { {20,40}, {20,23}, {33,0}, {40,0},
  820. {40,40}};
  821. POINT ptsEndMediumCurveQ0P3[] = { {0,35}, {23,23}, {40,19}, {40,40},
  822. {0,40}};
  823. POINT ptsEndMediumCurveQ1P1[] = { {5,0}, {18,20}, {19,40}, {0,40},
  824. {0,0}};
  825. POINT ptsEndMediumCurveQ1P3[] = { {0,18}, {20,25}, {40,35}, {40,40},
  826. {0,40}};
  827. POINT ptsEndMediumCurveQ2P1[] = { {20,0}, {21,18}, {36,40}, {40,40},
  828. {40,0}};
  829. POINT ptsEndMediumCurveQ2P3[] = { {0,0}, {20,12}, {40,17}, {40,0},
  830. {0,0}};
  831. POINT ptsEndMediumCurveQ3P1[] = { {20,0}, {19,15}, {5,40}, {0,40},
  832. {0,0}};
  833. POINT ptsEndMediumCurveQ3P3[] = { {0,0}, {40,0}, {40,2}, {0,18},
  834. {0,0}};
  835. // Here we mount the race track surface using the tiles of the roads
  836. // we will also CUT the hit checker map so that the map will only
  837. // have the invalid regin of the track. If any ship goes in to this
  838. // region, the ship will explode.
  839. for(int j=0;j<m_iRows;j++)
  840. {
  841. for(int i=0;i<m_iCols;i++)
  842. {
  843. // Get the low order value of the integer
  844. // The low order value represents the type of the road (tile)
  845. // we are using (could be a curve or a plain road). The high
  846. // order word is used to save the check point marks, that are
  847. // used check if the user completed the lap
  848. int iType = LOWORD(m_RoadMap.GetValue(i,j));
  849. switch(iType + ID_ROADTYPE_SRACEROADQ0 - 1)
  850. {
  851. case ID_ROADTYPE_VR_STARTDIAGONALQ0:
  852. m_hcRoadMap.RemovePolyFromBound(pts_VR_StartDiagonalQ0, 5, i*40, j*40);
  853. break;
  854. case ID_ROADTYPE_VR_STARTDIAGONALQ1:
  855. m_hcRoadMap.RemovePolyFromBound(pts_VR_StartDiagonalQ1, 5, i*40, j*40);
  856. break;
  857. case ID_ROADTYPE_VR_STARTDIAGONALQ2:
  858. m_hcRoadMap.RemovePolyFromBound(pts_VR_StartDiagonalQ2, 5, i*40, j*40);
  859. break;
  860. case ID_ROADTYPE_VR_STARTDIAGONALQ3:
  861. m_hcRoadMap.RemovePolyFromBound(pts_VR_StartDiagonalQ3, 5, i*40, j*40);
  862. break;
  863. case ID_ROADTYPE_HZ_ENDDIAGONALQ0:
  864. m_hcRoadMap.RemovePolyFromBound(pts_HZ_EndDiagonalQ0, 4, i*40, j*40);
  865. break;
  866. case ID_ROADTYPE_HZ_ENDDIAGONALQ1:
  867. m_hcRoadMap.RemovePolyFromBound(pts_HZ_EndDiagonalQ1, 4, i*40, j*40);
  868. break;
  869. case ID_ROADTYPE_HZ_ENDDIAGONALQ2:
  870. m_hcRoadMap.RemovePolyFromBound(pts_HZ_EndDiagonalQ2, 4, i*40, j*40);
  871. break;
  872. case ID_ROADTYPE_HZ_ENDDIAGONALQ3:
  873. m_hcRoadMap.RemovePolyFromBound(pts_HZ_EndDiagonalQ3, 4, i*40, j*40);
  874. break;
  875. case ID_ROADTYPE_HZ_STARTDIAGONALQ0:
  876. m_hcRoadMap.RemovePolyFromBound(pts_HZ_StartDiagonalQ0, 5, i*40, j*40);
  877. break;
  878. case ID_ROADTYPE_HZ_STARTDIAGONALQ1:
  879. m_hcRoadMap.RemovePolyFromBound(pts_HZ_StartDiagonalQ1, 5, i*40, j*40);
  880. break;
  881. case ID_ROADTYPE_HZ_STARTDIAGONALQ2:
  882. m_hcRoadMap.RemovePolyFromBound(pts_HZ_StartDiagonalQ2, 5, i*40, j*40);
  883. break;
  884. case ID_ROADTYPE_HZ_STARTDIAGONALQ3:
  885. m_hcRoadMap.RemovePolyFromBound(pts_HZ_StartDiagonalQ3, 5, i*40, j*40);
  886. break;
  887. case ID_ROADTYPE_DIAGONALQ0:
  888. m_hcRoadMap.RemovePolyFromBound(ptsDiagonalQ0, 3, i*40, j*40);
  889. break;
  890. case ID_ROADTYPE_DIAGONALQ1:
  891. m_hcRoadMap.RemovePolyFromBound(ptsDiagonalQ1, 3, i*40, j*40);
  892. break;
  893. case ID_ROADTYPE_DIAGONALQ2:
  894. m_hcRoadMap.RemovePolyFromBound(ptsDiagonalQ2, 3, i*40, j*40);
  895. break;
  896. case ID_ROADTYPE_DIAGONALQ3:
  897. m_hcRoadMap.RemovePolyFromBound(ptsDiagonalQ3, 3, i*40, j*40);
  898. break;
  899. case ID_ROADTYPE_SRACEROADQ0:
  900. m_hcRoadMap.RemoveRectFromBound( (i*40)+20, j*40, 21, 40);
  901. break;
  902. case ID_ROADTYPE_SRACEROADQ1:
  903. m_hcRoadMap.RemoveRectFromBound( (i*40), (j*40), 20, 40);
  904. break;
  905. case ID_ROADTYPE_SRACEROADQ2:
  906. m_hcRoadMap.RemoveRectFromBound( (i*40), (j*40)+18, 40, 20);
  907. break;
  908. case ID_ROADTYPE_SRACEROADQ3:
  909. m_hcRoadMap.RemoveRectFromBound( (i*40), (j*40), 40, 18);
  910. break;
  911. case ID_ROADTYPE_ROADQ0:
  912. m_hcRoadMap.RemoveRectFromBound( (i*40)+20, j*40, 21, 40);
  913. break;
  914. case ID_ROADTYPE_ROADQ1:
  915. m_hcRoadMap.RemoveRectFromBound( (i*40), (j*40), 20, 40);
  916. break;
  917. case ID_ROADTYPE_ROADQ2:
  918. m_hcRoadMap.RemoveRectFromBound( (i*40), (j*40)+18, 40, 22);
  919. break;
  920. case ID_ROADTYPE_ROADQ3:
  921. m_hcRoadMap.RemoveRectFromBound( (i*40), (j*40), 40, 20);
  922. break;
  923. case ID_ROADTYPE_CURVEQ0:
  924. m_hcRoadMap.RemovePolyFromBound(ptsCurveQ0, 7, i*40, j*40);
  925. break;
  926. case ID_ROADTYPE_CURVEQ1:
  927. m_hcRoadMap.RemovePolyFromBound(ptsCurveQ1, 7, i*40, j*40);
  928. break;
  929. case ID_ROADTYPE_CURVEQ2:
  930. m_hcRoadMap.RemovePolyFromBound(ptsCurveQ2, 7, i*40, j*40);
  931. break;
  932. case ID_ROADTYPE_CURVEQ3:
  933. m_hcRoadMap.RemovePolyFromBound(ptsCurveQ3, 7, i*40, j*40);
  934. break;
  935. case ID_ROADTYPE_ENDCURVEQ0:
  936. m_hcRoadMap.RemovePolyFromBound(ptsEndCurveQ0, 5, i*40, j*40);
  937. break;
  938. case ID_ROADTYPE_ENDCURVEQ1:
  939. m_hcRoadMap.RemovePolyFromBound(ptsEndCurveQ1, 5, i*40, j*40);
  940. break;
  941. case ID_ROADTYPE_ENDCURVEQ2:
  942. m_hcRoadMap.RemovePolyFromBound(ptsEndCurveQ2, 5, i*40, j*40);
  943. break;
  944. case ID_ROADTYPE_ENDCURVEQ3:
  945. m_hcRoadMap.RemovePolyFromBound(ptsEndCurveQ3, 5, i*40, j*40);
  946. break;
  947. case ID_ROADTYPE_MIDDIAGONALQ0:
  948. case ID_ROADTYPE_MIDDIAGONALQ1:
  949. case ID_ROADTYPE_MIDDIAGONALQ2:
  950. case ID_ROADTYPE_MIDDIAGONALQ3:
  951. case ID_ROADTYPE_FULLROADQ0:
  952. case ID_ROADTYPE_FULLROADQ1:
  953. case ID_ROADTYPE_FULLROADQ2:
  954. case ID_ROADTYPE_FULLROADQ3:
  955. case ID_ROADTYPE_FULLROADQ4:
  956. case ID_ROADTYPE_FULLROADQ5:
  957. case ID_ROADTYPE_FULLROADQ6:
  958. case ID_ROADTYPE_FULLROADQ7:
  959. case ID_ROADTYPE_FULLROADQ8:
  960. case ID_ROADTYPE_FULLROADQ9:
  961. case ID_ROADTYPE_FULLROADQ10:
  962. case ID_ROADTYPE_FULLROADQ11:
  963. case ID_ROADTYPE_FULLROADQ12:
  964. case ID_ROADTYPE_FULLROADQ13:
  965. case ID_ROADTYPE_FULLROADQ14:
  966. case ID_ROADTYPE_FULLROADQ15:
  967. case ID_ROADTYPE_FULLROADQ16:
  968. case ID_ROADTYPE_FULLROADQ17:
  969. m_hcRoadMap.RemoveRectFromBound( (i*40), (j*40), 40, 40);
  970. break;
  971. case ID_ROADTYPE_MEDIUMCURVEQ0P1:
  972. m_hcRoadMap.RemovePolyFromBound(ptsMediumCurveQ0P1, 6, i*40, j*40);
  973. break;
  974. case ID_ROADTYPE_MEDIUMCURVEQ0P2:
  975. m_hcRoadMap.RemoveRectFromBound( (i*40), (j*40), 40, 40);
  976. break;
  977. case ID_ROADTYPE_MEDIUMCURVEQ0P3:
  978. m_hcRoadMap.RemovePolyFromBound(ptsMediumCurveQ0P3, 4, i*40, j*40);
  979. break;
  980. case ID_ROADTYPE_MEDIUMCURVEQ1P1:
  981. m_hcRoadMap.RemovePolyFromBound(ptsMediumCurveQ1P1, 6, i*40, j*40);
  982. break;
  983. case ID_ROADTYPE_MEDIUMCURVEQ1P2:
  984. m_hcRoadMap.RemoveRectFromBound( (i*40), (j*40), 40, 40);
  985. break;
  986. case ID_ROADTYPE_MEDIUMCURVEQ1P3:
  987. m_hcRoadMap.RemovePolyFromBound(ptsMediumCurveQ1P3, 4, i*40, j*40);
  988. break;
  989. case ID_ROADTYPE_MEDIUMCURVEQ2P1:
  990. m_hcRoadMap.RemovePolyFromBound(ptsMediumCurveQ2P1, 6, i*40, j*40);
  991. break;
  992. case ID_ROADTYPE_MEDIUMCURVEQ2P2:
  993. m_hcRoadMap.RemoveRectFromBound( (i*40), (j*40), 40, 40);
  994. break;
  995. case ID_ROADTYPE_MEDIUMCURVEQ2P3:
  996. m_hcRoadMap.RemovePolyFromBound(ptsMediumCurveQ2P3, 4, i*40, j*40);
  997. break;
  998. case ID_ROADTYPE_MEDIUMCURVEQ3P1:
  999. m_hcRoadMap.RemovePolyFromBound(ptsMediumCurveQ3P1, 6, i*40, j*40);
  1000. break;
  1001. case ID_ROADTYPE_MEDIUMCURVEQ3P2:
  1002. m_hcRoadMap.RemoveRectFromBound( (i*40), (j*40), 40, 40);
  1003. break;
  1004. case ID_ROADTYPE_MEDIUMCURVEQ3P3:
  1005. m_hcRoadMap.RemovePolyFromBound(ptsMediumCurveQ3P3, 4, i*40, j*40);
  1006. break;
  1007. case ID_ROADTYPE_ENDMEDIUMCURVEQ0P1:
  1008. m_hcRoadMap.RemovePolyFromBound(ptsEndMediumCurveQ0P1, 5, i*40, j*40);
  1009. break;
  1010. case ID_ROADTYPE_ENDMEDIUMCURVEQ0P2:
  1011. break;
  1012. case ID_ROADTYPE_ENDMEDIUMCURVEQ0P3:
  1013. m_hcRoadMap.RemovePolyFromBound(ptsEndMediumCurveQ0P3, 5, i*40, j*40);
  1014. break;
  1015. case ID_ROADTYPE_ENDMEDIUMCURVEQ1P1:
  1016. m_hcRoadMap.RemovePolyFromBound(ptsEndMediumCurveQ1P1, 5, i*40, j*40);
  1017. break;
  1018. case ID_ROADTYPE_ENDMEDIUMCURVEQ1P2:
  1019. break;
  1020. case ID_ROADTYPE_ENDMEDIUMCURVEQ1P3:
  1021. m_hcRoadMap.RemovePolyFromBound(ptsEndMediumCurveQ1P3, 5, i*40, j*40);
  1022. break;
  1023. case ID_ROADTYPE_ENDMEDIUMCURVEQ2P1:
  1024. m_hcRoadMap.RemovePolyFromBound(ptsEndMediumCurveQ2P1, 5, i*40, j*40);
  1025. break;
  1026. case ID_ROADTYPE_ENDMEDIUMCURVEQ2P2:
  1027. break;
  1028. case ID_ROADTYPE_ENDMEDIUMCURVEQ2P3:
  1029. m_hcRoadMap.RemovePolyFromBound(ptsEndMediumCurveQ2P3, 5, i*40, j*40);
  1030. break;
  1031. case ID_ROADTYPE_ENDMEDIUMCURVEQ3P1:
  1032. m_hcRoadMap.RemovePolyFromBound(ptsEndMediumCurveQ3P1, 5, i*40, j*40);
  1033. break;
  1034. case ID_ROADTYPE_ENDMEDIUMCURVEQ3P2:
  1035. break;
  1036. case ID_ROADTYPE_ENDMEDIUMCURVEQ3P3:
  1037. m_hcRoadMap.RemovePolyFromBound(ptsEndMediumCurveQ3P3, 5, i*40, j*40);
  1038. break;
  1039. }
  1040. }
  1041. }
  1042. // Create the race Completed surface
  1043. m_surfRaceCompleted.Create(150,90,RGB(0,0,0));
  1044. m_surfRaceCompleted.LoadBitmap(GetMainApp()->m_hInst, IDB_RACECOMPLETED);
  1045. }
  1046. BOOL cRaceTrack::ReadFromFile(char *lpszFile)
  1047. {
  1048. // This function is used to load a race track from a race track file
  1049. // The file have a header with the track name, the number of laps
  1050. // and Track Dimensions.
  1051. //
  1052. // After the header we have an array of DWORD (based on the dimensions)
  1053. // that have the tile information
  1054. Destroy();
  1055. FILE* hFile;
  1056. int iCols;
  1057. int iRows;
  1058. int iTile;
  1059. int iValue;
  1060. int iSize;
  1061. char pBufferHeader[2];
  1062. // Open the track file
  1063. hFile = fopen(lpszFile, "rb");
  1064. if(hFile == NULL)
  1065. return FALSE;
  1066. m_sFileName = lpszFile;
  1067. // Read the header
  1068. fread((void*) pBufferHeader, sizeof(char), 2, hFile);
  1069. // Read the size of the track name string
  1070. fread((void*) &iSize, sizeof(int), 1, hFile);
  1071. m_sTrackName = (char*) malloc(iSize+1);
  1072. memset(m_sTrackName, '', iSize+1);
  1073. fread((void*) m_sTrackName, sizeof(char), iSize, hFile);
  1074. // Read the number of laps
  1075. fread((void*) &m_iLaps, sizeof(int), 1, hFile);
  1076. // Read the track dimension
  1077. fread((void*) &iCols, sizeof(int), 1, hFile);
  1078. fread((void*) &iRows, sizeof(int), 1, hFile);
  1079. // Read the Race Tile
  1080. fread((void*) &iTile, sizeof(int), 1, hFile);
  1081. // Now that we have the dimensions, read the DWORD array
  1082. int iRead = 0;
  1083. Create(iCols, iRows);
  1084. SetTile(iTile);
  1085. for(int j=0;j<iRows;j++)
  1086. {
  1087. for(int i=0;i<iCols;i++)
  1088. {
  1089. iRead = fread((void*) &iValue, sizeof(int),1,hFile);
  1090. m_RoadMap.SetValue(i,j,iValue);
  1091. }
  1092. }
  1093. fclose(hFile);
  1094. // Race track is loaded, remove the polygonal regions of the cHitCheck class
  1095. RemoveHitRegion();
  1096. return TRUE;
  1097. }
  1098. void cRaceTrack::GetStartPosition(int *iX, int *iY)
  1099. {
  1100. int i, j, iValue;
  1101. // This function is used to search where is the Race Start Tile
  1102. for(j=0; j<m_iRows; j++)
  1103. {
  1104. for(i=0; i<m_iCols; i++)
  1105. {
  1106. iValue = LOWORD(m_RoadMap.GetValue(i,j)) + ID_ROADTYPE_SRACEROADQ0 - 1;
  1107. if(iValue  >= ID_ROADTYPE_SRACEROADQ0 &&
  1108.    iValue  <= ID_ROADTYPE_SRACEROADQ3)
  1109. {
  1110. *iX = i*40;
  1111. *iY = j*40;
  1112. if(iValue == ID_ROADTYPE_SRACEROADQ0)
  1113. *iX = (i*40)+20;
  1114. if(iValue == ID_ROADTYPE_SRACEROADQ2)
  1115. *iY = (j*40)+20;
  1116. return;
  1117. }
  1118. }
  1119. }
  1120. }
  1121. void cRaceTrack::AdjustView(cRaceCar *pCar)
  1122. {
  1123. #define VIEW_RANGEX 320
  1124. #define VIEW_RANGEY 230
  1125. // This function will adjust the current view based on the player磗 car 
  1126. // current position
  1127. int iX, iY;
  1128. pCar->GetPos(&iX, &iY);
  1129. if(iX + VIEW_RANGEX >= m_iViewX + 640)
  1130. {
  1131. m_iViewX += (iX + VIEW_RANGEX)-(m_iViewX + 640);
  1132. }
  1133.     
  1134. if(iY + VIEW_RANGEY > m_iViewY + 480)
  1135. {
  1136. m_iViewY += (iY + VIEW_RANGEY)-(m_iViewY + 480);
  1137. }
  1138. if(iY - VIEW_RANGEY < m_iViewY)
  1139. {
  1140. m_iViewY -= (m_iViewY)-(iY - VIEW_RANGEY);
  1141. }
  1142. if(iX - VIEW_RANGEX < m_iViewX)
  1143. {
  1144. m_iViewX -= (m_iViewX)-(iX - VIEW_RANGEX);
  1145. }
  1146. if(m_iViewY<0)
  1147. m_iViewY = 0;
  1148. if(m_iViewX<0)
  1149. m_iViewX = 0;
  1150. if(m_iViewX > (m_iCols * 40)-640)
  1151. m_iViewX = (m_iCols * 40)-640;
  1152. if(m_iViewY > (m_iRows * 40)-480)
  1153. m_iViewY =(m_iRows * 40)-480;
  1154. }
  1155. int cRaceTrack::GetViewX()
  1156. {
  1157. return m_iViewX;
  1158. }
  1159. int cRaceTrack::GetViewY()
  1160. {
  1161. return m_iViewY;
  1162. }
  1163. BOOL cRaceTrack::CarHittedRoad(cRaceCar *pCar, int iX, int iY)
  1164. {
  1165. //int iX, iY;
  1166. if(iX == -1 && iY == -1)
  1167. pCar->GetPos(&iX, &iY);
  1168. return m_hcRoadMap.HaveHitted(&pCar->m_hcRaceCar, iX, iY, 0, 0);
  1169. }
  1170. int cRaceTrack::GetCheckPoint(int iX, int iY)
  1171. {
  1172. // Check if have any check point in the iX and iY position
  1173. iX = iX / 40;
  1174. iY = iY / 40;
  1175. if(iX < 0)
  1176. return 0;
  1177. if(iY < 0)
  1178. return 0;
  1179. if(iX > m_iCols-1)
  1180. return 0;
  1181. if(iY > m_iRows-1)
  1182. return 0;
  1183. int iResp = m_RoadMap.GetValue((int)iX,(int)iY);
  1184. // The check point is the LOWER BYTE of the HIWORD of the track DWORD array
  1185. iResp = LOBYTE(HIWORD(iResp));
  1186. return iResp;
  1187. }
  1188. int cRaceTrack::GetMaxCheckPoint()
  1189. {
  1190. // This function is used to get the number of the Last Check point we
  1191. // have in the track
  1192. if(m_iMaxCheckPoint != 0)
  1193. return m_iMaxCheckPoint;
  1194. for(int j=0;j<m_iRows;j++)
  1195. {
  1196. for(int i=0;i<m_iCols;i++)
  1197. {
  1198. if(LOBYTE(HIWORD(m_RoadMap.GetValue(i,j))) > m_iMaxCheckPoint)
  1199. m_iMaxCheckPoint = LOBYTE(HIWORD(m_RoadMap.GetValue(i,j)));
  1200. }
  1201. }
  1202. return m_iMaxCheckPoint;
  1203. }
  1204. int compare(const void* p1, const void* p2)
  1205. {
  1206. // This function is used to sort the cars, so that we know
  1207. // their position in the track
  1208. cRaceCar *pCar1, *pCar2;
  1209. pCar1 = *(cRaceCar**) p1;
  1210. pCar2 = *(cRaceCar**) p2;
  1211. // char buffer[100];
  1212. // sprintf(buffer,"CAR1 %d CAR2 %d", pCar1->m_iLaps, pCar2->m_iLaps);
  1213. // DXTRACE_MSG(buffer);
  1214. if(pCar1->GetCarState() == CARSTATE_RACECOMPLETED &&
  1215. pCar2->GetCarState() != CARSTATE_RACECOMPLETED)
  1216. return -1;
  1217. if(pCar1->GetCarState() == CARSTATE_RACECOMPLETED &&
  1218. pCar2->GetCarState() != CARSTATE_RACECOMPLETED)
  1219. return 1;
  1220. if(pCar1->GetCarState() == CARSTATE_RACECOMPLETED &&
  1221. pCar2->GetCarState() == CARSTATE_RACECOMPLETED)
  1222. {
  1223. if(pCar1->GetPosition() < pCar2->GetPosition())
  1224. return -1;
  1225. if(pCar1->GetPosition() > pCar2->GetPosition())
  1226. return 1;
  1227. }
  1228. if(pCar1->m_iLaps < pCar2->m_iLaps)
  1229. {
  1230. return 1;
  1231. }
  1232. else
  1233. {
  1234. if(pCar1->m_iLaps > pCar2->m_iLaps)
  1235. {
  1236. return -1;
  1237. }
  1238. else
  1239. {
  1240. if(pCar1->m_iCheckPoint < pCar2->m_iCheckPoint)
  1241. {
  1242. return 1;
  1243. }
  1244. else
  1245. {
  1246. if(pCar1->m_iCheckPoint > pCar2->m_iCheckPoint)
  1247. return -1;
  1248. else
  1249. {
  1250. if(pCar1->GetDistanceToNextCheckPoint() > pCar2->GetDistanceToNextCheckPoint())
  1251. return 1;
  1252. else
  1253. return -1;
  1254. }
  1255. }
  1256. }
  1257. }
  1258. }
  1259. void cRaceTrack::Process()
  1260. {
  1261. int iOffset = 0, i=0;
  1262. // This is the main function of the track
  1263. // Here is where the game really happens. At each game iteration, we磍l call
  1264. // this function to process the car data (including the racecars)
  1265. int iSrcCarX, iSrcCarY, iCarX, iCarY;
  1266. // The first thing we do is check if each one of the cars hit another car
  1267. // If they hit another car then the car that hit will be slowed down
  1268. // and the car that was hit will move forward
  1269. // Notice that we磍l only check this if we磖e on the single player mode
  1270. // or if we磖e hosting a multiplayer game. mutiplayer peers will receive
  1271. // this information in the network package
  1272. if(  
  1273.    ( (GetRaceXApp()->m_bIsMultiplayer == TRUE && GetRaceXApp()->GetMultiplayer()->IsHosting())
  1274.    || GetRaceXApp()->m_bIsMultiplayer == FALSE) && m_iState > 2
  1275.   )
  1276. {   
  1277. for(i=m_iNumCars-1;i>=0;i--)
  1278. {
  1279. for(int j=0;j<i;j++)
  1280. {
  1281. if(i!=j)
  1282. {
  1283. m_pRaceCars[j]->GetPos(&iCarX, &iCarY);
  1284. m_pRaceCars[i]->GetPos(&iSrcCarX, &iSrcCarY);
  1285. if(m_pRaceCars[j]->m_hcRaceCar.HaveHitted(&m_pRaceCars[i]->m_hcRaceCar, iCarX, iCarY, iSrcCarX, iSrcCarY) == TRUE)
  1286. {
  1287. if(m_pRaceCars[j]->GetSpeed() != 0)
  1288. {
  1289. if(m_pRaceCars[i]->GetLastCheckPoint() < m_pRaceCars[j]->GetLastCheckPoint())
  1290. {
  1291. m_pRaceCars[i]->HitCar();
  1292. m_pRaceCars[j]->MoveForward(/*m_pRaceCars[i]->GetSpeed() +*/ m_pRaceCars[j]->GetSpeed());
  1293. m_pRaceCars[j]->Accelerate();
  1294. }
  1295. else if (m_pRaceCars[i]->GetLastCheckPoint() < m_pRaceCars[j]->GetLastCheckPoint())
  1296. {
  1297. m_pRaceCars[j]->HitCar();
  1298. m_pRaceCars[i]->MoveForward(/*m_pRaceCars[i]->GetSpeed() +*/ m_pRaceCars[j]->GetSpeed());
  1299. m_pRaceCars[i]->Accelerate();
  1300. }
  1301. else
  1302. {
  1303. if(m_pRaceCars[i]->GetDistanceToNextCheckPoint() > m_pRaceCars[j]->GetDistanceToNextCheckPoint())
  1304. {
  1305. m_pRaceCars[i]->HitCar();
  1306. m_pRaceCars[j]->MoveForward(/*m_pRaceCars[i]->GetSpeed() +*/ m_pRaceCars[j]->GetSpeed());
  1307. m_pRaceCars[j]->Accelerate();
  1308. }
  1309. else
  1310. {
  1311. m_pRaceCars[j]->HitCar();
  1312. m_pRaceCars[i]->MoveForward( /*m_pRaceCars[i]->GetSpeed() +*/ m_pRaceCars[j]->GetSpeed());
  1313. m_pRaceCars[i]->Accelerate();
  1314. }
  1315. }
  1316. }
  1317. }
  1318. }
  1319. }
  1320. }
  1321. }
  1322. // In this loop we磍l process each one of the cars and set its position
  1323. for(i=0;i<m_iNumCars;i++)
  1324. {
  1325. // Set the current car position (if we磖e hosting a game or are in a single player game)
  1326. if(   ( (GetRaceXApp()->m_bIsMultiplayer == TRUE && GetRaceXApp()->GetMultiplayer()->IsHosting())  || GetRaceXApp()->m_bIsMultiplayer == FALSE) )
  1327. m_pRaceCars[i]->SetPosition(i+1);
  1328. // We磍l only process the car if the semaphore reached the "green" light
  1329. if(m_iState > 2)
  1330. m_pRaceCars[i]->Process(this);
  1331. // Here we磍l check if the car hit the Road. If so, we change the
  1332. // car state to CARSTATE_CRASHED_WALL
  1333. if(   ( (GetRaceXApp()->m_bIsMultiplayer == TRUE && GetRaceXApp()->GetMultiplayer()->IsHosting())
  1334.    || GetRaceXApp()->m_bIsMultiplayer == FALSE) 
  1335.    )
  1336. {
  1337. if(m_pRaceCars[i]->GetCarState() == CARSTATE_OK)
  1338. {
  1339. if(CarHittedRoad(m_pRaceCars[i]) == TRUE)
  1340. {
  1341. m_pRaceCars[i]->SetCarState(CARSTATE_CRASHED_WALL);
  1342. }
  1343. }
  1344. }
  1345. // After processing the car, we will adjust the car view
  1346. if(m_pRaceCars[i]->GetControlType() == CTRL_USER || m_pRaceCars[i]->GetControlType() == CTRL_NETWORK_LOCAL)
  1347. {
  1348. AdjustView(m_pRaceCars[i]);
  1349. }
  1350. }
  1351. // We process all the cars and adjusted the view, now draw each one of the cars
  1352. for(i=0;i<m_iNumCars;i++)
  1353. {
  1354. if( !(m_pRaceCars[i]->GetCarState() == CARSTATE_RACECOMPLETED &&
  1355. m_pRaceCars[i]->GetLapElapseTime() > 5000)  )
  1356. m_pRaceCars[i]->Draw(GetViewX(), GetViewY());
  1357. if(m_pRaceCars[i]->GetCarState() == CARSTATE_RACECOMPLETED && 
  1358.    (m_pRaceCars[i]->GetControlType() == CTRL_USER || m_pRaceCars[i]->GetControlType() == CTRL_NETWORK_LOCAL) )
  1359. {
  1360. m_surfRaceCompleted.Draw(GetMainApp()->m_pBackBuffer, 245, 190);
  1361. }
  1362. }   
  1363. // This is used to draw the semaphore on the screen
  1364. switch(m_iState)
  1365. {
  1366. case 0:
  1367. m_sptrWait.Create(GetMainApp()->GetInstHandle(), IDB_TRAFFICLIGHT, 120, 60, RGB(0,0,0), 40, 60);
  1368. m_sptrWait.m_iAbsolutePosition = 0;
  1369. m_sptrWait.Draw(GetMainApp()->m_pBackBuffer, 10, 10, FALSE);
  1370. m_lStartTime = GetTickCount();
  1371. m_iState++;
  1372. m_sndSemaphore.Play();
  1373. break;
  1374. case 1:
  1375. if(GetTickCount() - m_lStartTime > 1200)
  1376. {
  1377. m_sptrWait.Draw(GetMainApp()->m_pBackBuffer, 10, 10, TRUE);
  1378. m_lStartTime = GetTickCount();
  1379. m_iState++;
  1380. m_sndSemaphore.Play();
  1381. }
  1382. else
  1383. {
  1384. m_sptrWait.Draw(GetMainApp()->m_pBackBuffer, 10, 10, FALSE);
  1385. }
  1386. break;
  1387. case 2:
  1388. if(GetTickCount() - m_lStartTime > 1200)
  1389. {
  1390. m_sptrWait.Draw(GetMainApp()->m_pBackBuffer, 10, 10, TRUE);
  1391. m_lStartTime = GetTickCount();
  1392. m_iState++;
  1393. m_sndSemaphore.Play();
  1394. }
  1395. else
  1396. {
  1397. m_sptrWait.Draw(GetMainApp()->m_pBackBuffer, 10, 10, FALSE);
  1398. }
  1399. break;
  1400. default:
  1401. if(GetTickCount() - m_lStartTime < 1200)
  1402. {
  1403. m_sptrWait.Draw(GetMainApp()->m_pBackBuffer, 10, 10, FALSE);
  1404. }
  1405. break;
  1406. }
  1407. if(m_iState > 2)
  1408. qsort(m_pRaceCars, m_iNumCars, sizeof(cRaceCar*), compare);
  1409. }
  1410. cRaceCar* cRaceTrack::GetCar(int iPos)
  1411. {
  1412. return m_pRaceCars[iPos];
  1413. }
  1414. void cRaceTrack::AddCar(cRaceCar *pCar)
  1415. {
  1416. // When we add the cars to the race track
  1417. // we need to add them in the correct position
  1418. int iX, iY;
  1419. m_pRaceCars[m_iNumCars] = pCar;
  1420. m_iNumCars++;
  1421. GetStartPosition(&iX, &iY);
  1422. switch(m_iNumCars-1)
  1423. {
  1424. case 0:
  1425. pCar->SetPos(iX, iY);
  1426. break;
  1427. case 1:
  1428. pCar->SetPos(iX+40, iY);
  1429. break;
  1430. case 2:
  1431. pCar->SetPos(iX, iY+40);
  1432. break;
  1433. case 3:
  1434. pCar->SetPos(iX+40, iY+40);
  1435. break;
  1436. }
  1437. pCar->Backup();
  1438. }
  1439. int cRaceTrack::GetRoadType(int iX, int iY)
  1440. {
  1441. iX = (int) iX / 40;
  1442. iY = (int) iY / 40;
  1443. if(iX < 0)
  1444. iX = 0;
  1445. if(iY < 0)
  1446. iY = 0;
  1447. if(iX > m_iCols - 1)
  1448. {
  1449. iX = m_iCols - 1;
  1450. }
  1451. if(iY > m_iRows - 1)
  1452. iY = m_iRows - 1;
  1453. int iValue = m_RoadMap.GetValue(iX,iY);
  1454. if(LOWORD(iValue) <= 0)
  1455. return LOWORD(iValue);
  1456. else
  1457. return LOWORD(iValue) + ID_ROADTYPE_SRACEROADQ0 - 1;
  1458. }
  1459. /*
  1460. int cRaceTrack::TurnDirection(int iX, int iY, int iAngle)
  1461. {
  1462. int i = 0;
  1463. int iUseX = 0;
  1464. int iUseY = -1;
  1465. while(1)
  1466. {
  1467. if((GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDCURVEQ0 ||
  1468.    GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDMEDIUMCURVEQ0P3 ||
  1469.    GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDMEDIUMCURVEQ0P2 ||
  1470.    GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDMEDIUMCURVEQ0P1)
  1471.    && (iAngle >=0 && iAngle < 90))
  1472.    return TURN_RIGHT;
  1473. if((GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDCURVEQ1 ||
  1474.    GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDMEDIUMCURVEQ1P3 ||
  1475.    GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDMEDIUMCURVEQ1P2 ||
  1476.    GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDMEDIUMCURVEQ1P1)
  1477.    && (iAngle == 0 || iAngle > 270))
  1478.    return TURN_LEFT;
  1479. if((GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDCURVEQ1 ||
  1480.    GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDMEDIUMCURVEQ1P3 ||
  1481.    GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDMEDIUMCURVEQ1P2 ||
  1482.    GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDMEDIUMCURVEQ1P1)
  1483.    && (iAngle >=90 && iAngle < 180))
  1484.    return TURN_RIGHT;
  1485. if((GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDCURVEQ3 ||
  1486.    GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDMEDIUMCURVEQ3P3 ||
  1487.    GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDMEDIUMCURVEQ3P2 ||
  1488.    GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDMEDIUMCURVEQ3P1)
  1489.    && (iAngle > 0 && iAngle <=90))
  1490.    return TURN_LEFT;
  1491. if((GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDCURVEQ2 ||
  1492.    GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDMEDIUMCURVEQ2P3 ||
  1493.    GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDMEDIUMCURVEQ2P2 ||
  1494.    GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDMEDIUMCURVEQ2P1)
  1495.    && (iAngle <=180 && iAngle > 90))
  1496.    return TURN_LEFT;
  1497. if((GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDCURVEQ3 ||
  1498.    GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDMEDIUMCURVEQ3P3 ||
  1499.    GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDMEDIUMCURVEQ3P2 ||
  1500.    GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDMEDIUMCURVEQ3P1)
  1501.    && (iAngle < 270 && iAngle >=180))
  1502.    return TURN_RIGHT;
  1503. if((GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDCURVEQ0 ||
  1504.    GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDMEDIUMCURVEQ0P3 ||
  1505.    GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDMEDIUMCURVEQ0P2 ||
  1506.    GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDMEDIUMCURVEQ0P1)
  1507.    && (iAngle <=270 && iAngle > 180))
  1508.    return TURN_LEFT;
  1509. if((GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDCURVEQ2 ||
  1510.    GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDMEDIUMCURVEQ2P3 ||
  1511.    GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDMEDIUMCURVEQ2P2 ||
  1512.    GetRoadType(iX+(i*iUseX), iY+(i*iUseY)) == ID_ROADTYPE_ENDMEDIUMCURVEQ2P1)
  1513.    && (iAngle >= 270))
  1514.    return TURN_RIGHT;
  1515. // I think this is the crappyest code that ever written
  1516. // but i磎 really sleppy... zzzzzz....
  1517. if(i==0)
  1518. i+=40;
  1519. else
  1520. {
  1521. if(iUseX==0 || iUseY==0)
  1522. {
  1523. if(iUseY == -1 )
  1524. {
  1525. iUseY = 1;
  1526. iUseX = 0;
  1527. }
  1528. else
  1529. if(iUseY == 1)
  1530. {
  1531. iUseX = -1;
  1532. iUseY = 0;
  1533. }
  1534. else
  1535. if(iUseX == -1)
  1536. {
  1537. iUseX = 1;
  1538. iUseY = 0;
  1539. }
  1540. else
  1541. {
  1542. //i+=40;
  1543. iUseX = 1;
  1544. iUseY = 1;
  1545. }
  1546. }
  1547. else
  1548. if(iUseX==1 && iUseY==1)
  1549. {
  1550. iUseX=-1;
  1551. iUseY=1;
  1552. }
  1553. else
  1554. if(iUseX==-1 && iUseY==1)
  1555. {
  1556. iUseX=1;
  1557. iUseY=-1;
  1558. }
  1559. else
  1560. if(iUseX==1 && iUseY==-1)
  1561. {
  1562. iUseX=-1;
  1563. iUseY=-1;
  1564. }
  1565. else
  1566. {
  1567. iUseY = -1;
  1568. iUseX = 0;
  1569. i+=40;
  1570. if(i > 300)
  1571.    return TURN_RIGHT;
  1572. }
  1573. }
  1574. } // while
  1575. return 0;
  1576. }
  1577. */
  1578. void cRaceTrack::GetCheckPointPosition(int *iX, int *iY, int iCheckPoint)
  1579. {
  1580. // This function is used to get the position of an specific check point
  1581. int i, j, iValue;
  1582. for(j=*iY; j<m_iRows; j++)
  1583. {
  1584. for(i=0; i<m_iCols; i++)
  1585. {
  1586. if(j==*iY)
  1587. {
  1588. if(i<*iX)
  1589. {
  1590. i=*iX;
  1591. if(i > m_iCols-1)
  1592. {
  1593. i = 0;
  1594. j++;
  1595. }
  1596. }
  1597. }
  1598. iValue = LOBYTE(HIWORD(m_RoadMap.GetValue(i,j)));
  1599. if(iValue  == iCheckPoint)
  1600. {
  1601. *iX = i*40;
  1602. *iY = j*40;
  1603. /*if(LOWORD(m_RoadMap.GetValue(i,j)) + ID_ROADTYPE_SRACEROADQ0 - 1 == ID_ROADTYPE_ROADQ0)
  1604. *iX = (i*40)+30;
  1605. if(LOWORD(m_RoadMap.GetValue(i,j)) + ID_ROADTYPE_SRACEROADQ0 - 1 == ID_ROADTYPE_ROADQ2)
  1606. *iY = (j*40)+30;
  1607. if(LOWORD(m_RoadMap.GetValue(i,j)) + ID_ROADTYPE_SRACEROADQ0 - 1 == ID_ROADTYPE_ROADQ1)
  1608. *iX = (i*40)-30;
  1609. if(LOWORD(m_RoadMap.GetValue(i,j)) + ID_ROADTYPE_SRACEROADQ0 - 1 == ID_ROADTYPE_ROADQ3)
  1610. *iY = (j*40)-30;*/
  1611. return;
  1612. }
  1613. }
  1614. }
  1615. *iX = -1;
  1616. *iY = -1;
  1617. return;
  1618. }
  1619. char* cRaceTrack::GetTrackName()
  1620. {
  1621. return m_sTrackName;
  1622. }
  1623. int cRaceTrack::GetNumberOfLaps()
  1624. {
  1625. return m_iLaps;
  1626. }
  1627. int cRaceTrack::GetNumberOfCars()
  1628. {
  1629. return m_iNumCars;
  1630. }
  1631. int cRaceTrack::GetWidth()
  1632. {
  1633. return m_iCols * 40;
  1634. }
  1635. int cRaceTrack::GetHeight()
  1636. {
  1637. return m_iRows * 40;
  1638. }
  1639. char* cRaceTrack::GetFileName()
  1640. {
  1641. return &m_sFileName[0];
  1642. }
  1643. void cRaceTrack::SetCarInfo(BYTE bID, BYTE bMask, 
  1644. DWORD   dwElapseTime,
  1645. BYTE bLaps,
  1646. int iSpeed,
  1647. BYTE bCarPosition,
  1648. DWORD dwLastLapTime,
  1649. unsigned short nCarX,
  1650. unsigned short nCarY,
  1651. BYTE bAngle,
  1652. BYTE bCarState
  1653. )
  1654. {
  1655. // This function is used to set the car information
  1656. // Its used on multiplayer game only. If the peer receive a messgae
  1657. // from the host machine with the car information, we need to set this
  1658. // information for each one of the cars.
  1659. for(int i=0;i<m_iNumCars;i++)
  1660. {
  1661. if(m_pRaceCars[i]->GetID() == bID)
  1662. {
  1663. if(bMask & 0x01)
  1664. m_pRaceCars[i]->m_iLaps = bLaps;
  1665. if(bMask & 0x02)
  1666. m_pRaceCars[i]->SetSpeed(iSpeed * 10);
  1667. if(bMask & 0x04)
  1668. m_pRaceCars[i]->SetPosition(bCarPosition);
  1669. if(bMask & 0x08)
  1670. {
  1671. if(dwLastLapTime != 0)
  1672. m_pRaceCars[i]->AddLapTime(dwLastLapTime);
  1673. }
  1674. int iX, iY;
  1675. m_pRaceCars[i]->GetPos(&iX, &iY);
  1676. if(bMask & 0x10)
  1677. iX = nCarX;
  1678. if(bMask & 0x20)
  1679. iY = nCarY;
  1680. m_pRaceCars[i]->SetPos(iX, iY);
  1681. if(bMask & 0x40)
  1682. {
  1683. m_pRaceCars[i]->m_sprCar.m_iAbsolutePosition = bAngle;
  1684. m_pRaceCars[i]->m_iAngle = bAngle * 10;
  1685. }
  1686. if(bMask & 0x80)
  1687. m_pRaceCars[i]->SetCarState(bCarState);
  1688. m_pRaceCars[i]->m_dwElapseTime = dwElapseTime;
  1689. return;
  1690. }
  1691. }
  1692. }
  1693. int cRaceTrack::GetAngle(int iX, int iY)
  1694. {
  1695. iX = iX / 40;
  1696. iY = iY / 40;
  1697. if(iX < 0)
  1698. return 0;
  1699. if(iY < 0)
  1700. return 0;
  1701. if(iX > m_iCols-1)
  1702. return 0;
  1703. if(iY > m_iRows-1)
  1704. return 0;
  1705. // Get the angle associated with each one of the tiles
  1706. // The angle is used to tell the computer where to head when he is driving
  1707. // This is used only in single player mode
  1708. int iResp = m_RoadMap.GetValue((int)iX,(int)iY);
  1709. iResp = HIBYTE(HIWORD(iResp)) * 10;
  1710. return iResp;
  1711. }
  1712. void cRaceTrack::SetRemoteKeyboardStatus(BYTE bIdCar, BYTE bStatus)
  1713. {
  1714. // When we receive the keyboard status of a peer, we set the member variable
  1715. for(int i=0;i<m_iNumCars;i++)
  1716. {
  1717. if(m_pRaceCars[i]->GetID() == bIdCar)
  1718. {
  1719. m_pRaceCars[i]->m_bRemoteKeyboardStatus = bStatus;
  1720. return;
  1721. }
  1722. }
  1723. }
  1724. BYTE cRaceTrack::GetLocalCarID()
  1725. {
  1726. // Get the ID of the local car
  1727. for(int i=0;i<m_iNumCars;i++)
  1728. {
  1729. if(m_pRaceCars[i]->GetControlType() == CTRL_NETWORK_LOCAL || 
  1730. m_pRaceCars[i]->GetControlType() == CTRL_USER)
  1731. {
  1732. return m_pRaceCars[i]->m_bID;
  1733. }
  1734. }
  1735. return -1;
  1736. }