REVIEWED: Advance template
This commit is contained in:
parent
da8d76d826
commit
de4611ecf6
8 changed files with 65 additions and 75 deletions
|
|
@ -371,11 +371,11 @@ endif
|
|||
# Define all source files required
|
||||
PROJECT_SOURCE_FILES ?= \
|
||||
advance_game.c \
|
||||
screens/screen_logo.c \
|
||||
screens/screen_title.c \
|
||||
screens/screen_options.c \
|
||||
screens/screen_gameplay.c \
|
||||
screens/screen_ending.c
|
||||
screen_logo.c \
|
||||
screen_title.c \
|
||||
screen_options.c \
|
||||
screen_gameplay.c \
|
||||
screen_ending.c
|
||||
|
||||
# Define all object files from source files
|
||||
OBJS = $(patsubst %.c, %.o, $(PROJECT_SOURCE_FILES))
|
||||
|
|
|
|||
|
|
@ -13,12 +13,15 @@
|
|||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
#include "screens/screens.h" // NOTE: Defines global variable: currentScreen
|
||||
#include "screens.h" // NOTE: Declares global (extern) variables and screens functions
|
||||
|
||||
#if defined(PLATFORM_WEB)
|
||||
#include <emscripten/emscripten.h>
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Shared Variables Definition (global)
|
||||
//----------------------------------------------------------------------------------
|
||||
GameScreen currentScreen = 0;
|
||||
Font font = { 0 };
|
||||
Music music = { 0 };
|
||||
|
|
@ -27,8 +30,8 @@ Sound fxCoin = { 0 };
|
|||
//----------------------------------------------------------------------------------
|
||||
// Global Variables Definition (local to this module)
|
||||
//----------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
static const int screenWidth = 800;
|
||||
static const int screenHeight = 450;
|
||||
|
||||
// Required variables to manage screen transitions (fade-in, fade-out)
|
||||
static float transAlpha = 0.0f;
|
||||
|
|
@ -37,19 +40,16 @@ static bool transFadeOut = false;
|
|||
static int transFromScreen = -1;
|
||||
static int transToScreen = -1;
|
||||
|
||||
// NOTE: Some global variables that require to be visible for all screens,
|
||||
// are defined in screens.h (i.e. currentScreen)
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Local Functions Declaration
|
||||
//----------------------------------------------------------------------------------
|
||||
static void ChangeToScreen(int screen); // No transition effect
|
||||
static void ChangeToScreen(int screen); // Change to screen, no transition effect
|
||||
|
||||
static void TransitionToScreen(int screen);
|
||||
static void UpdateTransition(void);
|
||||
static void DrawTransition(void);
|
||||
static void TransitionToScreen(int screen); // Request transition to next screen
|
||||
static void UpdateTransition(void); // Update transition effect
|
||||
static void DrawTransition(void); // Draw transition effect (full-screen rectangle)
|
||||
|
||||
static void UpdateDrawFrame(void); // Update and Draw one frame
|
||||
static void UpdateDrawFrame(void); // Update and draw one frame
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Main entry point
|
||||
|
|
@ -66,7 +66,7 @@ int main(void)
|
|||
font = LoadFont("resources/mecha.png");
|
||||
music = LoadMusicStream("resources/ambient.ogg");
|
||||
fxCoin = LoadSound("resources/coin.wav");
|
||||
|
||||
|
||||
SetMusicVolume(music, 1.0f);
|
||||
PlayMusicStream(music);
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ int main(void)
|
|||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// Unload current screen data before closing
|
||||
switch (currentScreen)
|
||||
{
|
||||
|
|
@ -99,14 +99,14 @@ int main(void)
|
|||
case ENDING: UnloadEndingScreen(); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
||||
// Unload all global loaded data (i.e. fonts) here!
|
||||
UnloadFont(font);
|
||||
UnloadMusicStream(music);
|
||||
UnloadSound(fxCoin);
|
||||
|
||||
CloseAudioDevice(); // Close audio context
|
||||
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ static void ChangeToScreen(int screen)
|
|||
case ENDING: UnloadEndingScreen(); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
||||
// Init next screen
|
||||
switch (screen)
|
||||
{
|
||||
|
|
@ -139,11 +139,11 @@ static void ChangeToScreen(int screen)
|
|||
case ENDING: InitEndingScreen(); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
||||
currentScreen = screen;
|
||||
}
|
||||
|
||||
// Define transition to next screen
|
||||
// Request transition to next screen
|
||||
static void TransitionToScreen(int screen)
|
||||
{
|
||||
onTransition = true;
|
||||
|
|
@ -159,13 +159,13 @@ static void UpdateTransition(void)
|
|||
if (!transFadeOut)
|
||||
{
|
||||
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
|
||||
if (transAlpha > 1.01f)
|
||||
{
|
||||
transAlpha = 1.0f;
|
||||
|
||||
|
||||
// Unload current screen
|
||||
switch (transFromScreen)
|
||||
{
|
||||
|
|
@ -176,7 +176,7 @@ static void UpdateTransition(void)
|
|||
case ENDING: UnloadEndingScreen(); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
||||
// Load next screen
|
||||
switch (transToScreen)
|
||||
{
|
||||
|
|
@ -186,9 +186,9 @@ static void UpdateTransition(void)
|
|||
case ENDING: InitEndingScreen(); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
||||
currentScreen = transToScreen;
|
||||
|
||||
|
||||
// Activate fade out effect to next loaded screen
|
||||
transFadeOut = true;
|
||||
}
|
||||
|
|
@ -196,7 +196,7 @@ static void UpdateTransition(void)
|
|||
else // Transition fade out logic
|
||||
{
|
||||
transAlpha -= 0.02f;
|
||||
|
||||
|
||||
if (transAlpha < -0.01f)
|
||||
{
|
||||
transAlpha = 0.0f;
|
||||
|
|
@ -220,22 +220,22 @@ static void UpdateDrawFrame(void)
|
|||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
UpdateMusicStream(music); // NOTE: Music keeps playing between screens
|
||||
|
||||
|
||||
if (!onTransition)
|
||||
{
|
||||
switch(currentScreen)
|
||||
switch(currentScreen)
|
||||
{
|
||||
case LOGO:
|
||||
case LOGO:
|
||||
{
|
||||
UpdateLogoScreen();
|
||||
|
||||
|
||||
if (FinishLogoScreen()) TransitionToScreen(TITLE);
|
||||
|
||||
} break;
|
||||
case TITLE:
|
||||
case TITLE:
|
||||
{
|
||||
UpdateTitleScreen();
|
||||
|
||||
|
||||
if (FinishTitleScreen() == 1) TransitionToScreen(OPTIONS);
|
||||
else if (FinishTitleScreen() == 2) TransitionToScreen(GAMEPLAY);
|
||||
|
||||
|
|
@ -243,22 +243,22 @@ static void UpdateDrawFrame(void)
|
|||
case OPTIONS:
|
||||
{
|
||||
UpdateOptionsScreen();
|
||||
|
||||
|
||||
if (FinishOptionsScreen()) TransitionToScreen(TITLE);
|
||||
|
||||
} break;
|
||||
case GAMEPLAY:
|
||||
{
|
||||
UpdateGameplayScreen();
|
||||
|
||||
|
||||
if (FinishGameplayScreen() == 1) TransitionToScreen(ENDING);
|
||||
//else if (FinishGameplayScreen() == 2) TransitionToScreen(TITLE);
|
||||
|
||||
} break;
|
||||
case ENDING:
|
||||
{
|
||||
{
|
||||
UpdateEndingScreen();
|
||||
|
||||
|
||||
if (FinishEndingScreen() == 1) TransitionToScreen(TITLE);
|
||||
|
||||
} break;
|
||||
|
|
@ -267,14 +267,14 @@ static void UpdateDrawFrame(void)
|
|||
}
|
||||
else UpdateTransition(); // Update transition (fade-in, fade-out)
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
switch(currentScreen)
|
||||
|
||||
switch(currentScreen)
|
||||
{
|
||||
case LOGO: DrawLogoScreen(); break;
|
||||
case TITLE: DrawTitleScreen(); break;
|
||||
|
|
@ -283,12 +283,12 @@ static void UpdateDrawFrame(void)
|
|||
case ENDING: DrawEndingScreen(); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
||||
// Draw full screen rectangle in front of everything
|
||||
if (onTransition) DrawTransition();
|
||||
|
||||
|
||||
//DrawFPS(10, 10);
|
||||
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
|
|
|||
79
templates/advance_game/screen_ending.c
Normal file
79
templates/advance_game/screen_ending.c
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/**********************************************************************************************
|
||||
*
|
||||
* raylib - Advance Game template
|
||||
*
|
||||
* Ending Screen Functions Definitions (Init, Update, Draw, Unload)
|
||||
*
|
||||
* Copyright (c) 2014-2021 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"
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Variables Definition (local)
|
||||
//----------------------------------------------------------------------------------
|
||||
static int framesCounter = 0;
|
||||
static int finishScreen = 0;
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// 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;
|
||||
}
|
||||
79
templates/advance_game/screen_gameplay.c
Normal file
79
templates/advance_game/screen_gameplay.c
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/**********************************************************************************************
|
||||
*
|
||||
* raylib - Advance Game template
|
||||
*
|
||||
* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload)
|
||||
*
|
||||
* Copyright (c) 2014-2021 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"
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Variables Definition (local)
|
||||
//----------------------------------------------------------------------------------
|
||||
static int framesCounter = 0;
|
||||
static int finishScreen = 0;
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Gameplay Screen Functions Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Gameplay Screen Initialization logic
|
||||
void InitGameplayScreen(void)
|
||||
{
|
||||
// TODO: Initialize GAMEPLAY screen variables here!
|
||||
framesCounter = 0;
|
||||
finishScreen = 0;
|
||||
}
|
||||
|
||||
// Gameplay Screen Update logic
|
||||
void UpdateGameplayScreen(void)
|
||||
{
|
||||
// TODO: Update GAMEPLAY screen variables here!
|
||||
|
||||
// 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)
|
||||
{
|
||||
// TODO: Draw GAMEPLAY screen here!
|
||||
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), PURPLE);
|
||||
DrawTextEx(font, "GAMEPLAY SCREEN", (Vector2){ 20, 10 }, font.baseSize*3, 4, MAROON);
|
||||
DrawText("PRESS ENTER or TAP to JUMP to ENDING SCREEN", 130, 220, 20, MAROON);
|
||||
}
|
||||
|
||||
// Gameplay Screen Unload logic
|
||||
void UnloadGameplayScreen(void)
|
||||
{
|
||||
// TODO: Unload GAMEPLAY screen variables here!
|
||||
}
|
||||
|
||||
// Gameplay Screen should finish?
|
||||
int FinishGameplayScreen(void)
|
||||
{
|
||||
return finishScreen;
|
||||
}
|
||||
202
templates/advance_game/screen_logo.c
Normal file
202
templates/advance_game/screen_logo.c
Normal file
|
|
@ -0,0 +1,202 @@
|
|||
/**********************************************************************************************
|
||||
*
|
||||
* raylib - Advance Game template
|
||||
*
|
||||
* Logo Screen Functions Definitions (Init, Update, Draw, Unload)
|
||||
*
|
||||
* Copyright (c) 2014-2021 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"
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Variables Definition (local)
|
||||
//----------------------------------------------------------------------------------
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
69
templates/advance_game/screen_options.c
Normal file
69
templates/advance_game/screen_options.c
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/**********************************************************************************************
|
||||
*
|
||||
* raylib - Advance Game template
|
||||
*
|
||||
* Options Screen Functions Definitions (Init, Update, Draw, Unload)
|
||||
*
|
||||
* Copyright (c) 2014-2021 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"
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Variables Definition (local)
|
||||
//----------------------------------------------------------------------------------
|
||||
static int framesCounter = 0;
|
||||
static int finishScreen = 0;
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Options Screen Functions Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Options Screen Initialization logic
|
||||
void InitOptionsScreen(void)
|
||||
{
|
||||
// TODO: Initialize OPTIONS screen variables here!
|
||||
framesCounter = 0;
|
||||
finishScreen = 0;
|
||||
}
|
||||
|
||||
// Options Screen Update logic
|
||||
void UpdateOptionsScreen(void)
|
||||
{
|
||||
// TODO: Update OPTIONS screen variables here!
|
||||
}
|
||||
|
||||
// Options Screen Draw logic
|
||||
void DrawOptionsScreen(void)
|
||||
{
|
||||
// TODO: Draw OPTIONS screen here!
|
||||
}
|
||||
|
||||
// Options Screen Unload logic
|
||||
void UnloadOptionsScreen(void)
|
||||
{
|
||||
// TODO: Unload OPTIONS screen variables here!
|
||||
}
|
||||
|
||||
// Options Screen should finish?
|
||||
int FinishOptionsScreen(void)
|
||||
{
|
||||
return finishScreen;
|
||||
}
|
||||
80
templates/advance_game/screen_title.c
Normal file
80
templates/advance_game/screen_title.c
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
/**********************************************************************************************
|
||||
*
|
||||
* raylib - Advance Game template
|
||||
*
|
||||
* Title Screen Functions Definitions (Init, Update, Draw, Unload)
|
||||
*
|
||||
* Copyright (c) 2014-2021 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"
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Variables Definition (local)
|
||||
//----------------------------------------------------------------------------------
|
||||
static int framesCounter = 0;
|
||||
static int finishScreen = 0;
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Title Screen Functions Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Title Screen Initialization logic
|
||||
void InitTitleScreen(void)
|
||||
{
|
||||
// TODO: Initialize TITLE screen variables here!
|
||||
framesCounter = 0;
|
||||
finishScreen = 0;
|
||||
}
|
||||
|
||||
// Title Screen Update logic
|
||||
void UpdateTitleScreen(void)
|
||||
{
|
||||
// TODO: Update TITLE screen variables here!
|
||||
|
||||
// Press enter or tap to change to GAMEPLAY screen
|
||||
if (IsKeyPressed(KEY_ENTER) || IsGestureDetected(GESTURE_TAP))
|
||||
{
|
||||
//finishScreen = 1; // OPTIONS
|
||||
finishScreen = 2; // GAMEPLAY
|
||||
PlaySound(fxCoin);
|
||||
}
|
||||
}
|
||||
|
||||
// Title Screen Draw logic
|
||||
void DrawTitleScreen(void)
|
||||
{
|
||||
// TODO: Draw TITLE screen here!
|
||||
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), GREEN);
|
||||
DrawTextEx(font, "TITLE SCREEN", (Vector2){ 20, 10 }, font.baseSize*3, 4, DARKGREEN);
|
||||
DrawText("PRESS ENTER or TAP to JUMP to GAMEPLAY SCREEN", 120, 220, 20, DARKGREEN);
|
||||
}
|
||||
|
||||
// Title Screen Unload logic
|
||||
void UnloadTitleScreen(void)
|
||||
{
|
||||
// TODO: Unload TITLE screen variables here!
|
||||
}
|
||||
|
||||
// Title Screen should finish?
|
||||
int FinishTitleScreen(void)
|
||||
{
|
||||
return finishScreen;
|
||||
}
|
||||
95
templates/advance_game/screens.h
Normal file
95
templates/advance_game/screens.h
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
/**********************************************************************************************
|
||||
*
|
||||
* raylib - Advance Game template
|
||||
*
|
||||
* Screens Functions Declarations (Init, Update, Draw, Unload)
|
||||
*
|
||||
* Copyright (c) 2014-2021 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
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Types and Structures Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
typedef enum GameScreen { LOGO = 0, TITLE, OPTIONS, GAMEPLAY, ENDING } GameScreen;
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Global Variables Declaration (shared by several modules)
|
||||
//----------------------------------------------------------------------------------
|
||||
extern GameScreen currentScreen;
|
||||
extern Font font;
|
||||
extern Music music;
|
||||
extern Sound fxCoin;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" { // Prevents name mangling of functions
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// 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
|
||||
Loading…
Reference in a new issue