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
|
||||
|
@ -143,7 +143,7 @@ static void ChangeToScreen(int screen)
|
|||
currentScreen = screen;
|
||||
}
|
||||
|
||||
// Define transition to next screen
|
||||
// Request transition to next screen
|
||||
static void TransitionToScreen(int screen)
|
||||
{
|
||||
onTransition = true;
|
||||
|
|
|
@ -27,12 +27,10 @@
|
|||
#include "screens.h"
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Global Variables Definition (local to this module)
|
||||
// Module Variables Definition (local)
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Ending screen global variables
|
||||
static int framesCounter;
|
||||
static int finishScreen;
|
||||
static int framesCounter = 0;
|
||||
static int finishScreen = 0;
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Ending Screen Functions Definition
|
|
@ -27,12 +27,10 @@
|
|||
#include "screens.h"
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Global Variables Definition (local to this module)
|
||||
// Module Variables Definition (local)
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Gameplay screen global variables
|
||||
static int framesCounter;
|
||||
static int finishScreen;
|
||||
static int framesCounter = 0;
|
||||
static int finishScreen = 0;
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Gameplay Screen Functions Definition
|
|
@ -27,10 +27,8 @@
|
|||
#include "screens.h"
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Global Variables Definition (local to this module)
|
||||
// Module Variables Definition (local)
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Logo screen global variables
|
||||
static int framesCounter = 0;
|
||||
static int finishScreen = 0;
|
||||
|
|
@ -27,12 +27,10 @@
|
|||
#include "screens.h"
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Global Variables Definition (local to this module)
|
||||
// Module Variables Definition (local)
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Options screen global variables
|
||||
static int framesCounter;
|
||||
static int finishScreen;
|
||||
static int framesCounter = 0;
|
||||
static int finishScreen = 0;
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Options Screen Functions Definition
|
|
@ -27,12 +27,10 @@
|
|||
#include "screens.h"
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Global Variables Definition (local to this module)
|
||||
// Module Variables Definition (local)
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Title screen global variables
|
||||
static int framesCounter;
|
||||
static int finishScreen;
|
||||
static int framesCounter = 0;
|
||||
static int finishScreen = 0;
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Title Screen Functions Definition
|
|
@ -32,7 +32,7 @@
|
|||
typedef enum GameScreen { LOGO = 0, TITLE, OPTIONS, GAMEPLAY, ENDING } GameScreen;
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Global Variables Definition
|
||||
// Global Variables Declaration (shared by several modules)
|
||||
//----------------------------------------------------------------------------------
|
||||
extern GameScreen currentScreen;
|
||||
extern Font font;
|
Loading…
Add table
Add a link
Reference in a new issue