25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

169 lines
5.6 KiB

  1. /**********************************************************************************************
  2. *
  3. * raylib - Advance Game template
  4. *
  5. * Gameplay Screen Functions Definitions (Init, Update, Draw, Unload)
  6. *
  7. * Copyright (c) 2014-2020 Ramon Santamaria (@raysan5)
  8. *
  9. * This software is provided "as-is", without any express or implied warranty. In no event
  10. * will the authors be held liable for any damages arising from the use of this software.
  11. *
  12. * Permission is granted to anyone to use this software for any purpose, including commercial
  13. * applications, and to alter it and redistribute it freely, subject to the following restrictions:
  14. *
  15. * 1. The origin of this software must not be misrepresented; you must not claim that you
  16. * wrote the original software. If you use this software in a product, an acknowledgment
  17. * in the product documentation would be appreciated but is not required.
  18. *
  19. * 2. Altered source versions must be plainly marked as such, and must not be misrepresented
  20. * as being the original software.
  21. *
  22. * 3. This notice may not be removed or altered from any source distribution.
  23. *
  24. **********************************************************************************************/
  25. #include "raylib.h"
  26. #include "screens.h"
  27. static bool doHairCut = false;
  28. static bool doHairTint = false;
  29. static bool doEyeLiner = false;
  30. static bool doLipStick = false;
  31. static bool doNose = false;
  32. static bool doGlasses = false;
  33. //----------------------------------------------------------------------------------
  34. // Global Variables Definition (local to this module)
  35. //----------------------------------------------------------------------------------
  36. const unsigned int headColors[6] = { 0xffe29bff, 0xfed5a8ff, 0xad8962ff, 0xfff1b8ff, 0xffd6c4ff, 0xd49c8dff };
  37. const unsigned int hairColors[10] = { 0xf5bf60ff, 0xaa754aff, 0x974e14ff, 0xf36347ff, 0x87f347ff, 0xfc48d0ff, 0x3b435dff, 0x5f5e60ff, 0xe7e7e7ff, 0xfb386bff };
  38. // Gameplay screen global variables
  39. static int framesCounter = 0;
  40. static int finishScreen = 0;
  41. static RenderTexture target = { 0 };
  42. //----------------------------------------------------------------------------------
  43. // Gameplay Screen Functions Definition
  44. //----------------------------------------------------------------------------------
  45. // Gameplay Screen Initialization logic
  46. void InitGameplayScreen(void)
  47. {
  48. // Initialize GAMEPLAY screen variables
  49. framesCounter = 0;
  50. finishScreen = 0;
  51. target = LoadRenderTexture(720, 720);
  52. SetTextureFilter(target.texture, FILTER_BILINEAR);
  53. // Generate player character!
  54. //player = GenerateCharacter();
  55. playerBase = player;
  56. // Generate dating character!
  57. dating = GenerateCharacter();
  58. datingBase = dating;
  59. // TODO: Generate dating character likes
  60. // For the different types of properties we assign random like values: 0% (total-dislike) -> 100% (total-like)
  61. // The total match point will be the (like accumulated amount)/(num properties)
  62. // Some of the elements add points or remove points
  63. // At the end we can show the like percentadge of every element
  64. doHairCut = false;
  65. doHairTint = false;
  66. doEyeLiner = false;
  67. doLipStick = false;
  68. doNose = false;
  69. doGlasses = false;
  70. }
  71. // Gameplay Screen Update logic
  72. void UpdateGameplayScreen(void)
  73. {
  74. if (IsKeyPressed(KEY_SPACE))
  75. {
  76. player = GenerateCharacter();
  77. playerBase = player;
  78. }
  79. if (IsKeyPressed(KEY_ENTER)) finishScreen = 1;
  80. }
  81. // Gameplay Screen Draw logic
  82. void DrawGameplayScreen(void)
  83. {
  84. // Draw background
  85. DrawTexture(background, 0, 0, GetColor(0xf6aa60ff));
  86. // Draw left menu buttons
  87. GuiButton((Rectangle){ 20, 40, 300, 60 }, "RE-TOUCH:", 2);
  88. if (GuiButton((Rectangle){ 20, 40 + 90, 300, 80 }, "HAIR TINT", doHairTint? 3 : -1))
  89. {
  90. doHairTint = true;
  91. player.colHair = hairColors[GetRandomValue(0, 9)];
  92. }
  93. if (GuiButton((Rectangle){ 20, 40 + 180, 300, 80 }, "HAIR", doHairCut? 3 : -1))
  94. {
  95. doHairCut = true;
  96. player.hair = GetRandomValue(0, texHair.width/BASE_HAIR_WIDTH);
  97. }
  98. if (GuiButton((Rectangle){ 20, 40 + 270, 300, 80 }, "EYES", doEyeLiner? 3 : -1))
  99. {
  100. doEyeLiner = true;
  101. player.eyes = GetRandomValue(0, texEyes.width/BASE_EYES_WIDTH - 1);
  102. }
  103. if (GuiButton((Rectangle){ 20, 40 + 360, 300, 80 }, "NOSE", doNose? 3 : -1))
  104. {
  105. doNose = true;
  106. player.nose = GetRandomValue(0, texNose.width/BASE_NOSE_WIDTH - 1);
  107. }
  108. if (GuiButton((Rectangle){ 20, 40 + 450, 300, 80 }, "LIPS", doLipStick? 3 : -1))
  109. {
  110. doLipStick = true;
  111. player.mouth = GetRandomValue(0, texMouth.width/BASE_MOUTH_WIDTH - 1);
  112. }
  113. if (GuiButton((Rectangle){ 20, 40 + 540, 300, 80 }, "GLASSES", 3))
  114. {
  115. doGlasses = true;
  116. }
  117. // Draw player
  118. DrawCharacter(player, (Vector2){ GetScreenWidth()/2 - 125, 80 });
  119. // Draw dating view
  120. GuiButton((Rectangle){ 970, 40, 260, 60 }, "DATING:", 2);
  121. GuiButton((Rectangle){ 970, 40 + 70, 260, 260 }, " ", 0);
  122. BeginTextureMode(target);
  123. DrawCharacter(dating, (Vector2){ (720 - 250)/2, (720 - 500)/2 });
  124. EndTextureMode();
  125. DrawTexturePro(target.texture, (Rectangle){ 0.0f, 0.0f, (float)target.texture.width, (float)-target.texture.height }, (Rectangle){ 970, 40 + 70, 260, 260 }, (Vector2){ 0, 0 }, 0.0f, WHITE);
  126. // Draw left button: date!
  127. if (GuiButton((Rectangle){ 970, 580, 260, 90 }, "GO DATE!", -1))
  128. {
  129. finishScreen = 1;
  130. }
  131. }
  132. // Gameplay Screen Unload logic
  133. void UnloadGameplayScreen(void)
  134. {
  135. // Unload required textures
  136. }
  137. // Gameplay Screen should finish?
  138. int FinishGameplayScreen(void)
  139. {
  140. return finishScreen;
  141. }