REVIEWED: Advance template

This commit is contained in:
raysan5 2021-06-30 16:38:23 +02:00
parent da8d76d826
commit de4611ecf6
8 changed files with 65 additions and 75 deletions

View File

@ -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))

View File

@ -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;

View File

@ -27,12 +27,10 @@
#include "screens.h" #include "screens.h"
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Global Variables Definition (local to this module) // Module Variables Definition (local)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
static int framesCounter = 0;
// Ending screen global variables static int finishScreen = 0;
static int framesCounter;
static int finishScreen;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Ending Screen Functions Definition // Ending Screen Functions Definition

View File

@ -27,12 +27,10 @@
#include "screens.h" #include "screens.h"
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Global Variables Definition (local to this module) // Module Variables Definition (local)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
static int framesCounter = 0;
// Gameplay screen global variables static int finishScreen = 0;
static int framesCounter;
static int finishScreen;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Gameplay Screen Functions Definition // Gameplay Screen Functions Definition

View File

@ -27,10 +27,8 @@
#include "screens.h" #include "screens.h"
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Global Variables Definition (local to this module) // Module Variables Definition (local)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Logo screen global variables
static int framesCounter = 0; static int framesCounter = 0;
static int finishScreen = 0; static int finishScreen = 0;

View File

@ -27,12 +27,10 @@
#include "screens.h" #include "screens.h"
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Global Variables Definition (local to this module) // Module Variables Definition (local)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
static int framesCounter = 0;
// Options screen global variables static int finishScreen = 0;
static int framesCounter;
static int finishScreen;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Options Screen Functions Definition // Options Screen Functions Definition

View File

@ -27,12 +27,10 @@
#include "screens.h" #include "screens.h"
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Global Variables Definition (local to this module) // Module Variables Definition (local)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
static int framesCounter = 0;
// Title screen global variables static int finishScreen = 0;
static int framesCounter;
static int finishScreen;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Title Screen Functions Definition // Title Screen Functions Definition

View File

@ -32,7 +32,7 @@
typedef enum GameScreen { LOGO = 0, TITLE, OPTIONS, GAMEPLAY, ENDING } GameScreen; typedef enum GameScreen { LOGO = 0, TITLE, OPTIONS, GAMEPLAY, ENDING } GameScreen;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Global Variables Definition // Global Variables Declaration (shared by several modules)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
extern GameScreen currentScreen; extern GameScreen currentScreen;
extern Font font; extern Font font;