You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

580 lines
23 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. /*******************************************************************************************
  2. *
  3. * raylib - sample game: asteroids
  4. *
  5. * Sample game developed by Ian Eito, Albert Martos and Ramon Santamaria
  6. *
  7. * This game has been created using raylib v1.3 (www.raylib.com)
  8. * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
  9. *
  10. * Copyright (c) 2015 Ramon Santamaria (@raysan5)
  11. *
  12. ********************************************************************************************/
  13. #include "raylib.h"
  14. #include <math.h>
  15. #if defined(PLATFORM_ANDROID)
  16. #include "android_native_app_glue.h"
  17. #endif
  18. #if defined(PLATFORM_WEB)
  19. #include <emscripten/emscripten.h>
  20. #endif
  21. //----------------------------------------------------------------------------------
  22. // Some Defines
  23. //----------------------------------------------------------------------------------
  24. #define PLAYER_BASE_SIZE 20.0f
  25. #define PLAYER_SPEED 6.0f
  26. #define PLAYER_MAX_SHOOTS 10
  27. #define METEORS_SPEED 2
  28. #define MAX_BIG_METEORS 4
  29. #define MAX_MEDIUM_METEORS 8
  30. #define MAX_SMALL_METEORS 16
  31. //----------------------------------------------------------------------------------
  32. // Types and Structures Definition
  33. //----------------------------------------------------------------------------------
  34. typedef struct Player {
  35. Vector2 position;
  36. Vector2 speed;
  37. float acceleration;
  38. float rotation;
  39. Vector3 collider;
  40. Color color;
  41. } Player;
  42. typedef struct Shoot {
  43. Vector2 position;
  44. Vector2 speed;
  45. float radius;
  46. float rotation;
  47. int lifeSpawn;
  48. bool active;
  49. Color color;
  50. } Shoot;
  51. typedef struct Meteor {
  52. Vector2 position;
  53. Vector2 speed;
  54. float radius;
  55. bool active;
  56. Color color;
  57. } Meteor;
  58. //------------------------------------------------------------------------------------
  59. // Global Variables Declaration
  60. //------------------------------------------------------------------------------------
  61. static int screenWidth = 800;
  62. static int screenHeight = 450;
  63. static bool gameOver;
  64. static bool pause;
  65. static bool victory;
  66. // NOTE: Defined triangle is isosceles with common angles of 70 degrees.
  67. static float shipHeight;
  68. static Player player;
  69. static Shoot shoot[PLAYER_MAX_SHOOTS];
  70. static Meteor bigMeteor[MAX_BIG_METEORS];
  71. static Meteor mediumMeteor[MAX_MEDIUM_METEORS];
  72. static Meteor smallMeteor[MAX_SMALL_METEORS];
  73. static int midMeteorsCount;
  74. static int smallMeteorsCount;
  75. static int destroyedMeteorsCount;
  76. //------------------------------------------------------------------------------------
  77. // Module Functions Declaration (local)
  78. //------------------------------------------------------------------------------------
  79. static void InitGame(void); // Initialize game
  80. static void UpdateGame(void); // Update game (one frame)
  81. static void DrawGame(void); // Draw game (one frame)
  82. static void UnloadGame(void); // Unload game
  83. static void UpdateDrawFrame(void); // Update and Draw (one frame)
  84. //------------------------------------------------------------------------------------
  85. // Program main entry point
  86. //------------------------------------------------------------------------------------
  87. #if defined(PLATFORM_ANDROID)
  88. void android_main(struct android_app *app)
  89. #else
  90. int main(void)
  91. #endif
  92. {
  93. // Initialization
  94. //---------------------------------------------------------
  95. #if defined(PLATFORM_ANDROID)
  96. InitWindow(screenWidth, screenHeight, app);
  97. #else
  98. InitWindow(screenWidth, screenHeight, "sample game: asteroids");
  99. #endif
  100. InitGame();
  101. #if defined(PLATFORM_WEB)
  102. emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
  103. #else
  104. SetTargetFPS(60);
  105. //--------------------------------------------------------------------------------------
  106. // Main game loop
  107. while (!WindowShouldClose()) // Detect window close button or ESC key
  108. {
  109. // Update and Draw
  110. //----------------------------------------------------------------------------------
  111. UpdateDrawFrame();
  112. //----------------------------------------------------------------------------------
  113. }
  114. #endif
  115. // De-Initialization
  116. //--------------------------------------------------------------------------------------
  117. UnloadGame(); // Unload loaded data (textures, sounds, models...)
  118. CloseWindow(); // Close window and OpenGL context
  119. //--------------------------------------------------------------------------------------
  120. #if !defined(PLATFORM_ANDROID)
  121. return 0;
  122. #endif
  123. }
  124. //------------------------------------------------------------------------------------
  125. // Module Functions Definitions (local)
  126. //------------------------------------------------------------------------------------
  127. // Initialize game variables
  128. void InitGame(void)
  129. {
  130. int posx, posy;
  131. int velx, vely;
  132. bool correctRange = false;
  133. victory = false;
  134. pause = false;
  135. shipHeight = (PLAYER_BASE_SIZE/2)/tanf(20*DEG2RAD);
  136. // Initialization player
  137. player.position = (Vector2){screenWidth/2, screenHeight/2 - shipHeight/2};
  138. player.speed = (Vector2){0, 0};
  139. player.acceleration = 0;
  140. player.rotation = 0;
  141. player.collider = (Vector3){player.position.x + sin(player.rotation*DEG2RAD)*(shipHeight/2.5f), player.position.y - cos(player.rotation*DEG2RAD)*(shipHeight/2.5f), 12};
  142. player.color = LIGHTGRAY;
  143. destroyedMeteorsCount = 0;
  144. // Initialization shoot
  145. for (int i = 0; i < PLAYER_MAX_SHOOTS; i++)
  146. {
  147. shoot[i].position = (Vector2){0, 0};
  148. shoot[i].speed = (Vector2){0, 0};
  149. shoot[i].radius = 2;
  150. shoot[i].active = false;
  151. shoot[i].lifeSpawn = 0;
  152. shoot[i].color = WHITE;
  153. }
  154. for (int i = 0; i < MAX_BIG_METEORS; i++)
  155. {
  156. posx = GetRandomValue(0, screenWidth);
  157. while(!correctRange)
  158. {
  159. if (posx > screenWidth/2 - 150 && posx < screenWidth/2 + 150) posx = GetRandomValue(0, screenWidth);
  160. else correctRange = true;
  161. }
  162. correctRange = false;
  163. posy = GetRandomValue(0, screenHeight);
  164. while(!correctRange)
  165. {
  166. if (posy > screenHeight/2 - 150 && posy < screenHeight/2 + 150) posy = GetRandomValue(0, screenHeight);
  167. else correctRange = true;
  168. }
  169. bigMeteor[i].position = (Vector2){posx, posy};
  170. correctRange = false;
  171. velx = GetRandomValue(-METEORS_SPEED, METEORS_SPEED);
  172. vely = GetRandomValue(-METEORS_SPEED, METEORS_SPEED);
  173. while(!correctRange)
  174. {
  175. if (velx == 0 && vely == 0)
  176. {
  177. velx = GetRandomValue(-METEORS_SPEED, METEORS_SPEED);
  178. vely = GetRandomValue(-METEORS_SPEED, METEORS_SPEED);
  179. }
  180. else correctRange = true;
  181. }
  182. bigMeteor[i].speed = (Vector2){velx, vely};
  183. bigMeteor[i].radius = 40;
  184. bigMeteor[i].active = true;
  185. bigMeteor[i].color = BLUE;
  186. }
  187. for (int i = 0; i < MAX_MEDIUM_METEORS; i++)
  188. {
  189. mediumMeteor[i].position = (Vector2){-100, -100};
  190. mediumMeteor[i].speed = (Vector2){0,0};
  191. mediumMeteor[i].radius = 20;
  192. mediumMeteor[i].active = false;
  193. mediumMeteor[i].color = BLUE;
  194. }
  195. for (int i = 0; i < MAX_SMALL_METEORS; i++)
  196. {
  197. smallMeteor[i].position = (Vector2){-100, -100};
  198. smallMeteor[i].speed = (Vector2){0,0};
  199. smallMeteor[i].radius = 10;
  200. smallMeteor[i].active = false;
  201. smallMeteor[i].color = BLUE;
  202. }
  203. midMeteorsCount = 0;
  204. smallMeteorsCount = 0;
  205. }
  206. // Update game (one frame)
  207. void UpdateGame(void)
  208. {
  209. if (!gameOver)
  210. {
  211. if (IsKeyPressed('P')) pause = !pause;
  212. if (!pause)
  213. {
  214. // Player logic: rotation
  215. if (IsKeyDown(KEY_LEFT)) player.rotation -= 5;
  216. if (IsKeyDown(KEY_RIGHT)) player.rotation += 5;
  217. // Player logic: speed
  218. player.speed.x = sin(player.rotation*DEG2RAD)*PLAYER_SPEED;
  219. player.speed.y = cos(player.rotation*DEG2RAD)*PLAYER_SPEED;
  220. // Player logic: acceleration
  221. if (IsKeyDown(KEY_UP))
  222. {
  223. if (player.acceleration < 1) player.acceleration += 0.04f;
  224. }
  225. else
  226. {
  227. if (player.acceleration > 0) player.acceleration -= 0.02f;
  228. else if (player.acceleration < 0) player.acceleration = 0;
  229. }
  230. if (IsKeyDown(KEY_DOWN))
  231. {
  232. if (player.acceleration > 0) player.acceleration -= 0.04f;
  233. else if (player.acceleration < 0) player.acceleration = 0;
  234. }
  235. // Player logic: movement
  236. player.position.x += (player.speed.x*player.acceleration);
  237. player.position.y -= (player.speed.y*player.acceleration);
  238. // Collision logic: player vs walls
  239. if (player.position.x > screenWidth + shipHeight) player.position.x = -(shipHeight);
  240. else if (player.position.x < -(shipHeight)) player.position.x = screenWidth + shipHeight;
  241. if (player.position.y > (screenHeight + shipHeight)) player.position.y = -(shipHeight);
  242. else if (player.position.y < -(shipHeight)) player.position.y = screenHeight + shipHeight;
  243. // Player shoot logic
  244. if (IsKeyPressed(KEY_SPACE))
  245. {
  246. for (int i = 0; i < PLAYER_MAX_SHOOTS; i++)
  247. {
  248. if (!shoot[i].active)
  249. {
  250. shoot[i].position = (Vector2){ player.position.x + sin(player.rotation*DEG2RAD)*(shipHeight), player.position.y - cos(player.rotation*DEG2RAD)*(shipHeight) };
  251. shoot[i].active = true;
  252. shoot[i].speed.x = 1.5*sin(player.rotation*DEG2RAD)*PLAYER_SPEED;
  253. shoot[i].speed.y = 1.5*cos(player.rotation*DEG2RAD)*PLAYER_SPEED;
  254. shoot[i].rotation = player.rotation;
  255. break;
  256. }
  257. }
  258. }
  259. // Shoot life timer
  260. for (int i = 0; i < PLAYER_MAX_SHOOTS; i++)
  261. {
  262. if (shoot[i].active) shoot[i].lifeSpawn++;
  263. }
  264. // Shot logic
  265. for (int i = 0; i < PLAYER_MAX_SHOOTS; i++)
  266. {
  267. if (shoot[i].active)
  268. {
  269. // Movement
  270. shoot[i].position.x += shoot[i].speed.x;
  271. shoot[i].position.y -= shoot[i].speed.y;
  272. // Collision logic: shoot vs walls
  273. if (shoot[i].position.x > screenWidth + shoot[i].radius)
  274. {
  275. shoot[i].active = false;
  276. shoot[i].lifeSpawn = 0;
  277. }
  278. else if (shoot[i].position.x < 0 - shoot[i].radius)
  279. {
  280. shoot[i].active = false;
  281. shoot[i].lifeSpawn = 0;
  282. }
  283. if (shoot[i].position.y > screenHeight + shoot[i].radius)
  284. {
  285. shoot[i].active = false;
  286. shoot[i].lifeSpawn = 0;
  287. }
  288. else if (shoot[i].position.y < 0 - shoot[i].radius)
  289. {
  290. shoot[i].active = false;
  291. shoot[i].lifeSpawn = 0;
  292. }
  293. // Life of shoot
  294. if (shoot[i].lifeSpawn >= 60)
  295. {
  296. shoot[i].position = (Vector2){0, 0};
  297. shoot[i].speed = (Vector2){0, 0};
  298. shoot[i].lifeSpawn = 0;
  299. shoot[i].active = false;
  300. }
  301. }
  302. }
  303. // Collision logic: player vs meteors
  304. player.collider = (Vector3){player.position.x + sin(player.rotation*DEG2RAD)*(shipHeight/2.5f), player.position.y - cos(player.rotation*DEG2RAD)*(shipHeight/2.5f), 12};
  305. for (int a = 0; a < MAX_BIG_METEORS; a++)
  306. {
  307. if (CheckCollisionCircles((Vector2){player.collider.x, player.collider.y}, player.collider.z, bigMeteor[a].position, bigMeteor[a].radius) && bigMeteor[a].active) gameOver = true;
  308. }
  309. for (int a = 0; a < MAX_MEDIUM_METEORS; a++)
  310. {
  311. if (CheckCollisionCircles((Vector2){player.collider.x, player.collider.y}, player.collider.z, mediumMeteor[a].position, mediumMeteor[a].radius) && mediumMeteor[a].active) gameOver = true;
  312. }
  313. for (int a = 0; a < MAX_SMALL_METEORS; a++)
  314. {
  315. if (CheckCollisionCircles((Vector2){player.collider.x, player.collider.y}, player.collider.z, smallMeteor[a].position, smallMeteor[a].radius) && smallMeteor[a].active) gameOver = true;
  316. }
  317. // Meteors logic: big meteors
  318. for (int i = 0; i < MAX_BIG_METEORS; i++)
  319. {
  320. if (bigMeteor[i].active)
  321. {
  322. // Movement
  323. bigMeteor[i].position.x += bigMeteor[i].speed.x;
  324. bigMeteor[i].position.y += bigMeteor[i].speed.y;
  325. // Collision logic: meteor vs wall
  326. if (bigMeteor[i].position.x > screenWidth + bigMeteor[i].radius) bigMeteor[i].position.x = -(bigMeteor[i].radius);
  327. else if (bigMeteor[i].position.x < 0 - bigMeteor[i].radius) bigMeteor[i].position.x = screenWidth + bigMeteor[i].radius;
  328. if (bigMeteor[i].position.y > screenHeight + bigMeteor[i].radius) bigMeteor[i].position.y = -(bigMeteor[i].radius);
  329. else if (bigMeteor[i].position.y < 0 - bigMeteor[i].radius) bigMeteor[i].position.y = screenHeight + bigMeteor[i].radius;
  330. }
  331. }
  332. // Meteors logic: medium meteors
  333. for (int i = 0; i < MAX_MEDIUM_METEORS; i++)
  334. {
  335. if (mediumMeteor[i].active)
  336. {
  337. // Movement
  338. mediumMeteor[i].position.x += mediumMeteor[i].speed.x;
  339. mediumMeteor[i].position.y += mediumMeteor[i].speed.y;
  340. // Collision logic: meteor vs wall
  341. if (mediumMeteor[i].position.x > screenWidth + mediumMeteor[i].radius) mediumMeteor[i].position.x = -(mediumMeteor[i].radius);
  342. else if (mediumMeteor[i].position.x < 0 - mediumMeteor[i].radius) mediumMeteor[i].position.x = screenWidth + mediumMeteor[i].radius;
  343. if (mediumMeteor[i].position.y > screenHeight + mediumMeteor[i].radius) mediumMeteor[i].position.y = -(mediumMeteor[i].radius);
  344. else if (mediumMeteor[i].position.y < 0 - mediumMeteor[i].radius) mediumMeteor[i].position.y = screenHeight + mediumMeteor[i].radius;
  345. }
  346. }
  347. // Meteors logic: small meteors
  348. for (int i = 0; i < MAX_SMALL_METEORS; i++)
  349. {
  350. if (smallMeteor[i].active)
  351. {
  352. // Movement
  353. smallMeteor[i].position.x += smallMeteor[i].speed.x;
  354. smallMeteor[i].position.y += smallMeteor[i].speed.y;
  355. // Collision logic: meteor vs wall
  356. if (smallMeteor[i].position.x > screenWidth + smallMeteor[i].radius) smallMeteor[i].position.x = -(smallMeteor[i].radius);
  357. else if (smallMeteor[i].position.x < 0 - smallMeteor[i].radius) smallMeteor[i].position.x = screenWidth + smallMeteor[i].radius;
  358. if (smallMeteor[i].position.y > screenHeight + smallMeteor[i].radius) smallMeteor[i].position.y = -(smallMeteor[i].radius);
  359. else if (smallMeteor[i].position.y < 0 - smallMeteor[i].radius) smallMeteor[i].position.y = screenHeight + smallMeteor[i].radius;
  360. }
  361. }
  362. // Collision logic: player-shoots vs meteors
  363. for (int i = 0; i < PLAYER_MAX_SHOOTS; i++)
  364. {
  365. if ((shoot[i].active))
  366. {
  367. for (int a = 0; a < MAX_BIG_METEORS; a++)
  368. {
  369. if (bigMeteor[a].active && CheckCollisionCircles(shoot[i].position, shoot[i].radius, bigMeteor[a].position, bigMeteor[a].radius))
  370. {
  371. shoot[i].active = false;
  372. shoot[i].lifeSpawn = 0;
  373. bigMeteor[a].active = false;
  374. destroyedMeteorsCount++;
  375. for (int j = 0; j < 2; j ++)
  376. {
  377. if (midMeteorsCount%2 == 0)
  378. {
  379. mediumMeteor[midMeteorsCount].position = (Vector2){bigMeteor[a].position.x, bigMeteor[a].position.y};
  380. mediumMeteor[midMeteorsCount].speed = (Vector2){cos(shoot[i].rotation*DEG2RAD)*METEORS_SPEED*-1, sin(shoot[i].rotation*DEG2RAD)*METEORS_SPEED*-1};
  381. }
  382. else
  383. {
  384. mediumMeteor[midMeteorsCount].position = (Vector2){bigMeteor[a].position.x, bigMeteor[a].position.y};
  385. mediumMeteor[midMeteorsCount].speed = (Vector2){cos(shoot[i].rotation*DEG2RAD)*METEORS_SPEED, sin(shoot[i].rotation*DEG2RAD)*METEORS_SPEED};
  386. }
  387. mediumMeteor[midMeteorsCount].active = true;
  388. midMeteorsCount ++;
  389. }
  390. //bigMeteor[a].position = (Vector2){-100, -100};
  391. bigMeteor[a].color = RED;
  392. a = MAX_BIG_METEORS;
  393. }
  394. }
  395. for (int b = 0; b < MAX_MEDIUM_METEORS; b++)
  396. {
  397. if (mediumMeteor[b].active && CheckCollisionCircles(shoot[i].position, shoot[i].radius, mediumMeteor[b].position, mediumMeteor[b].radius))
  398. {
  399. shoot[i].active = false;
  400. shoot[i].lifeSpawn = 0;
  401. mediumMeteor[b].active = false;
  402. destroyedMeteorsCount++;
  403. for (int j = 0; j < 2; j ++)
  404. {
  405. if (smallMeteorsCount%2 == 0)
  406. {
  407. smallMeteor[smallMeteorsCount].position = (Vector2){mediumMeteor[b].position.x, mediumMeteor[b].position.y};
  408. smallMeteor[smallMeteorsCount].speed = (Vector2){cos(shoot[i].rotation*DEG2RAD)*METEORS_SPEED*-1, sin(shoot[i].rotation*DEG2RAD)*METEORS_SPEED*-1};
  409. }
  410. else
  411. {
  412. smallMeteor[smallMeteorsCount].position = (Vector2){mediumMeteor[b].position.x, mediumMeteor[b].position.y};
  413. smallMeteor[smallMeteorsCount].speed = (Vector2){cos(shoot[i].rotation*DEG2RAD)*METEORS_SPEED, sin(shoot[i].rotation*DEG2RAD)*METEORS_SPEED};
  414. }
  415. smallMeteor[smallMeteorsCount].active = true;
  416. smallMeteorsCount ++;
  417. }
  418. //mediumMeteor[b].position = (Vector2){-100, -100};
  419. mediumMeteor[b].color = GREEN;
  420. b = MAX_MEDIUM_METEORS;
  421. }
  422. }
  423. for (int c = 0; c < MAX_SMALL_METEORS; c++)
  424. {
  425. if (smallMeteor[c].active && CheckCollisionCircles(shoot[i].position, shoot[i].radius, smallMeteor[c].position, smallMeteor[c].radius))
  426. {
  427. shoot[i].active = false;
  428. shoot[i].lifeSpawn = 0;
  429. smallMeteor[c].active = false;
  430. destroyedMeteorsCount++;
  431. smallMeteor[c].color = YELLOW;
  432. // smallMeteor[c].position = (Vector2){-100, -100};
  433. c = MAX_SMALL_METEORS;
  434. }
  435. }
  436. }
  437. }
  438. }
  439. if (destroyedMeteorsCount == MAX_BIG_METEORS + MAX_MEDIUM_METEORS + MAX_SMALL_METEORS) victory = true;
  440. }
  441. else
  442. {
  443. if (IsKeyPressed(KEY_ENTER))
  444. {
  445. InitGame();
  446. gameOver = false;
  447. }
  448. }
  449. }
  450. // Draw game (one frame)
  451. void DrawGame(void)
  452. {
  453. BeginDrawing();
  454. ClearBackground(RAYWHITE);
  455. if (!gameOver)
  456. {
  457. // Draw spaceship
  458. Vector2 v1 = { player.position.x + sinf(player.rotation*DEG2RAD)*(shipHeight), player.position.y - cosf(player.rotation*DEG2RAD)*(shipHeight) };
  459. Vector2 v2 = { player.position.x - cosf(player.rotation*DEG2RAD)*(PLAYER_BASE_SIZE/2), player.position.y - sinf(player.rotation*DEG2RAD)*(PLAYER_BASE_SIZE/2) };
  460. Vector2 v3 = { player.position.x + cosf(player.rotation*DEG2RAD)*(PLAYER_BASE_SIZE/2), player.position.y + sinf(player.rotation*DEG2RAD)*(PLAYER_BASE_SIZE/2) };
  461. DrawTriangle(v1, v2, v3, MAROON);
  462. // Draw meteors
  463. for (int i = 0; i < MAX_BIG_METEORS; i++)
  464. {
  465. if (bigMeteor[i].active) DrawCircleV(bigMeteor[i].position, bigMeteor[i].radius, DARKGRAY);
  466. else DrawCircleV(bigMeteor[i].position, bigMeteor[i].radius, Fade(LIGHTGRAY, 0.3f));
  467. }
  468. for (int i = 0; i < MAX_MEDIUM_METEORS; i++)
  469. {
  470. if (mediumMeteor[i].active) DrawCircleV(mediumMeteor[i].position, mediumMeteor[i].radius, GRAY);
  471. else DrawCircleV(mediumMeteor[i].position, mediumMeteor[i].radius, Fade(LIGHTGRAY, 0.3f));
  472. }
  473. for (int i = 0; i < MAX_SMALL_METEORS; i++)
  474. {
  475. if (smallMeteor[i].active) DrawCircleV(smallMeteor[i].position, smallMeteor[i].radius, GRAY);
  476. else DrawCircleV(smallMeteor[i].position, smallMeteor[i].radius, Fade(LIGHTGRAY, 0.3f));
  477. }
  478. // Draw shoot
  479. for (int i = 0; i < PLAYER_MAX_SHOOTS; i++)
  480. {
  481. if (shoot[i].active) DrawCircleV(shoot[i].position, shoot[i].radius, BLACK);
  482. }
  483. if (victory) DrawText("VICTORY", screenWidth/2 - MeasureText("VICTORY", 20)/2, screenHeight/2, 20, LIGHTGRAY);
  484. if (pause) DrawText("GAME PAUSED", screenWidth/2 - MeasureText("GAME PAUSED", 40)/2, screenHeight/2 - 40, 40, GRAY);
  485. }
  486. else DrawText("PRESS [ENTER] TO PLAY AGAIN", GetScreenWidth()/2 - MeasureText("PRESS [ENTER] TO PLAY AGAIN", 20)/2, GetScreenHeight()/2 - 50, 20, GRAY);
  487. EndDrawing();
  488. }
  489. // Unload game variables
  490. void UnloadGame(void)
  491. {
  492. // TODO: Unload all dynamic loaded data (textures, sounds, models...)
  493. }
  494. // Update and Draw (one frame)
  495. void UpdateDrawFrame(void)
  496. {
  497. UpdateGame();
  498. DrawGame();
  499. }