diff --git a/games/repair/Makefile b/games/repair/Makefile index 5e4dd9d87..2b7065e3b 100644 --- a/games/repair/Makefile +++ b/games/repair/Makefile @@ -52,7 +52,7 @@ RAYLIB_H_INSTALL_PATH ?= $(DESTDIR)/include RAYLIB_LIBTYPE ?= STATIC # Build mode for project: DEBUG or RELEASE -BUILD_MODE ?= DEBUG +BUILD_MODE ?= RELEASE # Use external GLFW library instead of rglfw module # TODO: Review usage on Linux. Target version of choice. Switch on -lglfw or -lglfw3 diff --git a/games/repair/repair.c b/games/repair/repair.c index f66ce6687..df541e349 100644 --- a/games/repair/repair.c +++ b/games/repair/repair.c @@ -30,6 +30,12 @@ NPatchInfo npInfo = { 0 }; Texture2D texHead, texHair, texNose, texMouth, texEyes, texComp; Texture2D texMakeup = { 0 }; +Character playerBase = { 0 }; +Character datingBase = { 0 }; + +Character player = { 0 }; +Character dating = { 0 }; + //---------------------------------------------------------------------------------- // Global Variables Definition (local to this module) //---------------------------------------------------------------------------------- @@ -70,6 +76,8 @@ int main(void) InitAudioDevice(); font = LoadFont("resources/font.png"); + SetTextureFilter(font.texture, FILTER_BILINEAR); + music = LoadMusicStream("resources/elevator_romance.ogg"); fxCoin = LoadSound("resources/coin.wav"); @@ -95,8 +103,8 @@ int main(void) //PlayMusicStream(music); // Setup and Init first screen - currentScreen = TITLE; - InitTitleScreen(); + currentScreen = LOGO; + InitLogoScreen(); #if defined(PLATFORM_WEB) emscripten_set_main_loop(UpdateDrawFrame, 0, 1); @@ -130,6 +138,14 @@ int main(void) UnloadSound(fxCoin); UnloadTexture(background); UnloadTexture(texNPatch); + + UnloadTexture(texHead); + UnloadTexture(texHair); + UnloadTexture(texNose); + UnloadTexture(texMouth); + UnloadTexture(texEyes); + //UnloadTexture(texComp); + UnloadTexture(texMakeup); CloseAudioDevice(); // Close audio context @@ -139,6 +155,91 @@ int main(void) return 0; } +//---------------------------------------------------------------------------------- +// Public Functions Definition +//---------------------------------------------------------------------------------- + +Character GenerateCharacter(void) +{ + Character character = { 0 }; + + // Generate player character! + character.head = GetRandomValue(0, texHead.width/BASE_HEAD_WIDTH - 1); + character.colHead = headColors[GetRandomValue(0, 5)]; + character.hair = GetRandomValue(0, texHair.width/BASE_HAIR_WIDTH - 1); + character.colHair = hairColors[GetRandomValue(0, 9)]; + character.eyes = GetRandomValue(0, texEyes.width/BASE_EYES_WIDTH - 1); + character.nose = GetRandomValue(0, texNose.width/BASE_NOSE_WIDTH - 1); + character.mouth = GetRandomValue(0, texMouth.width/BASE_MOUTH_WIDTH - 1); + + // NOTE: No character customization at this point + + return character; +} + +void CustomizeCharacter(Character *character) +{ + if (GetRandomValue(0, 1)) character->hair = GetRandomValue(0, texHair.width/BASE_HAIR_WIDTH - 1); + if (GetRandomValue(0, 1)) character->colHair = hairColors[GetRandomValue(0, 9)]; + if (GetRandomValue(0, 1)) character->eyes = GetRandomValue(0, texEyes.width/BASE_EYES_WIDTH - 1); + if (GetRandomValue(0, 1)) character->nose = GetRandomValue(0, texNose.width/BASE_NOSE_WIDTH - 1); + if (GetRandomValue(0, 1)) character->mouth = GetRandomValue(0, texMouth.width/BASE_MOUTH_WIDTH - 1); +} + +void DrawCharacter(Character character, Vector2 position) +{ + DrawTextureRec(texHair, (Rectangle){ BASE_HAIR_WIDTH*character.hair, 240, BASE_HAIR_WIDTH, texHair.height - 240 }, (Vector2){ position.x + (250 - BASE_HAIR_WIDTH)/2, position.y + 240 }, GetColor(character.colHair)); + DrawTextureRec(texHead, (Rectangle){ BASE_HEAD_WIDTH*character.head, 0, BASE_HEAD_WIDTH, texHead.height }, (Vector2){ position.x + (250 - BASE_HEAD_WIDTH)/2, position.y + 60 }, GetColor(character.colHead)); + DrawTextureRec(texHair, (Rectangle){ BASE_HAIR_WIDTH*character.hair, 0, BASE_HAIR_WIDTH, 240 }, (Vector2){ position.x + (250 - BASE_HAIR_WIDTH)/2, position.y }, GetColor(character.colHair)); + DrawTextureRec(texEyes, (Rectangle){ BASE_EYES_WIDTH*character.eyes, 0, BASE_EYES_WIDTH, texEyes.height }, (Vector2){ position.x + (250 - BASE_EYES_WIDTH)/2, position.y + 190 }, WHITE); + DrawTextureRec(texNose, (Rectangle){ BASE_NOSE_WIDTH*character.nose, 0, BASE_NOSE_WIDTH, texNose.height }, (Vector2){ position.x + (250 - BASE_NOSE_WIDTH)/2, position.y + 275 }, GetColor(character.colHead)); + DrawTextureRec(texMouth, (Rectangle){ BASE_MOUTH_WIDTH*character.mouth, 0, BASE_MOUTH_WIDTH, texMouth.height }, (Vector2){ position.x + (250 - BASE_MOUTH_WIDTH)/2, position.y + 370 }, GetColor(character.colHead)); +} + +// Gui Button +bool GuiButton(Rectangle bounds, const char *text, int forcedState) +{ + static const int textColor[4] = { 0xeff6ffff, 0x78e782ff, 0xb04d5fff, 0xd6d6d6ff }; + + int state = (forcedState >= 0)? forcedState : 0; // NORMAL + bool pressed = false; + Vector2 textSize = MeasureTextEx(font, text, font.baseSize, 1); + + // Update control + //-------------------------------------------------------------------- + if ((state < 3) && (forcedState < 0)) + { + Vector2 mousePoint = GetMousePosition(); + + // Check button state + if (CheckCollisionPointRec(mousePoint, bounds)) + { + if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = 2; // PRESSED + else state = 1; // FOCUSED + + if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) + { + pressed = true; + PlaySound(fxCoin); + } + } + } + + npInfo.sourceRec.x = 80*state; + + //-------------------------------------------------------------------- + + // Draw control + //-------------------------------------------------------------------- + //DrawRectangleRec(bounds, GREEN); + //DrawRectangleLinesEx(bounds, 4, DARKGREEN); + DrawTextureNPatch(texNPatch, npInfo, bounds, (Vector2){ 0.0f, 0.0f }, 0.0f, WHITE); + DrawTextEx(font, text, (Vector2){ bounds.x + bounds.width/2 - textSize.x/2, bounds.y + bounds.height/2 - textSize.y/2 + 4 }, font.baseSize, 1, GetColor(textColor[state])); + //------------------------------------------------------------------ + + return pressed; +} + //---------------------------------------------------------------------------------- // Module specific Functions Definition //---------------------------------------------------------------------------------- @@ -184,7 +285,7 @@ static void UpdateTransition(void) { if (!transFadeOut) { - transAlpha += 0.02f; + transAlpha += 0.05f; // NOTE: Due to float internal representation, condition jumps on 1.0f instead of 1.05f // For that reason we compare against 1.01f, to avoid last frame loading stop diff --git a/games/repair/resources/match.png b/games/repair/resources/match.png new file mode 100644 index 000000000..c1637fda9 Binary files /dev/null and b/games/repair/resources/match.png differ diff --git a/games/repair/resources/qmark.png b/games/repair/resources/qmark.png new file mode 100644 index 000000000..c782062d9 Binary files /dev/null and b/games/repair/resources/qmark.png differ diff --git a/games/repair/resources/raylib_logo.png b/games/repair/resources/raylib_logo.png index 665456277..99ba54374 100644 Binary files a/games/repair/resources/raylib_logo.png and b/games/repair/resources/raylib_logo.png differ diff --git a/games/repair/screens/screen_ending.c b/games/repair/screens/screen_ending.c index c953fff8f..728e3d285 100644 --- a/games/repair/screens/screen_ending.c +++ b/games/repair/screens/screen_ending.c @@ -26,13 +26,32 @@ #include "raylib.h" #include "screens.h" +typedef struct { + int hair; + int colHair; + int eyes; + int nose; + int mouth; + //int glasses; + //int piercing; +} CharLikes; + //---------------------------------------------------------------------------------- // Global Variables Definition (local to this module) //---------------------------------------------------------------------------------- // Ending screen global variables -static int framesCounter; -static int finishScreen; +static int framesCounter = 0; +static int finishScreen = 0; + +static Texture2D texQmark = { 0 }; +static Texture2D texMatch = { 0 }; + +static int state = 0; +static int matchValue = 0; + +static CharLikes playerLikes = { 0 }; +static CharLikes playerBaseLikes = { 0 }; //---------------------------------------------------------------------------------- // Ending Screen Functions Definition @@ -41,16 +60,80 @@ static int finishScreen; // Ending Screen Initialization logic void InitEndingScreen(void) { - // TODO: Initialize ENDING screen variables here! framesCounter = 0; finishScreen = 0; + state = 0; + + CustomizeCharacter(&dating); + + texQmark = LoadTexture("resources/qmark.png"); + texMatch = LoadTexture("resources/match.png"); } // Ending Screen Update logic void UpdateEndingScreen(void) { - // TODO: Update ENDING screen variables here! - + if (state == 0) + { + framesCounter++; + + if (framesCounter > 200) + { + state = 1; + + // Check like percentatge for player base (playerBaseLikes) + if (playerBase.hair == dating.hair) playerBaseLikes.hair = GetRandomValue(70, 100); + else if (playerBase.hair == datingBase.hair) playerBaseLikes.hair = GetRandomValue(0, 30); + else playerBaseLikes.hair = GetRandomValue(0, 100); + + if (playerBase.colHair == dating.colHair) playerBaseLikes.colHair = GetRandomValue(70, 100); + else if (playerBase.colHair == datingBase.colHair) playerBaseLikes.colHair = GetRandomValue(0, 30); + else playerBaseLikes.colHair = GetRandomValue(0, 100); + + if (playerBase.eyes == dating.eyes) playerBaseLikes.eyes = GetRandomValue(70, 100); + else if (playerBase.eyes == datingBase.eyes) playerBaseLikes.eyes = GetRandomValue(0, 30); + else playerBaseLikes.eyes = GetRandomValue(0, 100); + + if (playerBase.nose == dating.nose) playerBaseLikes.nose = GetRandomValue(70, 100); + else if (playerBase.nose == datingBase.nose) playerBaseLikes.nose = GetRandomValue(0, 30); + else playerBaseLikes.nose = GetRandomValue(0, 100); + + if (playerBase.mouth == dating.mouth) playerBaseLikes.mouth = GetRandomValue(70, 100); + else if (playerBase.mouth == datingBase.mouth) playerBaseLikes.mouth = GetRandomValue(0, 30); + else playerBaseLikes.mouth = GetRandomValue(0, 100); + + + // Check like percentatge for player (playerLikes) + if (player.hair == dating.hair) playerLikes.hair = GetRandomValue(70, 100); + else if (player.hair == datingBase.hair) playerLikes.hair = GetRandomValue(0, 30); + else playerLikes.hair = GetRandomValue(0, 100); + + if (player.colHair == dating.colHair) playerLikes.colHair = GetRandomValue(70, 100); + else if (player.colHair == datingBase.colHair) playerLikes.colHair = GetRandomValue(0, 30); + else playerLikes.colHair = GetRandomValue(0, 100); + + if (player.eyes == dating.eyes) playerLikes.eyes = GetRandomValue(70, 100); + else if (player.eyes == datingBase.eyes) playerLikes.eyes = GetRandomValue(0, 30); + else playerLikes.eyes = GetRandomValue(0, 100); + + if (player.nose == dating.nose) playerLikes.nose = GetRandomValue(70, 100); + else if (player.nose == datingBase.nose) playerLikes.nose = GetRandomValue(0, 30); + else playerLikes.nose = GetRandomValue(0, 100); + + if (player.mouth == dating.mouth) playerLikes.mouth = GetRandomValue(70, 100); + else if (player.mouth == datingBase.mouth) playerLikes.mouth = GetRandomValue(0, 30); + else playerLikes.mouth = GetRandomValue(0, 100); + + // NOTE: Max possible points to get 5*100 = 500 + // If getting > 250 player likes! :D + matchValue = playerLikes.hair + playerLikes.colHair + playerLikes.eyes + playerLikes.nose + playerLikes.mouth; + } + } + else if (state == 1) + { + // Levels animation? + } + // Press enter or tap to return to TITLE screen if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP)) { @@ -62,16 +145,98 @@ void UpdateEndingScreen(void) // Ending Screen Draw logic void DrawEndingScreen(void) { - // TODO: Draw ENDING screen here! - DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), BLUE); - DrawTextEx(font, "ENDING SCREEN", (Vector2){ 20, 10 }, font.baseSize*3, 4, DARKBLUE); - DrawText("PRESS ENTER or TAP to RETURN to TITLE SCREEN", 120, 220, 20, DARKBLUE); + // Draw background + DrawTexture(background, 0, 0, GetColor(0xf6aa60ff)); + + DrawCharacter(player, (Vector2){ 180, 40 }); + + DrawCharacter(dating, (Vector2){ 820, 40 }); + + if (state == 0) + { + if ((framesCounter/15)%2 == 1) DrawTexture(texQmark, GetScreenWidth()/2 - texQmark.width/2, 180, WHITE); + } + else if (state == 1) + { + DrawTextEx(font, TextFormat("MATCH: %i%%", (int)(((float)matchValue/500.0f)*100.0f)), (Vector2){ 420, 40 }, font.baseSize*2, 1, SKYBLUE); + + DrawTextureRec(texMatch, (Rectangle){ 0, (matchValue > 250)? 0 : texMatch.height/2, texMatch.width, texMatch.height/2 }, (Vector2){ GetScreenWidth()/2 - texMatch.width/2, 240 }, WHITE); + + int barsPositionX = 80; + + //DrawRectangle(0, 530, GetScreenWidth(), GetScreenHeight() - 530, Fade(GRAY, 0.6f)); + //DrawRectangleLines(0, 530, GetScreenWidth(), GetScreenHeight() - 530, Fade(DARKGRAY, 0.8f)); + + // Draw like values: player base + DrawTextEx(font, "HAIR:", (Vector2){ barsPositionX, 550 }, font.baseSize/2, 1, WHITE); + DrawRectangle(barsPositionX + 80, 550 + 6, 400, font.baseSize/4, GRAY); + DrawRectangle(barsPositionX + 80, 550 + 6, playerBaseLikes.hair*4, font.baseSize/4, RED); + + DrawTextEx(font, "TINT:", (Vector2){ barsPositionX, 580 }, font.baseSize/2, 1, WHITE); + DrawRectangle(barsPositionX + 80, 580 + 6, 400, font.baseSize/4, GRAY); + DrawRectangle(barsPositionX + 80, 580 + 6, playerBaseLikes.colHair*4, font.baseSize/4, RED); + + DrawTextEx(font, "EYES:", (Vector2){ barsPositionX, 610 }, font.baseSize/2, 1, WHITE); + DrawRectangle(barsPositionX + 80, 610 + 6, 400, font.baseSize/4, GRAY); + DrawRectangle(barsPositionX + 80, 610 + 6, playerBaseLikes.eyes*4, font.baseSize/4, RED); + + DrawTextEx(font, "NOSE:", (Vector2){ barsPositionX, 640 }, font.baseSize/2, 1, WHITE); + DrawRectangle(barsPositionX + 80, 640 + 6, 400, font.baseSize/4, GRAY); + DrawRectangle(barsPositionX + 80, 640 + 6, playerBaseLikes.nose*4, font.baseSize/4, RED); + + DrawTextEx(font, "LIPS:", (Vector2){ barsPositionX, 670 }, font.baseSize/2, 1, WHITE); + DrawRectangle(barsPositionX + 80, 670 + 6, 400, font.baseSize/4, GRAY); + DrawRectangle(barsPositionX + 80, 670 + 6, playerBaseLikes.mouth*4, font.baseSize/4, RED); + + // Draw like values: player + if (player.hair != playerBase.hair) + { + DrawTextEx(font, "after re-touch:", (Vector2){ barsPositionX + 80 + 400 + 20, 550 }, font.baseSize/2, 1, WHITE); + DrawRectangle(barsPositionX + 80 + 400 + 100 + 90, 550 + 6, 400, font.baseSize/4, GRAY); + DrawRectangle(barsPositionX + 80 + 400 + 100 + 90, 550 + 6, playerLikes.hair*4, font.baseSize/4, RED); + } + + if (player.colHair != playerBase.colHair) + { + DrawTextEx(font, "after re-touch:", (Vector2){ barsPositionX + 80 + 400 + 20, 580 }, font.baseSize/2, 1, WHITE); + DrawRectangle(barsPositionX + 80 + 400 + 100 + 90, 580 + 6, 400, font.baseSize/4, GRAY); + DrawRectangle(barsPositionX + 80 + 400 + 100 + 90, 580 + 6, playerLikes.colHair*4, font.baseSize/4, RED); + } + + if (player.eyes != playerBase.eyes) + { + DrawTextEx(font, "after re-touch:", (Vector2){ barsPositionX + 80 + 400 + 20, 610 }, font.baseSize/2, 1, WHITE); + DrawRectangle(barsPositionX + 80 + 400 + 100 + 90, 610 + 6, 400, font.baseSize/4, GRAY); + DrawRectangle(barsPositionX + 80 + 400 + 100 + 90, 610 + 6, playerLikes.eyes*4, font.baseSize/4, RED); + } + + if (player.nose != playerBase.nose) + { + DrawTextEx(font, "after re-touch:", (Vector2){ barsPositionX + 80 + 400 + 20, 640 }, font.baseSize/2, 1, WHITE); + DrawRectangle(barsPositionX + 80 + 400 + 100 + 90, 640 + 6, 400, font.baseSize/4, GRAY); + DrawRectangle(barsPositionX + 80 + 400 + 100 + 90, 640 + 6, playerLikes.nose*4, font.baseSize/4, RED); + } + + if (player.mouth != playerBase.mouth) + { + DrawTextEx(font, "after re-touch:", (Vector2){ barsPositionX + 80 + 400 + 20, 670 }, font.baseSize/2, 1, WHITE); + DrawRectangle(barsPositionX + 80 + 400 + 100 + 90, 670 + 6, 400, font.baseSize/4, GRAY); + DrawRectangle(barsPositionX + 80 + 400 + 100 + 90, 670 + 6, playerLikes.mouth*4, font.baseSize/4, RED); + } + + // Draw left button: date! + if (GuiButton((Rectangle){ GetScreenWidth() - 280, 60, 260, 80 }, "AGAIN!", -1)) + { + finishScreen = 1; + } + } } // Ending Screen Unload logic void UnloadEndingScreen(void) { - // TODO: Unload ENDING screen variables here! + UnloadTexture(texQmark); + UnloadTexture(texMatch); } // Ending Screen should finish? diff --git a/games/repair/screens/screen_gameplay.c b/games/repair/screens/screen_gameplay.c index e531aad5f..9d1c44738 100644 --- a/games/repair/screens/screen_gameplay.c +++ b/games/repair/screens/screen_gameplay.c @@ -30,9 +30,8 @@ static bool doHairCut = false; static bool doHairTint = false; static bool doEyeLiner = false; static bool doLipStick = false; -static bool doMakeup = false; +static bool doNose = false; static bool doGlasses = false; -static bool doPiercing = false; //---------------------------------------------------------------------------------- // Global Variables Definition (local to this module) @@ -45,9 +44,6 @@ const unsigned int hairColors[10] = { 0xf5bf60ff, 0xaa754aff, 0x974e14ff, 0xf363 static int framesCounter = 0; static int finishScreen = 0; -static Character player = { 0 }; -static Character dating = { 0 }; - static RenderTexture target = { 0 }; //---------------------------------------------------------------------------------- @@ -65,10 +61,12 @@ void InitGameplayScreen(void) SetTextureFilter(target.texture, FILTER_BILINEAR); // Generate player character! - player = GenerateCharacter(); + //player = GenerateCharacter(); + playerBase = player; // Generate dating character! dating = GenerateCharacter(); + datingBase = dating; // TODO: Generate dating character likes // For the different types of properties we assign random like values: 0% (total-dislike) -> 100% (total-like) @@ -77,86 +75,76 @@ void InitGameplayScreen(void) // Some of the elements add points or remove points // At the end we can show the like percentadge of every element + + doHairCut = false; + doHairTint = false; + doEyeLiner = false; + doLipStick = false; + doNose = false; + doGlasses = false; } // Gameplay Screen Update logic void UpdateGameplayScreen(void) { - // Update GAMEPLAY screen - - // TODO: Check buttons and checkboxes to update player properties - - if (IsKeyPressed(KEY_SPACE)) player = GenerateCharacter(); - - // Press enter or tap to change to ENDING screen - if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP)) + if (IsKeyPressed(KEY_SPACE)) { - finishScreen = 1; - PlaySound(fxCoin); + player = GenerateCharacter(); + playerBase = player; } + + if (IsKeyPressed(KEY_ENTER)) finishScreen = 1; } // Gameplay Screen Draw logic void DrawGameplayScreen(void) { - // Draw background (texture, color, vignette?) + // Draw background DrawTexture(background, 0, 0, GetColor(0xf6aa60ff)); - // TODO: Draw left menu buttons - if (GuiButton((Rectangle){ 20, 40, 300, 80 }, "HAIR CUT", doHairCut? 3 : -1)) - { - doHairCut = true; - - if (GetRandomValue(0, 100) > 20) player.hair = GetRandomValue(0, texHair.width/BASE_HAIR_WIDTH); - else - { - player.hair = -1; - - // TODO: Play problem sound! - } - } + // Draw left menu buttons + GuiButton((Rectangle){ 20, 40, 300, 60 }, "RE-TOUCH:", 2); + if (GuiButton((Rectangle){ 20, 40 + 90, 300, 80 }, "HAIR TINT", doHairTint? 3 : -1)) { doHairTint = true; player.colHair = hairColors[GetRandomValue(0, 9)]; } - if (GuiButton((Rectangle){ 20, 40 + 180, 300, 80 }, "EYELINER", doEyeLiner? 3 : -1)) + if (GuiButton((Rectangle){ 20, 40 + 180, 300, 80 }, "HAIR", doHairCut? 3 : -1)) + { + doHairCut = true; + player.hair = GetRandomValue(0, texHair.width/BASE_HAIR_WIDTH); + + } + if (GuiButton((Rectangle){ 20, 40 + 270, 300, 80 }, "EYES", doEyeLiner? 3 : -1)) { doEyeLiner = true; + player.eyes = GetRandomValue(0, texEyes.width/BASE_EYES_WIDTH - 1); } - if (GuiButton((Rectangle){ 20, 40 + 270, 300, 80 }, "LIPSTICK", doLipStick? 3 : -1)) + if (GuiButton((Rectangle){ 20, 40 + 360, 300, 80 }, "NOSE", doNose? 3 : -1)) + { + doNose = true; + player.nose = GetRandomValue(0, texNose.width/BASE_NOSE_WIDTH - 1); + } + if (GuiButton((Rectangle){ 20, 40 + 450, 300, 80 }, "LIPS", doLipStick? 3 : -1)) { doLipStick = true; + player.mouth = GetRandomValue(0, texMouth.width/BASE_MOUTH_WIDTH - 1); } - if (GuiButton((Rectangle){ 20, 40 + 360, 300, 80 }, "MAKEUP", doMakeup? 3 : -1)) - { - doMakeup = true; - player.makeup = GetRandomValue(1, 2); - } - if (GuiButton((Rectangle){ 20, 40 + 540, 300, 80 }, "GLASSES", doGlasses? 3 : -1)) + if (GuiButton((Rectangle){ 20, 40 + 540, 300, 80 }, "GLASSES", 3)) { doGlasses = true; } - if (GuiButton((Rectangle){ 20, 40 + 540, 300, 80 }, "PIERCING", doPiercing? 3 : -1)) - { - doPiercing = true; - } // Draw player - DrawCharacter(player); + DrawCharacter(player, (Vector2){ GetScreenWidth()/2 - 125, 80 }); // Draw dating view - GuiButton((Rectangle){ 970, 40, 260, 60 }, "DATING...", 2); + GuiButton((Rectangle){ 970, 40, 260, 60 }, "DATING:", 2); GuiButton((Rectangle){ 970, 40 + 70, 260, 260 }, " ", 0); + BeginTextureMode(target); - DrawTextureRec(texHair, (Rectangle){ BASE_HAIR_WIDTH*dating.hair, 240, BASE_HAIR_WIDTH, texHair.height - 240 }, (Vector2){ target.texture.width/2 - BASE_HAIR_WIDTH/2, 80 + 240 }, GetColor(dating.colHair)); - DrawTextureRec(texHead, (Rectangle){ BASE_HEAD_WIDTH*dating.head, 0, BASE_HEAD_WIDTH, texHead.height }, (Vector2){ target.texture.width/2 - BASE_HEAD_WIDTH/2, 140 }, GetColor(dating.colHead)); - DrawTextureRec(texHair, (Rectangle){ BASE_HAIR_WIDTH*dating.hair, 0, BASE_HAIR_WIDTH, 240 }, (Vector2){ target.texture.width/2 - BASE_HAIR_WIDTH/2, 80 }, GetColor(dating.colHair)); - DrawTextureRec(texEyes, (Rectangle){ BASE_EYES_WIDTH*dating.eyes, 0, BASE_EYES_WIDTH, texEyes.height }, (Vector2){ target.texture.width/2 - BASE_EYES_WIDTH/2, 270 }, WHITE); - DrawTextureRec(texNose, (Rectangle){ BASE_NOSE_WIDTH*dating.nose, 0, BASE_NOSE_WIDTH, texNose.height }, (Vector2){ target.texture.width/2 - BASE_NOSE_WIDTH/2, 355 }, GetColor(dating.colHead)); - DrawTextureRec(texMouth, (Rectangle){ BASE_MOUTH_WIDTH*dating.mouth, 0, BASE_MOUTH_WIDTH, texMouth.height }, (Vector2){ target.texture.width/2 - BASE_MOUTH_WIDTH/2, 450 }, GetColor(dating.colHead)); - - if (dating.makeup) DrawTextureRec(texMakeup, (Rectangle){ 0, 0, texMakeup.width, texMakeup.height }, (Vector2){ target.texture.width/2 - texMakeup.width/2, 350 }, Fade(RED, 0.3f)); + DrawCharacter(dating, (Vector2){ (720 - 250)/2, (720 - 500)/2 }); EndTextureMode(); 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); @@ -164,26 +152,14 @@ void DrawGameplayScreen(void) // Draw left button: date! if (GuiButton((Rectangle){ 970, 580, 260, 90 }, "GO DATE!", -1)) { - CustomizeCharacter(&dating); - finishScreen = 1; - PlaySound(fxCoin); } } // Gameplay Screen Unload logic void UnloadGameplayScreen(void) { - // Unload GAMEPLAY screen variables - // Unload required textures - UnloadTexture(texHead); - UnloadTexture(texHair); - UnloadTexture(texNose); - UnloadTexture(texMouth); - UnloadTexture(texEyes); - //UnloadTexture(texComp); - UnloadTexture(texMakeup); } // Gameplay Screen should finish? @@ -191,84 +167,3 @@ int FinishGameplayScreen(void) { return finishScreen; } - -Character GenerateCharacter(void) -{ - Character character = { 0 }; - - // Generate player character! - character.head = GetRandomValue(0, texHead.width/BASE_HEAD_WIDTH); - character.colHead = headColors[GetRandomValue(0, 5)]; - character.hair = GetRandomValue(0, texHair.width/BASE_HAIR_WIDTH); // Config (decrease value only) - character.colHair = hairColors[GetRandomValue(0, 9)]; // Config - character.eyes = GetRandomValue(0, texEyes.width/BASE_EYES_WIDTH); - character.nose = GetRandomValue(0, texNose.width/BASE_NOSE_WIDTH); - character.mouth = GetRandomValue(0, texMouth.width/BASE_MOUTH_WIDTH); - - // NOTE: No character customization at this point - - return character; -} - -void CustomizeCharacter(Character *character) -{ - character->eyeLine = GetRandomValue(0, 2); // Config - character->paintLips = GetRandomValue(0, 2); // Config - character->makeup = GetRandomValue(0, 2); // Config - //character->bear = GetRandomValue(0, 1); // Config: remove - //character->moustache = GetRandomValue(0, 1); // Config: remove - character->glasses = GetRandomValue(0, 3); // Config: put/remove - character->piercing = GetRandomValue(0, 3); // Config: put/remove -} - -void DrawCharacter(Character character) -{ - if (player.hair >= 0) DrawTextureRec(texHair, (Rectangle){ BASE_HAIR_WIDTH*character.hair, 240, BASE_HAIR_WIDTH, texHair.height - 240 }, (Vector2){ GetScreenWidth()/2 - BASE_HAIR_WIDTH/2, 80 + 240 }, GetColor(character.colHair)); - DrawTextureRec(texHead, (Rectangle){ BASE_HEAD_WIDTH*character.head, 0, BASE_HEAD_WIDTH, texHead.height }, (Vector2){ GetScreenWidth()/2 - BASE_HEAD_WIDTH/2, 140 }, GetColor(character.colHead)); - DrawTextureRec(texHair, (Rectangle){ BASE_HAIR_WIDTH*character.hair, 0, BASE_HAIR_WIDTH, 240 }, (Vector2){ GetScreenWidth()/2 - BASE_HAIR_WIDTH/2, 80 }, GetColor(character.colHair)); - DrawTextureRec(texEyes, (Rectangle){ BASE_EYES_WIDTH*character.eyes, 0, BASE_EYES_WIDTH, texEyes.height }, (Vector2){ GetScreenWidth()/2 - BASE_EYES_WIDTH/2, 270 }, WHITE); - DrawTextureRec(texNose, (Rectangle){ BASE_NOSE_WIDTH*character.nose, 0, BASE_NOSE_WIDTH, texNose.height }, (Vector2){ GetScreenWidth()/2 - BASE_NOSE_WIDTH/2, 355 }, GetColor(character.colHead)); - DrawTextureRec(texMouth, (Rectangle){ BASE_MOUTH_WIDTH*character.mouth, 0, BASE_MOUTH_WIDTH, texMouth.height }, (Vector2){ GetScreenWidth()/2 - BASE_MOUTH_WIDTH/2, 450 }, GetColor(character.colHead)); - - if (character.makeup) DrawTextureRec(texMakeup, (Rectangle){ 0, 0, texMakeup.width, texMakeup.height }, (Vector2){ GetScreenWidth()/2 - texMakeup.width/2, 350 }, Fade(RED, 0.3f)); -} - -// Gui Button -bool GuiButton(Rectangle bounds, const char *text, int forcedState) -{ - static const int textColor[4] = { 0xeff6ffff, 0x78e782ff, 0xb04d5fff, 0xd6d6d6ff }; - - int state = (forcedState >= 0)? forcedState : 0; // NORMAL - bool pressed = false; - Vector2 textSize = MeasureTextEx(font, text, font.baseSize, 1); - - // Update control - //-------------------------------------------------------------------- - if ((state < 3) && (forcedState < 0)) - { - Vector2 mousePoint = GetMousePosition(); - - // Check button state - if (CheckCollisionPointRec(mousePoint, bounds)) - { - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = 2; // PRESSED - else state = 1; // FOCUSED - - if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) pressed = true; - } - } - - npInfo.sourceRec.x = 80*state; - - //-------------------------------------------------------------------- - - // Draw control - //-------------------------------------------------------------------- - //DrawRectangleRec(bounds, GREEN); - //DrawRectangleLinesEx(bounds, 4, DARKGREEN); - DrawTextureNPatch(texNPatch, npInfo, bounds, (Vector2){ 0.0f, 0.0f }, 0.0f, WHITE); - DrawTextEx(font, text, (Vector2){ bounds.x + bounds.width/2 - textSize.x/2, bounds.y + bounds.height/2 - textSize.y/2 + 4 }, font.baseSize, 1, GetColor(textColor[state])); - //------------------------------------------------------------------ - - return pressed; -} \ No newline at end of file diff --git a/games/repair/screens/screen_title.c b/games/repair/screens/screen_title.c index e4ed88b0d..460d30634 100644 --- a/games/repair/screens/screen_title.c +++ b/games/repair/screens/screen_title.c @@ -35,11 +35,10 @@ static int framesCounter = 0; static int finishScreen = 0; static Texture2D texTitle = { 0 }; - -static Character demoChar = { 0 }; +static Texture2D texLogo = { 0 }; static int titlePositionY = 0; -static int buttonPositionY = 0; +static int titleCounter = 0; //---------------------------------------------------------------------------------- // Title Screen Functions Definition @@ -52,44 +51,45 @@ void InitTitleScreen(void) finishScreen = 0; texTitle = LoadTexture("resources/title.png"); + texLogo = LoadTexture("resources/raylib_logo.png"); - demoChar = GenerateCharacter(); + player = GenerateCharacter(); - titlePositionY = -600; - buttonPositionY = 1600; + titlePositionY = -200; } // Title Screen Update logic void UpdateTitleScreen(void) { framesCounter++; - - if (framesCounter > 60) + + if (framesCounter > 5) { int partToChange = GetRandomValue(0, 4); if (partToChange == 0) { - demoChar.head = GetRandomValue(0, texHead.width/BASE_HEAD_WIDTH); - demoChar.colHead = headColors[GetRandomValue(0, 5)]; + player.head = GetRandomValue(0, texHead.width/BASE_HEAD_WIDTH - 1); + player.colHead = headColors[GetRandomValue(0, 5)]; } - else if (partToChange == 1) demoChar.eyes = GetRandomValue(0, texEyes.width/BASE_EYES_WIDTH); - else if (partToChange == 2) demoChar.nose = GetRandomValue(0, texNose.width/BASE_NOSE_WIDTH); - else if (partToChange == 3) demoChar.mouth = GetRandomValue(0, texMouth.width/BASE_MOUTH_WIDTH); + else if (partToChange == 1) player.eyes = GetRandomValue(0, texEyes.width/BASE_EYES_WIDTH - 1); + else if (partToChange == 2) player.nose = GetRandomValue(0, texNose.width/BASE_NOSE_WIDTH - 1); + else if (partToChange == 3) player.mouth = GetRandomValue(0, texMouth.width/BASE_MOUTH_WIDTH - 1); else if (partToChange == 4) { - demoChar.hair = GetRandomValue(0, texHair.width/BASE_HAIR_WIDTH); - demoChar.colHair = hairColors[GetRandomValue(0, 9)]; + player.hair = GetRandomValue(0, texHair.width/BASE_HAIR_WIDTH - 1); + player.colHair = hairColors[GetRandomValue(0, 9)]; } framesCounter = 0; } - titlePositionY++; + titlePositionY += 3; if (titlePositionY > 40) titlePositionY = 40; - buttonPositionY--; - if (buttonPositionY < 580) buttonPositionY = 580; + titleCounter++; + + if (IsKeyPressed(KEY_ENTER)) finishScreen = 1; } // Title Screen Draw logic @@ -98,26 +98,33 @@ void DrawTitleScreen(void) DrawTexture(background, 0, 0, GetColor(0xf6aa60ff)); // Draw face, parts keep changing ranomly - DrawCharacter(demoChar); + DrawCharacter(player, (Vector2){ GetScreenWidth()/2 - 125, 80 }); // Draw face rectangles - DrawRectangleRec((Rectangle){ GetScreenWidth()/2 - BASE_EYES_WIDTH/2, 270, BASE_EYES_WIDTH, texEyes.height }, Fade(GREEN, 0.3f)); - DrawRectangleRec((Rectangle){ GetScreenWidth()/2 - BASE_NOSE_WIDTH/2, 355, BASE_NOSE_WIDTH, texNose.height }, Fade(SKYBLUE, 0.3f)); - DrawRectangleRec((Rectangle){ GetScreenWidth()/2 - BASE_MOUTH_WIDTH/2, 450, BASE_MOUTH_WIDTH, texMouth.height }, Fade(RED, 0.3f)); + //DrawRectangleRec((Rectangle){ GetScreenWidth()/2 - BASE_EYES_WIDTH/2, 270, BASE_EYES_WIDTH, texEyes.height }, Fade(GREEN, 0.3f)); + //DrawRectangleRec((Rectangle){ GetScreenWidth()/2 - BASE_NOSE_WIDTH/2, 355, BASE_NOSE_WIDTH, texNose.height }, Fade(SKYBLUE, 0.3f)); + //DrawRectangleRec((Rectangle){ GetScreenWidth()/2 - BASE_MOUTH_WIDTH/2, 450, BASE_MOUTH_WIDTH, texMouth.height }, Fade(RED, 0.3f)); DrawTexture(texTitle, GetScreenWidth()/2 - texTitle.width/2, titlePositionY, WHITE); - if (GuiButton((Rectangle){ GetScreenWidth()/2 - 440/2, buttonPositionY, 440, 80 }, "START DATE!", -1)) + if (titleCounter > 180) { - finishScreen = 1; // GAMEPLAY - PlaySound(fxCoin); + if (GuiButton((Rectangle){ GetScreenWidth()/2 - 440/2, 580, 440, 80 }, "START DATE!", -1)) + { + finishScreen = 1; // GAMEPLAY + PlaySound(fxCoin); + } } + + DrawText("powered by", 20, GetScreenHeight() - texLogo.height - 35, 10, BLACK); + DrawTexture(texLogo, 20, GetScreenHeight() - texLogo.height - 20, WHITE); } // Title Screen Unload logic void UnloadTitleScreen(void) { UnloadTexture(texTitle); + UnloadTexture(texLogo); } // Title Screen should finish? diff --git a/games/repair/screens/screens.h b/games/repair/screens/screens.h index 872ff0cce..362a15c9a 100644 --- a/games/repair/screens/screens.h +++ b/games/repair/screens/screens.h @@ -40,20 +40,14 @@ typedef enum GameScreen { LOGO = 0, TITLE, OPTIONS, GAMEPLAY, ENDING } GameScree typedef struct { int head; int colHead; - int eyes; - int nose; - int mouth; - int hair; // Config (decrease value only) + int eyes; // Config + int nose; // Config + int mouth; // Config + int hair; // Config int colHair; // Config - int eyeLine; // Config -> 0, 1, 2 - int paintLips; // Config -> 0, 1, 2 - //Color colLips; // Config - bool makeup; // Config - bool bear; // Config: remove - bool moustache; // Config: remove - bool glasses; // Config: put/remove - bool piercing; // Config: put/remove - //bool freckles; + int glasses; // Config + //int piercing; + //int freckles; } Character; //---------------------------------------------------------------------------------- @@ -72,6 +66,11 @@ extern NPatchInfo npInfo; extern Texture2D texHead, texHair, texNose, texMouth, texEyes, texComp; extern Texture2D texMakeup; +extern Character player; +extern Character playerBase; +extern Character dating; +extern Character datingBase; + #ifdef __cplusplus extern "C" { // Prevents name mangling of functions #endif @@ -81,7 +80,7 @@ bool GuiButton(Rectangle rec, const char *text, int forcedState); Character GenerateCharacter(void); void CustomizeCharacter(Character *character); -void DrawCharacter(Character character); +void DrawCharacter(Character character, Vector2 position); //---------------------------------------------------------------------------------- // Logo Screen Functions Declaration