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
|
# Define all source files required
|
||||||
PROJECT_SOURCE_FILES ?= \
|
PROJECT_SOURCE_FILES ?= \
|
||||||
advance_game.c \
|
advance_game.c \
|
||||||
screens/screen_logo.c \
|
screen_logo.c \
|
||||||
screens/screen_title.c \
|
screen_title.c \
|
||||||
screens/screen_options.c \
|
screen_options.c \
|
||||||
screens/screen_gameplay.c \
|
screen_gameplay.c \
|
||||||
screens/screen_ending.c
|
screen_ending.c
|
||||||
|
|
||||||
# Define all object files from source files
|
# Define all object files from source files
|
||||||
OBJS = $(patsubst %.c, %.o, $(PROJECT_SOURCE_FILES))
|
OBJS = $(patsubst %.c, %.o, $(PROJECT_SOURCE_FILES))
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,15 @@
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#include "raylib.h"
|
#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)
|
#if defined(PLATFORM_WEB)
|
||||||
#include <emscripten/emscripten.h>
|
#include <emscripten/emscripten.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Shared Variables Definition (global)
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
GameScreen currentScreen = 0;
|
GameScreen currentScreen = 0;
|
||||||
Font font = { 0 };
|
Font font = { 0 };
|
||||||
Music music = { 0 };
|
Music music = { 0 };
|
||||||
|
|
@ -27,8 +30,8 @@ Sound fxCoin = { 0 };
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Global Variables Definition (local to this module)
|
// Global Variables Definition (local to this module)
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
const int screenWidth = 800;
|
static const int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
static const int screenHeight = 450;
|
||||||
|
|
||||||
// Required variables to manage screen transitions (fade-in, fade-out)
|
// Required variables to manage screen transitions (fade-in, fade-out)
|
||||||
static float transAlpha = 0.0f;
|
static float transAlpha = 0.0f;
|
||||||
|
|
@ -37,19 +40,16 @@ static bool transFadeOut = false;
|
||||||
static int transFromScreen = -1;
|
static int transFromScreen = -1;
|
||||||
static int transToScreen = -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
|
// 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 TransitionToScreen(int screen); // Request transition to next screen
|
||||||
static void UpdateTransition(void);
|
static void UpdateTransition(void); // Update transition effect
|
||||||
static void DrawTransition(void);
|
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
|
// Main entry point
|
||||||
|
|
@ -143,7 +143,7 @@ static void ChangeToScreen(int screen)
|
||||||
currentScreen = screen;
|
currentScreen = screen;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define transition to next screen
|
// Request transition to next screen
|
||||||
static void TransitionToScreen(int screen)
|
static void TransitionToScreen(int screen)
|
||||||
{
|
{
|
||||||
onTransition = true;
|
onTransition = true;
|
||||||
|
|
|
||||||
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