[GAME] Upload RE-PAIR game from GGJ2020 -WIP-

This commit is contained in:
Ray 2020-02-01 23:40:19 +01:00
commit 724e805282
5 changed files with 1573 additions and 4 deletions

View file

@ -0,0 +1,81 @@
/**********************************************************************************************
*
* raylib - Advance Game template
*
* Ending Screen Functions Definitions (Init, Update, Draw, Unload)
*
* Copyright (c) 2014-2020 Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose, including commercial
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not claim that you
* wrote the original software. If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
* as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
**********************************************************************************************/
#include "raylib.h"
#include "screens.h"
//----------------------------------------------------------------------------------
// Global Variables Definition (local to this module)
//----------------------------------------------------------------------------------
// Ending screen global variables
static int framesCounter;
static int finishScreen;
//----------------------------------------------------------------------------------
// Ending Screen Functions Definition
//----------------------------------------------------------------------------------
// Ending Screen Initialization logic
void InitEndingScreen(void)
{
// TODO: Initialize ENDING screen variables here!
framesCounter = 0;
finishScreen = 0;
}
// Ending Screen Update logic
void UpdateEndingScreen(void)
{
// TODO: Update ENDING screen variables here!
// Press enter or tap to return to TITLE screen
if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP))
{
finishScreen = 1;
PlaySound(fxCoin);
}
}
// 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);
}
// Ending Screen Unload logic
void UnloadEndingScreen(void)
{
// TODO: Unload ENDING screen variables here!
}
// Ending Screen should finish?
int FinishEndingScreen(void)
{
return finishScreen;
}

View file

@ -0,0 +1,274 @@
/**********************************************************************************************
*
* raylib - Advance Game template
*
* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload)
*
* Copyright (c) 2014-2020 Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose, including commercial
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not claim that you
* wrote the original software. If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
* as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
**********************************************************************************************/
#include "raylib.h"
#include "screens.h"
static bool doHairCut = false;
static bool doHairTint = false;
static bool doEyeLiner = false;
static bool doLipStick = false;
static bool doMakeup = false;
static bool doGlasses = false;
static bool doPiercing = false;
//----------------------------------------------------------------------------------
// Global Variables Definition (local to this module)
//----------------------------------------------------------------------------------
const unsigned int headColors[6] = { 0xffe29bff, 0xfed5a8ff, 0xad8962ff, 0xfff1b8ff, 0xffd6c4ff, 0xd49c8dff };
const unsigned int hairColors[10] = { 0xf5bf60ff, 0xaa754aff, 0x974e14ff, 0xf36347ff, 0x87f347ff, 0xfc48d0ff, 0x3b435dff, 0x5f5e60ff, 0xe7e7e7ff, 0xfb386bff };
// Gameplay screen global variables
static int framesCounter = 0;
static int finishScreen = 0;
static Character player = { 0 };
static Character dating = { 0 };
static RenderTexture target = { 0 };
//----------------------------------------------------------------------------------
// Gameplay Screen Functions Definition
//----------------------------------------------------------------------------------
// Gameplay Screen Initialization logic
void InitGameplayScreen(void)
{
// Initialize GAMEPLAY screen variables
framesCounter = 0;
finishScreen = 0;
target = LoadRenderTexture(720, 720);
SetTextureFilter(target.texture, FILTER_BILINEAR);
// Generate player character!
player = GenerateCharacter();
// Generate dating character!
dating = GenerateCharacter();
// TODO: Generate dating character likes
// For the different types of properties we assign random like values: 0% (total-dislike) -> 100% (total-like)
// The total match point will be the (like accumulated amount)/(num properties)
// Some of the elements add points or remove points
// At the end we can show the like percentadge of every element
}
// 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))
{
finishScreen = 1;
PlaySound(fxCoin);
}
}
// Gameplay Screen Draw logic
void DrawGameplayScreen(void)
{
// Draw background (texture, color, vignette?)
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!
}
}
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))
{
doEyeLiner = true;
}
if (GuiButton((Rectangle){ 20, 40 + 270, 300, 80 }, "LIPSTICK", doLipStick? 3 : -1))
{
doLipStick = true;
}
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))
{
doGlasses = true;
}
if (GuiButton((Rectangle){ 20, 40 + 540, 300, 80 }, "PIERCING", doPiercing? 3 : -1))
{
doPiercing = true;
}
// Draw player
DrawCharacter(player);
// Draw dating view
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));
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);
// 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?
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;
}

View file

@ -0,0 +1,211 @@
/**********************************************************************************************
*
* raylib - Advance Game template
*
* Logo Screen Functions Definitions (Init, Update, Draw, Unload)
*
* Copyright (c) 2014-2019 Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose, including commercial
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not claim that you
* wrote the original software. If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
* as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
**********************************************************************************************/
#include "raylib.h"
#include "screens.h"
#define LOGO_RECS_SIDE 16
//----------------------------------------------------------------------------------
// Global Variables Definition (local to this module)
//----------------------------------------------------------------------------------
// Logo screen global variables
static int framesCounter = 0;
static int finishScreen = 0;
static int logoPositionX = 0;
static int logoPositionY = 0;
static int lettersCount = 0;
static int topSideRecWidth = 0;
static int leftSideRecHeight = 0;
static int bottomSideRecWidth = 0;
static int rightSideRecHeight = 0;
static char raylib[8] = { 0 }; // raylib text array, max 8 letters
static int state = 0; // Tracking animation states (State Machine)
static float alpha = 1.0f; // Useful for fading
//----------------------------------------------------------------------------------
// Logo Screen Functions Definition
//----------------------------------------------------------------------------------
// Logo Screen Initialization logic
void InitLogoScreen(void)
{
// Initialize LOGO screen variables here!
finishScreen = 0;
framesCounter = 0;
lettersCount = 0;
logoPositionX = GetScreenWidth()/2 - 128;
logoPositionY = GetScreenHeight()/2 - 128;
topSideRecWidth = LOGO_RECS_SIDE;
leftSideRecHeight = LOGO_RECS_SIDE;
bottomSideRecWidth = LOGO_RECS_SIDE;
rightSideRecHeight = LOGO_RECS_SIDE;
for (int i = 0; i < 8; i++) raylib[i] = '\0';
state = 0;
alpha = 1.0f;
}
// Logo Screen Update logic
void UpdateLogoScreen(void)
{
// Update LOGO screen variables here!
if (state == 0) // State 0: Small box blinking
{
framesCounter++;
if (framesCounter == 80)
{
state = 1;
framesCounter = 0; // Reset counter... will be used later...
}
}
else if (state == 1) // State 1: Top and left bars growing
{
topSideRecWidth += 8;
leftSideRecHeight += 8;
if (topSideRecWidth == 256) state = 2;
}
else if (state == 2) // State 2: Bottom and right bars growing
{
bottomSideRecWidth += 8;
rightSideRecHeight += 8;
if (bottomSideRecWidth == 256) state = 3;
}
else if (state == 3) // State 3: Letters appearing (one by one)
{
framesCounter++;
if (framesCounter/10) // Every 12 frames, one more letter!
{
lettersCount++;
framesCounter = 0;
}
switch (lettersCount)
{
case 1: raylib[0] = 'r'; break;
case 2: raylib[1] = 'a'; break;
case 3: raylib[2] = 'y'; break;
case 4: raylib[3] = 'l'; break;
case 5: raylib[4] = 'i'; break;
case 6: raylib[5] = 'b'; break;
default: break;
}
// When all letters have appeared...
if (lettersCount >= 10)
{
state = 4;
framesCounter = 0;
}
}
else if (state == 4)
{
framesCounter++;
if (framesCounter > 100)
{
alpha -= 0.02f;
if (alpha <= 0.0f)
{
alpha = 0.0f;
finishScreen = 1;
}
}
}
}
// Logo Screen Draw logic
void DrawLogoScreen(void)
{
if (state == 0)
{
if ((framesCounter/10)%2) DrawRectangle(logoPositionX, logoPositionY, 16, 16, BLACK);
}
else if (state == 1)
{
DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK);
DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK);
}
else if (state == 2)
{
DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK);
DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK);
DrawRectangle(logoPositionX + 240, logoPositionY, 16, rightSideRecHeight, BLACK);
DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, BLACK);
}
else if (state == 3)
{
DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, Fade(BLACK, alpha));
DrawRectangle(logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, Fade(BLACK, alpha));
DrawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, Fade(BLACK, alpha));
DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, Fade(BLACK, alpha));
DrawRectangle(GetScreenWidth()/2 - 112, GetScreenHeight()/2 - 112, 224, 224, Fade(RAYWHITE, alpha));
DrawText(raylib, GetScreenWidth()/2 - 44, GetScreenHeight()/2 + 48, 50, Fade(BLACK, alpha));
}
else if (state == 4)
{
DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, Fade(BLACK, alpha));
DrawRectangle(logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, Fade(BLACK, alpha));
DrawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, Fade(BLACK, alpha));
DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, Fade(BLACK, alpha));
DrawRectangle(GetScreenWidth()/2 - 112, GetScreenHeight()/2 - 112, 224, 224, Fade(RAYWHITE, alpha));
DrawText(raylib, GetScreenWidth()/2 - 44, GetScreenHeight()/2 + 48, 50, Fade(BLACK, alpha));
if (framesCounter > 20) DrawText("powered by", logoPositionX, logoPositionY - 27, 20, Fade(DARKGRAY, alpha));
}
}
// Logo Screen Unload logic
void UnloadLogoScreen(void)
{
// Unload LOGO screen variables here!
}
// Logo Screen should finish?
int FinishLogoScreen(void)
{
return finishScreen;
}

View file

@ -0,0 +1,127 @@
/**********************************************************************************************
*
* raylib - Advance Game template
*
* Title Screen Functions Definitions (Init, Update, Draw, Unload)
*
* Copyright (c) 2014-2020 Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose, including commercial
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not claim that you
* wrote the original software. If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
* as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
**********************************************************************************************/
#include "raylib.h"
#include "screens.h"
//----------------------------------------------------------------------------------
// Global Variables Definition (local to this module)
//----------------------------------------------------------------------------------
// Title screen global variables
static int framesCounter = 0;
static int finishScreen = 0;
static Texture2D texTitle = { 0 };
static Character demoChar = { 0 };
static int titlePositionY = 0;
static int buttonPositionY = 0;
//----------------------------------------------------------------------------------
// Title Screen Functions Definition
//----------------------------------------------------------------------------------
// Title Screen Initialization logic
void InitTitleScreen(void)
{
framesCounter = 0;
finishScreen = 0;
texTitle = LoadTexture("resources/title.png");
demoChar = GenerateCharacter();
titlePositionY = -600;
buttonPositionY = 1600;
}
// Title Screen Update logic
void UpdateTitleScreen(void)
{
framesCounter++;
if (framesCounter > 60)
{
int partToChange = GetRandomValue(0, 4);
if (partToChange == 0)
{
demoChar.head = GetRandomValue(0, texHead.width/BASE_HEAD_WIDTH);
demoChar.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 == 4)
{
demoChar.hair = GetRandomValue(0, texHair.width/BASE_HAIR_WIDTH);
demoChar.colHair = hairColors[GetRandomValue(0, 9)];
}
framesCounter = 0;
}
titlePositionY++;
if (titlePositionY > 40) titlePositionY = 40;
buttonPositionY--;
if (buttonPositionY < 580) buttonPositionY = 580;
}
// Title Screen Draw logic
void DrawTitleScreen(void)
{
DrawTexture(background, 0, 0, GetColor(0xf6aa60ff));
// Draw face, parts keep changing ranomly
DrawCharacter(demoChar);
// 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));
DrawTexture(texTitle, GetScreenWidth()/2 - texTitle.width/2, titlePositionY, WHITE);
if (GuiButton((Rectangle){ GetScreenWidth()/2 - 440/2, buttonPositionY, 440, 80 }, "START DATE!", -1))
{
finishScreen = 1; // GAMEPLAY
PlaySound(fxCoin);
}
}
// Title Screen Unload logic
void UnloadTitleScreen(void)
{
UnloadTexture(texTitle);
}
// Title Screen should finish?
int FinishTitleScreen(void)
{
return finishScreen;
}

View file

@ -0,0 +1,135 @@
/**********************************************************************************************
*
* raylib - Advance Game template
*
* Screens Functions Declarations (Init, Update, Draw, Unload)
*
* Copyright (c) 2014-2020 Ramon Santamaria (@raysan5)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose, including commercial
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not claim that you
* wrote the original software. If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
* as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
**********************************************************************************************/
#ifndef SCREENS_H
#define SCREENS_H
#define BASE_HEAD_WIDTH 400
#define BASE_HAIR_WIDTH 500
#define BASE_NOSE_WIDTH 80
#define BASE_MOUTH_WIDTH 170
#define BASE_EYES_WIDTH 240
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
typedef enum GameScreen { LOGO = 0, TITLE, OPTIONS, GAMEPLAY, ENDING } GameScreen;
typedef struct {
int head;
int colHead;
int eyes;
int nose;
int mouth;
int hair; // Config (decrease value only)
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;
} Character;
//----------------------------------------------------------------------------------
// Global Variables Definition
//----------------------------------------------------------------------------------
extern const unsigned int headColors[6];
extern const unsigned int hairColors[10];
extern GameScreen currentScreen;
extern Font font;
extern Music music;
extern Sound fxCoin;
extern Texture2D background;
extern Texture2D texNPatch;
extern NPatchInfo npInfo;
extern Texture2D texHead, texHair, texNose, texMouth, texEyes, texComp;
extern Texture2D texMakeup;
#ifdef __cplusplus
extern "C" { // Prevents name mangling of functions
#endif
// Gui Button
bool GuiButton(Rectangle rec, const char *text, int forcedState);
Character GenerateCharacter(void);
void CustomizeCharacter(Character *character);
void DrawCharacter(Character character);
//----------------------------------------------------------------------------------
// Logo Screen Functions Declaration
//----------------------------------------------------------------------------------
void InitLogoScreen(void);
void UpdateLogoScreen(void);
void DrawLogoScreen(void);
void UnloadLogoScreen(void);
int FinishLogoScreen(void);
//----------------------------------------------------------------------------------
// Title Screen Functions Declaration
//----------------------------------------------------------------------------------
void InitTitleScreen(void);
void UpdateTitleScreen(void);
void DrawTitleScreen(void);
void UnloadTitleScreen(void);
int FinishTitleScreen(void);
//----------------------------------------------------------------------------------
// Options Screen Functions Declaration
//----------------------------------------------------------------------------------
void InitOptionsScreen(void);
void UpdateOptionsScreen(void);
void DrawOptionsScreen(void);
void UnloadOptionsScreen(void);
int FinishOptionsScreen(void);
//----------------------------------------------------------------------------------
// Gameplay Screen Functions Declaration
//----------------------------------------------------------------------------------
void InitGameplayScreen(void);
void UpdateGameplayScreen(void);
void DrawGameplayScreen(void);
void UnloadGameplayScreen(void);
int FinishGameplayScreen(void);
//----------------------------------------------------------------------------------
// Ending Screen Functions Declaration
//----------------------------------------------------------------------------------
void InitEndingScreen(void);
void UpdateEndingScreen(void);
void DrawEndingScreen(void);
void UnloadEndingScreen(void);
int FinishEndingScreen(void);
#ifdef __cplusplus
}
#endif
#endif // SCREENS_H