From 1ef1f3d7ea40992b507ed6969df465fabb383910 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Thu, 18 Sep 2014 19:00:30 +0200 Subject: [PATCH] Multiple templates to start a game Some basic to advance templates are provided to be use as base code for new games --- templates/advance_game/advance_game.c | 226 ++++++++++++++++++ templates/advance_game/makefile | 118 +++++++++ .../advance_game/screens/screen_ending.c | 80 +++++++ .../advance_game/screens/screen_ending.o | Bin 0 -> 1622 bytes .../advance_game/screens/screen_gameplay.c | 80 +++++++ .../advance_game/screens/screen_gameplay.o | Bin 0 -> 1632 bytes templates/advance_game/screens/screen_logo.c | 81 +++++++ templates/advance_game/screens/screen_logo.o | Bin 0 -> 1362 bytes .../advance_game/screens/screen_options.c | 71 ++++++ .../advance_game/screens/screen_options.o | Bin 0 -> 1047 bytes templates/advance_game/screens/screen_title.c | 81 +++++++ templates/advance_game/screens/screen_title.o | Bin 0 -> 1617 bytes templates/advance_game/screens/screens.h | 92 +++++++ templates/basic_game/basic_game.c | 152 ++++++++++++ templates/basic_game/makefile | 90 +++++++ templates/basic_test/basic_test.c | 59 +++++ templates/basic_test/makefile | 90 +++++++ templates/simple_game/makefile | 98 ++++++++ templates/simple_game/screens.c | 195 +++++++++++++++ templates/simple_game/screens.h | 74 ++++++ templates/simple_game/screens.o | Bin 0 -> 3124 bytes templates/simple_game/simple_game.c | 98 ++++++++ templates/standard_game/makefile | 118 +++++++++ .../standard_game/screens/screen_ending.c | 80 +++++++ .../standard_game/screens/screen_ending.o | Bin 0 -> 1622 bytes .../standard_game/screens/screen_gameplay.c | 80 +++++++ .../standard_game/screens/screen_gameplay.o | Bin 0 -> 1632 bytes templates/standard_game/screens/screen_logo.c | 81 +++++++ templates/standard_game/screens/screen_logo.o | Bin 0 -> 1362 bytes .../standard_game/screens/screen_options.c | 71 ++++++ .../standard_game/screens/screen_options.o | Bin 0 -> 1047 bytes .../standard_game/screens/screen_title.c | 81 +++++++ .../standard_game/screens/screen_title.o | Bin 0 -> 1617 bytes templates/standard_game/screens/screens.h | 92 +++++++ templates/standard_game/standard_game.c | 144 +++++++++++ 35 files changed, 2432 insertions(+) create mode 100644 templates/advance_game/advance_game.c create mode 100644 templates/advance_game/makefile create mode 100644 templates/advance_game/screens/screen_ending.c create mode 100644 templates/advance_game/screens/screen_ending.o create mode 100644 templates/advance_game/screens/screen_gameplay.c create mode 100644 templates/advance_game/screens/screen_gameplay.o create mode 100644 templates/advance_game/screens/screen_logo.c create mode 100644 templates/advance_game/screens/screen_logo.o create mode 100644 templates/advance_game/screens/screen_options.c create mode 100644 templates/advance_game/screens/screen_options.o create mode 100644 templates/advance_game/screens/screen_title.c create mode 100644 templates/advance_game/screens/screen_title.o create mode 100644 templates/advance_game/screens/screens.h create mode 100644 templates/basic_game/basic_game.c create mode 100644 templates/basic_game/makefile create mode 100644 templates/basic_test/basic_test.c create mode 100644 templates/basic_test/makefile create mode 100644 templates/simple_game/makefile create mode 100644 templates/simple_game/screens.c create mode 100644 templates/simple_game/screens.h create mode 100644 templates/simple_game/screens.o create mode 100644 templates/simple_game/simple_game.c create mode 100644 templates/standard_game/makefile create mode 100644 templates/standard_game/screens/screen_ending.c create mode 100644 templates/standard_game/screens/screen_ending.o create mode 100644 templates/standard_game/screens/screen_gameplay.c create mode 100644 templates/standard_game/screens/screen_gameplay.o create mode 100644 templates/standard_game/screens/screen_logo.c create mode 100644 templates/standard_game/screens/screen_logo.o create mode 100644 templates/standard_game/screens/screen_options.c create mode 100644 templates/standard_game/screens/screen_options.o create mode 100644 templates/standard_game/screens/screen_title.c create mode 100644 templates/standard_game/screens/screen_title.o create mode 100644 templates/standard_game/screens/screens.h create mode 100644 templates/standard_game/standard_game.c diff --git a/templates/advance_game/advance_game.c b/templates/advance_game/advance_game.c new file mode 100644 index 000000000..891bbaf12 --- /dev/null +++ b/templates/advance_game/advance_game.c @@ -0,0 +1,226 @@ +/******************************************************************************************* +* +* raylib - Advance Game template +* +* +* +* +* This game has been created using raylib (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* +* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* +********************************************************************************************/ + +#include "raylib.h" +#include "screens/screens.h" // NOTE: Defines global variable: currentScreen + +//---------------------------------------------------------------------------------- +// Global Variables Definition (local to this module) +//---------------------------------------------------------------------------------- + +// Required variables to manage screen transitions (fade-in, fade-out) +float transAlpha = 0; +bool onTransition = false; +bool transFadeOut = false; +int transFromScreen = -1; +int transToScreen = -1; + +//---------------------------------------------------------------------------------- +// Local Functions Declaration +//---------------------------------------------------------------------------------- +void TransitionToScreen(int screen); +void UpdateTransition(void); +void DrawTransition(void); + +//---------------------------------------------------------------------------------- +// Main entry point +//---------------------------------------------------------------------------------- +int main(void) +{ + // Initialization + //--------------------------------------------------------- + const int screenWidth = 800; + const int screenHeight = 450; + const char windowTitle[30] = ""; + + InitWindow(screenWidth, screenHeight, windowTitle); + + // TODO: Load global data here (assets that must be available in all screens, i.e. fonts) + + // Setup and Init first screen + currentScreen = LOGO; + InitLogoScreen(); + + SetTargetFPS(60); + //---------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + if (!onTransition) + { + switch(currentScreen) + { + case LOGO: + { + UpdateLogoScreen(); + + if (FinishLogoScreen()) TransitionToScreen(TITLE); + + } break; + case TITLE: + { + UpdateTitleScreen(); + + if (FinishTitleScreen() == 1) TransitionToScreen(OPTIONS); + else if (FinishTitleScreen() == 2) TransitionToScreen(GAMEPLAY); + + } break; + case OPTIONS: + { + UpdateOptionsScreen(); + + if (FinishOptionsScreen()) TransitionToScreen(TITLE); + + } break; + case GAMEPLAY: + { + UpdateGameplayScreen(); + + if (FinishGameplayScreen()) TransitionToScreen(ENDING); + + } break; + case ENDING: + { + UpdateEndingScreen(); + + if (FinishEndingScreen()) TransitionToScreen(TITLE); + + } break; + default: break; + } + } + else + { + // Update transition (fade-in, fade-out) + UpdateTransition(); + } + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + switch(currentScreen) + { + case LOGO: DrawLogoScreen(); break; + case TITLE: DrawTitleScreen(); break; + case OPTIONS: DrawOptionsScreen(); break; + case GAMEPLAY: DrawGameplayScreen(); break; + case ENDING: DrawEndingScreen(); break; + default: break; + } + + if (onTransition) DrawTransition(); + + //DrawFPS(10, 10); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + + // TODO: Unload all global loaded data (i.e. fonts) here! + + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} + +void TransitionToScreen(int screen) +{ + onTransition = true; + transFromScreen = currentScreen; + transToScreen = screen; +} + +void UpdateTransition(void) +{ + if (!transFadeOut) + { + transAlpha += 0.01; + + if (transAlpha >= 1.0) + { + transAlpha = 1.0; + + switch (transFromScreen) + { + case LOGO: UnloadLogoScreen(); break; + case TITLE: UnloadTitleScreen(); break; + case OPTIONS: UnloadOptionsScreen(); break; + case GAMEPLAY: UnloadGameplayScreen(); break; + case ENDING: UnloadEndingScreen(); break; + default: break; + } + + switch (transToScreen) + { + case LOGO: + { + InitLogoScreen(); + currentScreen = LOGO; + } break; + case TITLE: + { + InitTitleScreen(); + currentScreen = TITLE; + } break; + case OPTIONS: + { + InitOptionsScreen(); + currentScreen = OPTIONS; + } break; + case GAMEPLAY: + { + InitGameplayScreen(); + currentScreen = GAMEPLAY; + } break; + case ENDING: + { + InitEndingScreen(); + currentScreen = ENDING; + } break; + default: break; + } + + transFadeOut = true; + } + } + else // Transition fade out logic + { + transAlpha -= 0.01f; + + if (transAlpha <= 0) + { + transAlpha = 0; + transFadeOut = false; + onTransition = false; + transFromScreen = -1; + transToScreen = -1; + } + } +} + +void DrawTransition(void) +{ + DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(BLACK, transAlpha)); +} \ No newline at end of file diff --git a/templates/advance_game/makefile b/templates/advance_game/makefile new file mode 100644 index 000000000..bf4b55892 --- /dev/null +++ b/templates/advance_game/makefile @@ -0,0 +1,118 @@ +#************************************************************************************************** +# +# raylib - Advance Game +# +# makefile to compile advance game +# +# Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +# +# 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. +# +#************************************************************************************************** + +# define raylib platform if not defined (by default, compile for RPI) +# Other possible platform: PLATFORM_DESKTOP +PLATFORM ?= PLATFORM_RPI + +# define compiler: gcc for C program, define as g++ for C++ +CC = gcc + +# define compiler flags: +# -O2 defines optimization level +# -Wall turns on most, but not all, compiler warnings +# -std=c99 use standard C from 1999 revision +CFLAGS = -O2 -Wall -std=c99 +#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes + +# define any directories containing required header files +ifeq ($(PLATFORM),PLATFORM_RPI) + INCLUDES = -I. -I./screens -I../../src -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads +else + INCLUDES = -I. -I./screens -I../../src +endif + +# define library paths containing required libs +LFLAGS = -L. -L../../src -L/opt/vc/lib + +# define any libraries to link into executable +# if you want to link libraries (libname.so or libname.a), use the -lname +ifeq ($(PLATFORM),PLATFORM_RPI) + # libraries for Raspberry Pi compiling + # NOTE: OpenAL Soft library should be installed (libopenal1 package) + LIBS = -lraylib -lGLESv2 -lEGL -lm -lbcm_host -lopenal +else + # libraries for Windows desktop compiling + # NOTE: GLFW3 and OpenAL Soft libraries should be installed + LIBS = -lraylib -lglfw3 -lglew32 -lopengl32 -lopenal32 -lgdi32 +endif + +# define additional parameters and flags for windows +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + # resources file contains windows exe icon + # -Wl,--subsystem,windows hides the console window + WINFLAGS = ../../src/resources -Wl,--subsystem,windows +endif + +# define all screen object files required +SCREENS = \ + screens/screen_logo.o \ + screens/screen_title.o \ + screens/screen_options.o \ + screens/screen_gameplay.o \ + screens/screen_ending.o \ + +# typing 'make' will invoke the first target entry in the file, +# in this case, the 'default' target entry is advance_game +default: advance_game + +# compile template - advance_game +advance_game: advance_game.c $(SCREENS) + $(CC) -o $@ $< $(SCREENS) $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) + +# compile screen LOGO +screens/screen_logo.o: screens/screen_logo.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen TITLE +screens/screen_title.o: screens/screen_title.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen OPTIONS +screens/screen_options.o: screens/screen_options.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen GAMEPLAY +screens/screen_gameplay.o: screens/screen_gameplay.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen ENDING +screens/screen_ending.o: screens/screen_ending.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# clean everything +clean: +ifeq ($(PLATFORM),PLATFORM_RPI) + rm -f screens/*.o +# find . -executable -delete +else + del screens/*.o *.exe +endif + @echo Cleaning done + +# instead of defining every module one by one, we can define a pattern +# this pattern below will automatically compile every module defined on $(OBJS) +#%.exe : %.c +# $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) diff --git a/templates/advance_game/screens/screen_ending.c b/templates/advance_game/screens/screen_ending.c new file mode 100644 index 000000000..3d9f81a1a --- /dev/null +++ b/templates/advance_game/screens/screen_ending.c @@ -0,0 +1,80 @@ +/********************************************************************************************** +* +* raylib - Advance Game template +* +* Ending Screen Functions Definitions (Init, Update, Draw, Unload) +* +* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* +* 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 to return to TITLE screen + if (IsKeyPressed(KEY_ENTER)) + { + finishScreen = 1; + } +} + +// Ending Screen Draw logic +void DrawEndingScreen(void) +{ + // TODO: Draw ENDING screen here! + DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), BLUE); + DrawText("ENDING SCREEN", 20, 20, 40, DARKBLUE); + DrawText("PRESS ENTER to RETURN to TITLE SCREEN", 160, 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; +} \ No newline at end of file diff --git a/templates/advance_game/screens/screen_ending.o b/templates/advance_game/screens/screen_ending.o new file mode 100644 index 0000000000000000000000000000000000000000..5d819b1618a9985a76c14bbd404a5ea8142fc9cb GIT binary patch literal 1622 zcmZ`)L2DCH5S~r8vXl@!RIIkhT65^ZZi5slqL7lTZLx&9N%5c(*W@)>NH=A7+gkBZ zh=QdE5fMBpc=Y5Su#iGL3Mzm5<4(6-}~NVX5QQPUY4X2K;k3; z#yOHD&0`Ndj)nPwPL=>ZCd4>}PKE3}t!8?rppLaU$nIEP0k0w$^?M6AsyjUsjD+u?o5i>su9aj6mGbonaOn-nKI%T(g!bWh zPtHi#!Ea)p?0dr^fO={lj8jaheK^Tyce~v63Yn9z{pV=+PA0Wm$S64GDKQb{=*JlE zj&LqDi6nYuM0lC|V`BXng}w*neNA4*dVb#a!Q^e~iS!Ls?RGkPv9MU2S4(+A*NaFk z8+xgv>cz5ds9sAo^zw>PBvf83FX{a_b;@j7b-UVHTe~t*sctw9v%ON)Va%SmcnN@d zA(0*$AU#r~v6L)7#eJb>=p0e`Q>Y{qn?)u5JSybV>fN*qD#8WS9O`pam`f||L_VEO z?4^~tE=GuaP4r(-F+CTmv4i>zRh(V``uu4=rqe0V1w^M&M_?-C<`9i?jw+wwi1MH1 z=mlEJega;h9pl`GkUI#uuZTnq711#22+V|NDMafbdK@Bc)oKPu_wNxvU2^%hR+wG0 z?7CLPND|6VBH=zIf~5;8w5pHjK#M~?jfnQG&s@V1t(fOQ4{#IpDr%phnxA6K7LLT8 zV|9qW2-Hea`i_=%x-Ze!fWAiZKRriZ0^Xsd^b`0f`U>!sNS6m=A};`4-lTMHAclxN zpQTfhlsag`tM1PLyhKEGNT_dsx7?DUwUfN(mQ28O2bj+T%&!=8h$D?PDyxpU#-Orj zTb|CpxVTjyCfs~$!}geiL(8_@MliXuj&CE2|DfQQTXAN^Znn%?oV(8R#JETsv73!u txi{GMvcp`L)u1xZ{42k}ta`(X5Vx$F*MJIjVBlM9+I2kBd|0Ocj(@7|?#loG literal 0 HcmV?d00001 diff --git a/templates/advance_game/screens/screen_gameplay.c b/templates/advance_game/screens/screen_gameplay.c new file mode 100644 index 000000000..307f2ea38 --- /dev/null +++ b/templates/advance_game/screens/screen_gameplay.c @@ -0,0 +1,80 @@ +/********************************************************************************************** +* +* raylib - Advance Game template +* +* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) +* +* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* +* 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) +//---------------------------------------------------------------------------------- + +// Gameplay screen global variables +static int framesCounter; +static int finishScreen; + +//---------------------------------------------------------------------------------- +// 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 to change to ENDING screen + if (IsKeyPressed(KEY_ENTER)) + { + finishScreen = 1; + } +} + +// Gameplay Screen Draw logic +void DrawGameplayScreen(void) +{ + // TODO: Draw GAMEPLAY screen here! + DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), PURPLE); + DrawText("GAMEPLAY SCREEN", 20, 20, 40, MAROON); + DrawText("PRESS ENTER to JUMP to ENDING SCREEN", 170, 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; +} \ No newline at end of file diff --git a/templates/advance_game/screens/screen_gameplay.o b/templates/advance_game/screens/screen_gameplay.o new file mode 100644 index 0000000000000000000000000000000000000000..b31cccb3157d004b0aa66bf7e673f077dc156473 GIT binary patch literal 1632 zcmZ`)&ubG=5S~r8vXl^ds90^0ZOx$vyGE&4L@*(VX|)X@X%JC~YqCui(oNajR$BxM zQLu;*5y6{y_26G1T1X+i2p$wf6g+z9*`smhz1__wu>&*n&G#nrX5X(Y3P*s%3<69r zBnpbH-M1O$<_9`a0N4-kID}4y=pCi3+A60GwK0h9Dt9f*pCI`I2X9lJ*;{Z9$A00w ze!+S%rEF>?dqZ=18Nry-o6FI>XJ*}q`zE?M%!}c-k_@3zy*2?R?IF=Yt!Eq1IGAXQ z5dk~+P3+@cdzdFsPmR3^%E>nlrrGFDi@A0(GP1wb>FnH!gm#h<31e0g3sDU(=fmWM z4vvMUkwh@WNMl* zb^06t^+F5rn4P;L~J_(@bqgyq{|5oCn(s4>*%s1OfJ zjX)wC4Ll7?@fK$AdNuT4P-)poXpU{vZ>aqA0?_t{Sxl#sqf>~Ep^n0g$HftiF^*Dm7hunq;OTfjm7SAczqaDFhy_X5!6 z4GJd*a)@~8uyjg-LKCfb)twQ5*NA8y66zb^9kXQU+ezLtOU7kB4KP0kn1deX4@Qbs zEv}fj&rn=2bUW?rIKNlGhpa?>-LN$iL*3A=sykR%!`D&k|4GtR@AY#9qgGeT{p=N1 zt&jCJ)N{wNKkJ&dnKd=b(#lXwYtH4L*Yrx&_7T_hvR#ED^^wC@Sv4wnx>>kP|04eY Dj(qix literal 0 HcmV?d00001 diff --git a/templates/advance_game/screens/screen_logo.c b/templates/advance_game/screens/screen_logo.c new file mode 100644 index 000000000..1cd428306 --- /dev/null +++ b/templates/advance_game/screens/screen_logo.c @@ -0,0 +1,81 @@ +/********************************************************************************************** +* +* raylib - Advance Game template +* +* Logo Screen Functions Definitions (Init, Update, Draw, Unload) +* +* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* +* 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) +//---------------------------------------------------------------------------------- + +// Logo screen global variables +static int framesCounter; +static int finishScreen; + +//---------------------------------------------------------------------------------- +// Logo Screen Functions Definition +//---------------------------------------------------------------------------------- + +// Logo Screen Initialization logic +void InitLogoScreen(void) +{ + // TODO: Initialize LOGO screen variables here! + framesCounter = 0; + finishScreen = 0; +} + +// Logo Screen Update logic +void UpdateLogoScreen(void) +{ + // TODO: Update LOGO screen variables here! + + framesCounter++; // Count frames + + // Wait for 2 seconds (120 frames) before jumping to TITLE screen + if (framesCounter > 120) + { + finishScreen = true; + } +} + +// Logo Screen Draw logic +void DrawLogoScreen(void) +{ + // TODO: Draw LOGO screen here! + DrawText("LOGO SCREEN", 20, 20, 40, LIGHTGRAY); + DrawText("WAIT for 2 SECONDS...", 290, 220, 20, GRAY); +} + +// Logo Screen Unload logic +void UnloadLogoScreen(void) +{ + // TODO: Unload LOGO screen variables here! +} + +// Logo Screen should finish? +int FinishLogoScreen(void) +{ + return finishScreen; +} \ No newline at end of file diff --git a/templates/advance_game/screens/screen_logo.o b/templates/advance_game/screens/screen_logo.o new file mode 100644 index 0000000000000000000000000000000000000000..10a997460c0288faaf8b7624a0fd96bd3ab3430c GIT binary patch literal 1362 zcmZ`(-D(q25T4U)ODLiABBD~!CG)ErLI!G2Q$?vRgLWT0|ta zAc6?F@IpmIu@6#+kX-l(K0q&g0IyoVIcIlsLUmwfzWL5%=A5%hIbiZvqU@<{e#M3Nw`N!W|>;XK;>5#9VK{K+0g!2vGmsE`4L1{m%B_&)&;v zwaSh9y@TKBL4JOAI2@kBC$55ok0+Hkq&N5gbj*fx_xJZ@ZjclIrFbKSiUVUl5#}EJ zNcVfPKX0br>#Y>;7R^#_tx#B{2e+5k&6?|(i)N{iE3W2CmSrK$T&T2~b*JjK+c#6? z>W=5xj$f*Jw(X?Si$vU%MLb_4@ggqf5{B^xjc37Kf^w^KP!{GgQ0C{LEd2XC^aivH zrQA$r;?a!3xsRbApnNkd%xyzIL)Ggd;wzt#F`rYRixIjKp=%L(2*j19WWV!3NqQY| zZ-Er|5lGcDf%t7EX(>YYBD5JHKSEZm*$SW0$th7?bmWzlTW;O8s>oBq^;ra&G!Y(C zQIWkIpcp(W(E^n3b;R64#8W2gz!Tkv@@_}W6GZRF7#EScUvwvZI(aKG@dcL8JraE~ z`Q~H)*t0&Ba);vVT^o7 zi9SiohR=QoZ`qA<&8xI+Dla=te+6Gky>n7@C+F@szU?7wI?YZaT-?~kzl*J>=e^1^ cJ>GCyZe>en?#K!nqctC!F)DMhb^hP{3m3w*6951J literal 0 HcmV?d00001 diff --git a/templates/advance_game/screens/screen_options.c b/templates/advance_game/screens/screen_options.c new file mode 100644 index 000000000..87d322648 --- /dev/null +++ b/templates/advance_game/screens/screen_options.c @@ -0,0 +1,71 @@ +/********************************************************************************************** +* +* raylib - Advance Game template +* +* Options Screen Functions Definitions (Init, Update, Draw, Unload) +* +* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* +* 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) +//---------------------------------------------------------------------------------- + +// Options screen global variables +static int framesCounter; +static int finishScreen; + +//---------------------------------------------------------------------------------- +// 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; +} \ No newline at end of file diff --git a/templates/advance_game/screens/screen_options.o b/templates/advance_game/screens/screen_options.o new file mode 100644 index 0000000000000000000000000000000000000000..17153fd9391c8116c94c9c4f84c5bd26791e5ed7 GIT binary patch literal 1047 zcmZ`&O-sW-5S{IZ6cO>DASe<=L8Qhao;*lF5d}d|1P?-u=~e@6Qj)ZadhqB)=-Hd# z#eX68;GghkcvjzJlXP2k;O)M7JDHswCVL`JY@dQ?B4RmVhVm+mxLS(XK7eP$uw?;* zN~dPk3av=_e<@Sx)jSIVJ))pHF~8%usxR%ZEt6vdq!8bkXq<0lE%DTTi)|5cZ*eTY z2yx|i^)z_z`J4)+?nAo|Pkhkrbc|)I?wq@}*J!NIRqU4UOE)~UeJS0!;wsU2{Jpq7 zAaPp|QzNUY4z>)vU^V4MrRG}=NtIpK3HMdc)u@p= u2{yf!8%iIp<2u1ba(L9lA14RC*z&E*0qMxCdscNo+>TQ9i&`yxBTqkOZH7bu literal 0 HcmV?d00001 diff --git a/templates/advance_game/screens/screen_title.c b/templates/advance_game/screens/screen_title.c new file mode 100644 index 000000000..9c288fb58 --- /dev/null +++ b/templates/advance_game/screens/screen_title.c @@ -0,0 +1,81 @@ +/********************************************************************************************** +* +* raylib - Advance Game template +* +* Title Screen Functions Definitions (Init, Update, Draw, Unload) +* +* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* +* 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; +static int finishScreen; + +//---------------------------------------------------------------------------------- +// 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 to change to GAMEPLAY screen + if (IsKeyPressed(KEY_ENTER)) + { + //finishScreen = 1; // OPTIONS + finishScreen = 2; // GAMEPLAY + } +} + +// Title Screen Draw logic +void DrawTitleScreen(void) +{ + // TODO: Draw TITLE screen here! + DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), GREEN); + DrawText("TITLE SCREEN", 20, 20, 40, DARKGREEN); + DrawText("PRESS ENTER to JUMP to GAMEPLAY SCREEN", 160, 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; +} \ No newline at end of file diff --git a/templates/advance_game/screens/screen_title.o b/templates/advance_game/screens/screen_title.o new file mode 100644 index 0000000000000000000000000000000000000000..cbe172970ef8449bd74dfafff655df68dbec40f7 GIT binary patch literal 1617 zcmZ`)PiqrV5T8x9Who(es90^$wdT-6y9Oy(#6v>5w$-$T{6Rz|U6a>jA>EYSZT*9X zLR2gwM7(%YKY(9B3n|2tcu){g@F3`+pTRow-e$8)?7+#fI8-Ltd3k??JFa~PMxwUP{>Qob$$F5My7L!D<^(AuBq z$_WWO_(SZYU3WwTP_5S91jQ6u`%`>&r^8)$K5+zoB@cFPCSp7D2?fVIB_^UA{g}<^ z1DuOZA&FiY6<+54kXSE9q3=O?Uz3-yo|m_^H+6%0B7H+uJMDIHshHK(LME^4E66}D zuNMlczEafls@qgAmzHzn7t+gmE}OpYN2)VM!>n1A=KA`D$#P}WwwdJ?DmG)*V-tQp9krIB8|sn`3de6HACl!${$4~q1YrU@uyKC6IXA=Wl#|=qNY%vqe42av?7^! zGV(O8q&pZP@-@(ZM#c18sKz$xS5$F&0qB#&`It_pKxYsgLmh<~pGzYe;~Z5!&JpE5 z!O;t}lzkXpq8;bld!O6$xi5%B4HeM{>L|?mDC?sQA3gMuwq`bZNB8dmKuvP^ww7Jf zZ7{8Zfm|p*iG=$U=`CGQzCGn3I?&=!Ylvvy`piWf(TaH<^Z-{;iS0A1IQkS~=)#IU z$LbJ#5vY}@^bIZTbYFt60ey|=e|iqS1iV8@=_l||@D<=IkJm>9qyim;E;Tmf tTw(WeHggy7{b literal 0 HcmV?d00001 diff --git a/templates/advance_game/screens/screens.h b/templates/advance_game/screens/screens.h new file mode 100644 index 000000000..88537d9bf --- /dev/null +++ b/templates/advance_game/screens/screens.h @@ -0,0 +1,92 @@ +/********************************************************************************************** +* +* raylib - Advance Game template +* +* Screens Functions Declarations (Init, Update, Draw, Unload) +* +* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* +* 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, TITLE, OPTIONS, GAMEPLAY, ENDING } GameScreen; + +//---------------------------------------------------------------------------------- +// Global Variables Definition +//---------------------------------------------------------------------------------- +GameScreen currentScreen; + +#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 \ No newline at end of file diff --git a/templates/basic_game/basic_game.c b/templates/basic_game/basic_game.c new file mode 100644 index 000000000..990552c83 --- /dev/null +++ b/templates/basic_game/basic_game.c @@ -0,0 +1,152 @@ +/******************************************************************************************* +* +* raylib - Basic Game template +* +* +* +* +* This game has been created using raylib v1.2 (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* +* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* +********************************************************************************************/ + +#include "raylib.h" + +//---------------------------------------------------------------------------------- +// Types and Structures Definition +//---------------------------------------------------------------------------------- +typedef enum GameScreen { LOGO, TITLE, GAMEPLAY, ENDING } GameScreen; + +//---------------------------------------------------------------------------------- +// Main entry point +//---------------------------------------------------------------------------------- +int main() +{ + // Initialization + //-------------------------------------------------------------------------------------- + const int screenWidth = 800; + const int screenHeight = 450; + const char windowTitle[30] = ""; + + GameScreen currentScreen = LOGO; + + InitWindow(screenWidth, screenHeight, windowTitle); + + // TODO: Initialize all required variables and load all required data here! + + int framesCounter = 0; // Used to count frames + + SetTargetFPS(60); + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + switch(currentScreen) + { + case LOGO: + { + // TODO: Update LOGO screen variables here! + + framesCounter++; // Count frames + + // Wait for 2 seconds (120 frames) before jumping to TITLE screen + if (framesCounter > 120) + { + currentScreen = TITLE; + } + } break; + case TITLE: + { + // TODO: Update TITLE screen variables here! + + // Press enter to change to GAMEPLAY screen + if (IsKeyPressed(KEY_ENTER)) + { + currentScreen = GAMEPLAY; + } + } break; + case GAMEPLAY: + { + // TODO: Update GAMEPLAY screen variables here! + + // Press enter to change to ENDING screen + if (IsKeyPressed(KEY_ENTER)) + { + currentScreen = ENDING; + } + } break; + case ENDING: + { + // TODO: Update ENDING screen variables here! + + // Press enter to return to TITLE screen + if (IsKeyPressed(KEY_ENTER)) + { + currentScreen = TITLE; + } + } break; + default: break; + } + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + switch(currentScreen) + { + case LOGO: + { + // TODO: Draw LOGO screen here! + DrawText("LOGO SCREEN", 20, 20, 40, LIGHTGRAY); + DrawText("WAIT for 2 SECONDS...", 290, 220, 20, GRAY); + + } break; + case TITLE: + { + // TODO: Draw TITLE screen here! + DrawRectangle(0, 0, screenWidth, screenHeight, GREEN); + DrawText("TITLE SCREEN", 20, 20, 40, DARKGREEN); + DrawText("PRESS ENTER to JUMP to GAMEPLAY SCREEN", 160, 220, 20, DARKGREEN); + + } break; + case GAMEPLAY: + { + // TODO: Draw GAMEPLAY screen here! + DrawRectangle(0, 0, screenWidth, screenHeight, PURPLE); + DrawText("GAMEPLAY SCREEN", 20, 20, 40, MAROON); + DrawText("PRESS ENTER to JUMP to ENDING SCREEN", 170, 220, 20, MAROON); + + } break; + case ENDING: + { + // TODO: Draw ENDING screen here! + DrawRectangle(0, 0, screenWidth, screenHeight, BLUE); + DrawText("ENDING SCREEN", 20, 20, 40, DARKBLUE); + DrawText("PRESS ENTER to RETURN to TITLE SCREEN", 160, 220, 20, DARKBLUE); + + } break; + default: break; + } + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + + // TODO: Unload all loaded data (textures, fonts, audio) here! + + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} \ No newline at end of file diff --git a/templates/basic_game/makefile b/templates/basic_game/makefile new file mode 100644 index 000000000..6b3d647e1 --- /dev/null +++ b/templates/basic_game/makefile @@ -0,0 +1,90 @@ +#************************************************************************************************** +# +# raylib - Basic Game +# +# makefile to compile basic game +# +# Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +# +# 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. +# +#************************************************************************************************** + +# define raylib platform (by default, compile for RPI) +# Other possible platform: PLATFORM_DESKTOP +PLATFORM ?= PLATFORM_RPI + +# define compiler: gcc for C program, define as g++ for C++ +CC = gcc + +# define compiler flags: +# -O2 defines optimization level +# -Wall turns on most, but not all, compiler warnings +# -std=c99 use standard C from 1999 revision +CFLAGS = -O2 -Wall -std=c99 +#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes + +# define any directories containing required header files +ifeq ($(PLATFORM),PLATFORM_RPI) + INCLUDES = -I. -I../../src -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads +else + INCLUDES = -I. -I../../src +endif + +# define library paths containing required libs +LFLAGS = -L. -L../../src -L/opt/vc/lib + +# define any libraries to link into executable +# if you want to link libraries (libname.so or libname.a), use the -lname +ifeq ($(PLATFORM),PLATFORM_RPI) + # libraries for Raspberry Pi compiling + # NOTE: OpenAL Soft library should be installed (libopenal1 package) + LIBS = -lraylib -lGLESv2 -lEGL -lm -lbcm_host -lopenal +else + # libraries for Windows desktop compiling + # NOTE: GLFW3 and OpenAL Soft libraries should be installed + LIBS = -lraylib -lglfw3 -lglew32 -lopengl32 -lopenal32 -lgdi32 +endif + +# define additional parameters and flags for windows +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + # resources file contains windows exe icon + # -Wl,--subsystem,windows hides the console window + WINFLAGS = ../../src/resources -Wl,--subsystem,windows +endif + +# typing 'make' will invoke the first target entry in the file, +# in this case, the 'default' target entry is basic_game +default: basic_game + +# compile template - basic_game +basic_game: basic_game.c + $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) + +# clean everything +clean: +ifeq ($(PLATFORM),PLATFORM_RPI) + rm -f *.o +# find . -executable -delete +else + del *.o *.exe +endif + @echo Cleaning done + +# instead of defining every module one by one, we can define a pattern +# this pattern below will automatically compile every module defined on $(OBJS) +#%.exe : %.c +# $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) diff --git a/templates/basic_test/basic_test.c b/templates/basic_test/basic_test.c new file mode 100644 index 000000000..d4359df51 --- /dev/null +++ b/templates/basic_test/basic_test.c @@ -0,0 +1,59 @@ +/******************************************************************************************* +* +* raylib - Template for basic test +* +* +* +* This example has been created using raylib v1.2 (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* +* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* +********************************************************************************************/ + +#include "raylib.h" + +int main() +{ + // Initialization + //-------------------------------------------------------------------------------------- + const int screenWidth = 800; + const int screenHeight = 450; + + InitWindow(screenWidth, screenHeight, "raylib basic test - "); + + // TODO: Initialize all required variables and load all required data here! + + SetTargetFPS(60); + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + // TODO: Update your variables here + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + DrawText("BASIC TEST TEMPLATE", 270, 180, 20, LIGHTGRAY); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + + // TODO: Unload all loaded data (textures, fonts, audio) here! + + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} \ No newline at end of file diff --git a/templates/basic_test/makefile b/templates/basic_test/makefile new file mode 100644 index 000000000..648c48020 --- /dev/null +++ b/templates/basic_test/makefile @@ -0,0 +1,90 @@ +#************************************************************************************************** +# +# raylib - Basic Test +# +# makefile to compile basic test +# +# Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +# +# 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. +# +#************************************************************************************************** + +# define raylib platform if not defined (by default, compile for RPI) +# Other possible platform: PLATFORM_DESKTOP +PLATFORM ?= PLATFORM_RPI + +# define compiler: gcc for C program, define as g++ for C++ +CC = gcc + +# define compiler flags: +# -O2 defines optimization level +# -Wall turns on most, but not all, compiler warnings +# -std=c99 use standard C from 1999 revision +CFLAGS = -O2 -Wall -std=c99 +#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes + +# define any directories containing required header files +ifeq ($(PLATFORM),PLATFORM_RPI) + INCLUDES = -I. -I../../src -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads +else + INCLUDES = -I. -I../../src +endif + +# define library paths containing required libs +LFLAGS = -L. -L../../src -L/opt/vc/lib + +# define any libraries to link into executable +# if you want to link libraries (libname.so or libname.a), use the -lname +ifeq ($(PLATFORM),PLATFORM_RPI) + # libraries for Raspberry Pi compiling + # NOTE: OpenAL Soft library should be installed (libopenal1 package) + LIBS = -lraylib -lGLESv2 -lEGL -lm -lbcm_host -lopenal +else + # libraries for Windows desktop compiling + # NOTE: GLFW3 and OpenAL Soft libraries should be installed + LIBS = -lraylib -lglfw3 -lglew32 -lopengl32 -lopenal32 -lgdi32 +endif + +# define additional parameters and flags for windows +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + # resources file contains windows exe icon + # -Wl,--subsystem,windows hides the console window + WINFLAGS = ../../src/resources -Wl,--subsystem,windows +endif + +# typing 'make' will invoke the first target entry in the file, +# in this case, the 'default' target entry is basic_test +default: basic_test + +# compile template - basic_test +basic_test: basic_test.c + $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) + +# clean everything +clean: +ifeq ($(PLATFORM),PLATFORM_RPI) + rm -f *.o +# find . -executable -delete +else + del *.o *.exe +endif + @echo Cleaning done + +# instead of defining every module one by one, we can define a pattern +# this pattern below will automatically compile every module defined on $(OBJS) +#%.exe : %.c +# $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) diff --git a/templates/simple_game/makefile b/templates/simple_game/makefile new file mode 100644 index 000000000..418df1a35 --- /dev/null +++ b/templates/simple_game/makefile @@ -0,0 +1,98 @@ +#************************************************************************************************** +# +# raylib - Simple Game +# +# makefile to compile simple game +# +# Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +# +# 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. +# +#************************************************************************************************** + +# define raylib platform (by default, compile for RPI) +# Other possible platform: PLATFORM_DESKTOP +PLATFORM ?= PLATFORM_RPI + +# define compiler: gcc for C program, define as g++ for C++ +CC = gcc + +# define compiler flags: +# -O2 defines optimization level +# -Wall turns on most, but not all, compiler warnings +# -std=c99 use standard C from 1999 revision +ifeq ($(PLATFORM),PLATFORM_RPI) + CFLAGS = -O2 -Wall -std=gnu99 -fgnu89-inline +else + CFLAGS = -O2 -Wall -std=c99 +endif +#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes + +# define any directories containing required header files +ifeq ($(PLATFORM),PLATFORM_RPI) + INCLUDES = -I. -I../../src -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads +else + INCLUDES = -I. -I../../src +endif + +# define library paths containing required libs +LFLAGS = -L. -L../../src -L/opt/vc/lib + +# define any libraries to link into executable +# if you want to link libraries (libname.so or libname.a), use the -lname +ifeq ($(PLATFORM),PLATFORM_RPI) + # libraries for Raspberry Pi compiling + # NOTE: OpenAL Soft library should be installed (libopenal1 package) + LIBS = -lraylib -lGLESv2 -lEGL -lm -lbcm_host -lopenal +else + # libraries for Windows desktop compiling + # NOTE: GLFW3 and OpenAL Soft libraries should be installed + LIBS = -lraylib -lglfw3 -lglew32 -lopengl32 -lopenal32 -lgdi32 +endif + +# define additional parameters and flags for windows +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + # resources file contains windows exe icon + # -Wl,--subsystem,windows hides the console window + WINFLAGS = ../../src/resources -Wl,--subsystem,windows +endif + +# typing 'make' will invoke the first target entry in the file, +# in this case, the 'default' target entry is simple_game +default: simple_game + +# compile template - simple_game +simple_game: simple_game.c screens.o + $(CC) -o $@ $< screens.o $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) + +# compile screens +screens.o: screens.c + $(CC) -c $< $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# clean everything +clean: +ifeq ($(PLATFORM),PLATFORM_RPI) + rm -f *.o +# find . -executable -delete +else + del *.o *.exe +endif + @echo Cleaning done + +# instead of defining every module one by one, we can define a pattern +# this pattern below will automatically compile every module defined on $(OBJS) +#%.exe : %.c +# $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) diff --git a/templates/simple_game/screens.c b/templates/simple_game/screens.c new file mode 100644 index 000000000..742cf6f87 --- /dev/null +++ b/templates/simple_game/screens.c @@ -0,0 +1,195 @@ +/********************************************************************************************** +* +* raylib - Simple Game template +* +* Screens Functions Definitions (Init, Update, Draw, Unload) +* +* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* +* 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 (visible to other modules) +//---------------------------------------------------------------------------------- +GameScreen currentScreen = LOGO; + +//---------------------------------------------------------------------------------- +// Global Variables Definition (local to this module) +//---------------------------------------------------------------------------------- + +// Logo screen global variables +static int framesCounter; + +// Title screen global variables + +// Gameplay screen global variables + +// Ending screen global variables + +//---------------------------------------------------------------------------------- +// Logo Screen Functions Definition +//---------------------------------------------------------------------------------- + +// Logo Screen Initialization logic +void InitLogoScreen(void) +{ + // TODO: Initialize LOGO screen variables here! + framesCounter = 0; +} + +// Logo Screen Update logic +void UpdateLogoScreen(void) +{ + // TODO: Update LOGO screen variables here! + + framesCounter++; // Count frames + + // Wait for 2 seconds (120 frames) before jumping to TITLE screen + if (framesCounter > 120) + { + currentScreen = TITLE; + } +} + +// Logo Screen Draw logic +void DrawLogoScreen(void) +{ + // TODO: Draw LOGO screen here! + DrawText("LOGO SCREEN", 20, 20, 40, LIGHTGRAY); + DrawText("WAIT for 2 SECONDS...", 290, 220, 20, GRAY); +} + +// Logo Screen Unload logic +void UnloadLogoScreen(void) +{ + // TODO: Unload LOGO screen variables here! +} + +//---------------------------------------------------------------------------------- +// Title Screen Functions Definition +//---------------------------------------------------------------------------------- + +// Title Screen Initialization logic +void InitTitleScreen(void) +{ + // TODO: Initialize TITLE screen variables here! +} + +// Title Screen Update logic +void UpdateTitleScreen(void) +{ + // TODO: Update TITLE screen variables here! + + // Press enter to change to GAMEPLAY screen + if (IsKeyPressed(KEY_ENTER)) + { + currentScreen = GAMEPLAY; + } +} + +// Title Screen Draw logic +void DrawTitleScreen(void) +{ + // TODO: Draw TITLE screen here! + DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), GREEN); + DrawText("TITLE SCREEN", 20, 20, 40, DARKGREEN); + DrawText("PRESS ENTER to JUMP to GAMEPLAY SCREEN", 160, 220, 20, DARKGREEN); +} + +// Title Screen Unload logic +void UnloadTitleScreen(void) +{ + // TODO: Unload TITLE screen variables here! +} + +//---------------------------------------------------------------------------------- +// Gameplay Screen Functions Definition +//---------------------------------------------------------------------------------- + +// Gameplay Screen Initialization logic +void InitGameplayScreen(void) +{ + // TODO: Initialize GAMEPLAY screen variables here! +} + +// Gameplay Screen Update logic +void UpdateGameplayScreen(void) +{ + // TODO: Update GAMEPLAY screen variables here! + + // Press enter to change to ENDING screen + if (IsKeyPressed(KEY_ENTER)) + { + currentScreen = ENDING; + } +} + +// Gameplay Screen Draw logic +void DrawGameplayScreen(void) +{ + // TODO: Draw GAMEPLAY screen here! + DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), PURPLE); + DrawText("GAMEPLAY SCREEN", 20, 20, 40, MAROON); + DrawText("PRESS ENTER to JUMP to ENDING SCREEN", 170, 220, 20, MAROON); +} + +// Gameplay Screen Unload logic +void UnloadGameplayScreen(void) +{ + // TODO: Unload GAMEPLAY screen variables here! +} + +//---------------------------------------------------------------------------------- +// Ending Screen Functions Definition +//---------------------------------------------------------------------------------- + +// Ending Screen Initialization logic +void InitEndingScreen(void) +{ + // TODO: Initialize ENDING screen variables here! +} + +// Ending Screen Update logic +void UpdateEndingScreen(void) +{ + // TODO: Update ENDING screen variables here! + + // Press enter to return to TITLE screen + if (IsKeyPressed(KEY_ENTER)) + { + currentScreen = TITLE; + } +} + +// Ending Screen Draw logic +void DrawEndingScreen(void) +{ + // TODO: Draw ENDING screen here! + DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), BLUE); + DrawText("ENDING SCREEN", 20, 20, 40, DARKBLUE); + DrawText("PRESS ENTER to RETURN to TITLE SCREEN", 160, 220, 20, DARKBLUE); +} + +// Ending Screen Unload logic +void UnloadEndingScreen(void) +{ + // TODO: Unload ENDING screen variables here! +} \ No newline at end of file diff --git a/templates/simple_game/screens.h b/templates/simple_game/screens.h new file mode 100644 index 000000000..7afaebeb2 --- /dev/null +++ b/templates/simple_game/screens.h @@ -0,0 +1,74 @@ +/********************************************************************************************** +* +* raylib - Simple Game template +* +* Screens Functions Declarations (Init, Update, Draw, Unload) +* +* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* +* 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, TITLE, GAMEPLAY, ENDING } GameScreen; + +#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); + +//---------------------------------------------------------------------------------- +// Title Screen Functions Declaration +//---------------------------------------------------------------------------------- +void InitTitleScreen(void); +void UpdateTitleScreen(void); +void DrawTitleScreen(void); +void UnloadTitleScreen(void); + +//---------------------------------------------------------------------------------- +// Gameplay Screen Functions Declaration +//---------------------------------------------------------------------------------- +void InitGameplayScreen(void); +void UpdateGameplayScreen(void); +void DrawGameplayScreen(void); +void UnloadGameplayScreen(void); + +//---------------------------------------------------------------------------------- +// Ending Screen Functions Declaration +//---------------------------------------------------------------------------------- +void InitEndingScreen(void); +void UpdateEndingScreen(void); +void DrawEndingScreen(void); +void UnloadEndingScreen(void); + +#ifdef __cplusplus +} +#endif + +#endif // SCREENS_H \ No newline at end of file diff --git a/templates/simple_game/screens.o b/templates/simple_game/screens.o new file mode 100644 index 0000000000000000000000000000000000000000..7ed0860c0e82c16b313d03ac37b392fb81ec712f GIT binary patch literal 3124 zcma)8L1<$|82(@TwgxxGf;osS`qGWiLybi$yMka#`)H%tv?M7-x=S|OytaXul;l<0 zBDyp#Z0RmU5E0fxMFm|v3M!}+6KG{U2zv0~aX}Bgc+!Jfzken(c`x0~I`GeY^UeQ% z^Uq}FWfI0I;?ff!iV9>JG1u8}1(wwhJw(3(ntif=28~6dmty&xo0HT%>v0<0k6o@- zy$+b_M7hF#6~AB;UZ3>(U7wczAe>HaH9tZ6GXLQ?zCjJ^Gz1_TApz7QQW?0B;X?a|ntD zW;CdLYt4~Hy>a7JVyhhuV$6Vx(7C$rw$i};i^CgK@uxm>ZHvC{VBY;r0ci^V7t&m?T+LUSoQown>`#!gvo*?MvQ{2aH_ z6X)%@#KgtXTTP++0~52?40HUTlE$8-D)oAYoy2VcqzxCmPB92~d- z>o!Le<3W56(1^lwoI|JI!|@!PM;Kg$y*%s4gFgqp+Z?>-{7pwA3LrfS>!XJ>dPJkg zHA(_K2J53V>L*}f+S1&cn!5>P!NT-0YN`AcP(*P1sD}i)gPQ+K!gLy`NacPYseD#* z&ueZG$Py6_kW}6TiU{rskW~H%NGjh3lFB~X{Mx#p_xf)&5XiuZ2M!#ruq>+hr@TmyXutvOV zlH>C!(W*w*HHs}4iVkAA{CiBaVpNwZj#H|}mL%D#L#@^zi+T`!x58(IZ%c2>h@JxC ze?t+4mgoi8Fs#kYqQ`4)Gdc9+ZN^-{L=~94%Zj-Q=5ts(>Rt3^kXf7g6pXyFD(V|B z^1dqOCorxr>NhX}OxxD^2aLRxD(YcG$UCW+GhoJiQO|-o)QtC4g#qd{zQ-7!rFQYY zs4xhh_LxH6*Ob_2BcO(K>wQUy-^2J$k9k47rO%I{UW4CJ{Jrs)bjye5;+*i#(pjms z7f&!-Cz#z6%uOG23%!`Lnq98sUU4WJFBRNGd8M2dhmj;*oh+}HT&F_W`8B*19k0Vw zCHI=QKVK@Ab9pbrl9_^Abd;tP@lmYeBczOvVx4IuxmL_=`lUKqR_o-XU?H9Ns7hs+ddnwzT|AqRh(+o$y0XPX}Qceg_TtdYht00 ScULLPfhlLn&6QU0t@sa}ZvKS; literal 0 HcmV?d00001 diff --git a/templates/simple_game/simple_game.c b/templates/simple_game/simple_game.c new file mode 100644 index 000000000..b4d757198 --- /dev/null +++ b/templates/simple_game/simple_game.c @@ -0,0 +1,98 @@ +/******************************************************************************************* +* +* raylib - Simple Game template +* +* +* +* +* This game has been created using raylib (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* +* raylib - Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* +********************************************************************************************/ + +#include "raylib.h" + +#include "screens.h" + +//---------------------------------------------------------------------------------- +// Global Variables Defined in other modules +//---------------------------------------------------------------------------------- +extern GameScreen currentScreen; // Defined in screens.c + +//---------------------------------------------------------------------------------- +// Main entry point +//---------------------------------------------------------------------------------- +int main(void) +{ + // Initialization + //--------------------------------------------------------- + const int screenWidth = 800; + const int screenHeight = 450; + const char windowTitle[30] = ""; + + InitWindow(screenWidth, screenHeight, windowTitle); + + // Initialize all screens + InitLogoScreen(); + InitTitleScreen(); + InitGameplayScreen(); + InitEndingScreen(); + + // Define first screen + currentScreen = LOGO; + + SetTargetFPS(60); + //---------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + switch(currentScreen) + { + case LOGO: UpdateLogoScreen(); break; // Update LOGO currentScreen + case TITLE: UpdateTitleScreen(); break; // Update TITLE currentScreen + case GAMEPLAY: UpdateGameplayScreen(); break; // Update GAMEPLAY currentScreen + case ENDING: UpdateEndingScreen(); break; // Update END currentScreen + default: break; + } + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + switch(currentScreen) + { + case LOGO: DrawLogoScreen(); break; // Draw LOGO currentScreen + case TITLE: DrawTitleScreen(); break; // Draw TITLE currentScreen + case GAMEPLAY: DrawGameplayScreen(); break; // Draw GAMEPLAY currentScreen + case ENDING: DrawEndingScreen(); break; // Draw END currentScreen + default: break; + } + + DrawFPS(screenWidth - 100, 20); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + + // Unload all loaded data (textures, fonts, audio) + UnloadLogoScreen(); + UnloadTitleScreen(); + UnloadGameplayScreen(); + UnloadEndingScreen(); + + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} \ No newline at end of file diff --git a/templates/standard_game/makefile b/templates/standard_game/makefile new file mode 100644 index 000000000..2aacd54c1 --- /dev/null +++ b/templates/standard_game/makefile @@ -0,0 +1,118 @@ +#************************************************************************************************** +# +# raylib - Standard Game +# +# makefile to compile standard game +# +# Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +# +# 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. +# +#************************************************************************************************** + +# define raylib platform if not defined (by default, compile for RPI) +# Other possible platform: PLATFORM_DESKTOP +PLATFORM ?= PLATFORM_RPI + +# define compiler: gcc for C program, define as g++ for C++ +CC = gcc + +# define compiler flags: +# -O2 defines optimization level +# -Wall turns on most, but not all, compiler warnings +# -std=c99 use standard C from 1999 revision +CFLAGS = -O2 -Wall -std=c99 +#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes + +# define any directories containing required header files +ifeq ($(PLATFORM),PLATFORM_RPI) + INCLUDES = -I. -I./screens -I../../src -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads +else + INCLUDES = -I. -I./screens -I../../src +endif + +# define library paths containing required libs +LFLAGS = -L. -L../../src -L/opt/vc/lib + +# define any libraries to link into executable +# if you want to link libraries (libname.so or libname.a), use the -lname +ifeq ($(PLATFORM),PLATFORM_RPI) + # libraries for Raspberry Pi compiling + # NOTE: OpenAL Soft library should be installed (libopenal1 package) + LIBS = -lraylib -lGLESv2 -lEGL -lm -lbcm_host -lopenal +else + # libraries for Windows desktop compiling + # NOTE: GLFW3 and OpenAL Soft libraries should be installed + LIBS = -lraylib -lglfw3 -lglew32 -lopengl32 -lopenal32 -lgdi32 +endif + +# define additional parameters and flags for windows +ifeq ($(PLATFORM),PLATFORM_DESKTOP) + # resources file contains windows exe icon + # -Wl,--subsystem,windows hides the console window + WINFLAGS = ../../src/resources -Wl,--subsystem,windows +endif + +# define all screen object files required +SCREENS = \ + screens/screen_logo.o \ + screens/screen_title.o \ + screens/screen_options.o \ + screens/screen_gameplay.o \ + screens/screen_ending.o \ + +# typing 'make' will invoke the first target entry in the file, +# in this case, the 'default' target entry is standard_game +default: standard_game + +# compile template - standard_game +standard_game: standard_game.c $(SCREENS) + $(CC) -o $@ $< $(SCREENS) $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS) + +# compile screen LOGO +screens/screen_logo.o: screens/screen_logo.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen TITLE +screens/screen_title.o: screens/screen_title.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen OPTIONS +screens/screen_options.o: screens/screen_options.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen GAMEPLAY +screens/screen_gameplay.o: screens/screen_gameplay.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# compile screen ENDING +screens/screen_ending.o: screens/screen_ending.c + $(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM) + +# clean everything +clean: +ifeq ($(PLATFORM),PLATFORM_RPI) + rm -f screens/*.o +# find . -executable -delete +else + del screens/*.o *.exe +endif + @echo Cleaning done + +# instead of defining every module one by one, we can define a pattern +# this pattern below will automatically compile every module defined on $(OBJS) +#%.exe : %.c +# $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) diff --git a/templates/standard_game/screens/screen_ending.c b/templates/standard_game/screens/screen_ending.c new file mode 100644 index 000000000..e01cd6add --- /dev/null +++ b/templates/standard_game/screens/screen_ending.c @@ -0,0 +1,80 @@ +/********************************************************************************************** +* +* raylib - Standard Game template +* +* Ending Screen Functions Definitions (Init, Update, Draw, Unload) +* +* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* +* 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 to return to TITLE screen + if (IsKeyPressed(KEY_ENTER)) + { + finishScreen = 1; + } +} + +// Ending Screen Draw logic +void DrawEndingScreen(void) +{ + // TODO: Draw ENDING screen here! + DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), BLUE); + DrawText("ENDING SCREEN", 20, 20, 40, DARKBLUE); + DrawText("PRESS ENTER to RETURN to TITLE SCREEN", 160, 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; +} \ No newline at end of file diff --git a/templates/standard_game/screens/screen_ending.o b/templates/standard_game/screens/screen_ending.o new file mode 100644 index 0000000000000000000000000000000000000000..5d819b1618a9985a76c14bbd404a5ea8142fc9cb GIT binary patch literal 1622 zcmZ`)L2DCH5S~r8vXl@!RIIkhT65^ZZi5slqL7lTZLx&9N%5c(*W@)>NH=A7+gkBZ zh=QdE5fMBpc=Y5Su#iGL3Mzm5<4(6-}~NVX5QQPUY4X2K;k3; z#yOHD&0`Ndj)nPwPL=>ZCd4>}PKE3}t!8?rppLaU$nIEP0k0w$^?M6AsyjUsjD+u?o5i>su9aj6mGbonaOn-nKI%T(g!bWh zPtHi#!Ea)p?0dr^fO={lj8jaheK^Tyce~v63Yn9z{pV=+PA0Wm$S64GDKQb{=*JlE zj&LqDi6nYuM0lC|V`BXng}w*neNA4*dVb#a!Q^e~iS!Ls?RGkPv9MU2S4(+A*NaFk z8+xgv>cz5ds9sAo^zw>PBvf83FX{a_b;@j7b-UVHTe~t*sctw9v%ON)Va%SmcnN@d zA(0*$AU#r~v6L)7#eJb>=p0e`Q>Y{qn?)u5JSybV>fN*qD#8WS9O`pam`f||L_VEO z?4^~tE=GuaP4r(-F+CTmv4i>zRh(V``uu4=rqe0V1w^M&M_?-C<`9i?jw+wwi1MH1 z=mlEJega;h9pl`GkUI#uuZTnq711#22+V|NDMafbdK@Bc)oKPu_wNxvU2^%hR+wG0 z?7CLPND|6VBH=zIf~5;8w5pHjK#M~?jfnQG&s@V1t(fOQ4{#IpDr%phnxA6K7LLT8 zV|9qW2-Hea`i_=%x-Ze!fWAiZKRriZ0^Xsd^b`0f`U>!sNS6m=A};`4-lTMHAclxN zpQTfhlsag`tM1PLyhKEGNT_dsx7?DUwUfN(mQ28O2bj+T%&!=8h$D?PDyxpU#-Orj zTb|CpxVTjyCfs~$!}geiL(8_@MliXuj&CE2|DfQQTXAN^Znn%?oV(8R#JETsv73!u txi{GMvcp`L)u1xZ{42k}ta`(X5Vx$F*MJIjVBlM9+I2kBd|0Ocj(@7|?#loG literal 0 HcmV?d00001 diff --git a/templates/standard_game/screens/screen_gameplay.c b/templates/standard_game/screens/screen_gameplay.c new file mode 100644 index 000000000..13752d014 --- /dev/null +++ b/templates/standard_game/screens/screen_gameplay.c @@ -0,0 +1,80 @@ +/********************************************************************************************** +* +* raylib - Standard Game template +* +* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload) +* +* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* +* 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) +//---------------------------------------------------------------------------------- + +// Gameplay screen global variables +static int framesCounter; +static int finishScreen; + +//---------------------------------------------------------------------------------- +// 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 to change to ENDING screen + if (IsKeyPressed(KEY_ENTER)) + { + finishScreen = 1; + } +} + +// Gameplay Screen Draw logic +void DrawGameplayScreen(void) +{ + // TODO: Draw GAMEPLAY screen here! + DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), PURPLE); + DrawText("GAMEPLAY SCREEN", 20, 20, 40, MAROON); + DrawText("PRESS ENTER to JUMP to ENDING SCREEN", 170, 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; +} \ No newline at end of file diff --git a/templates/standard_game/screens/screen_gameplay.o b/templates/standard_game/screens/screen_gameplay.o new file mode 100644 index 0000000000000000000000000000000000000000..b31cccb3157d004b0aa66bf7e673f077dc156473 GIT binary patch literal 1632 zcmZ`)&ubG=5S~r8vXl^ds90^0ZOx$vyGE&4L@*(VX|)X@X%JC~YqCui(oNajR$BxM zQLu;*5y6{y_26G1T1X+i2p$wf6g+z9*`smhz1__wu>&*n&G#nrX5X(Y3P*s%3<69r zBnpbH-M1O$<_9`a0N4-kID}4y=pCi3+A60GwK0h9Dt9f*pCI`I2X9lJ*;{Z9$A00w ze!+S%rEF>?dqZ=18Nry-o6FI>XJ*}q`zE?M%!}c-k_@3zy*2?R?IF=Yt!Eq1IGAXQ z5dk~+P3+@cdzdFsPmR3^%E>nlrrGFDi@A0(GP1wb>FnH!gm#h<31e0g3sDU(=fmWM z4vvMUkwh@WNMl* zb^06t^+F5rn4P;L~J_(@bqgyq{|5oCn(s4>*%s1OfJ zjX)wC4Ll7?@fK$AdNuT4P-)poXpU{vZ>aqA0?_t{Sxl#sqf>~Ep^n0g$HftiF^*Dm7hunq;OTfjm7SAczqaDFhy_X5!6 z4GJd*a)@~8uyjg-LKCfb)twQ5*NA8y66zb^9kXQU+ezLtOU7kB4KP0kn1deX4@Qbs zEv}fj&rn=2bUW?rIKNlGhpa?>-LN$iL*3A=sykR%!`D&k|4GtR@AY#9qgGeT{p=N1 zt&jCJ)N{wNKkJ&dnKd=b(#lXwYtH4L*Yrx&_7T_hvR#ED^^wC@Sv4wnx>>kP|04eY Dj(qix literal 0 HcmV?d00001 diff --git a/templates/standard_game/screens/screen_logo.c b/templates/standard_game/screens/screen_logo.c new file mode 100644 index 000000000..41cb56782 --- /dev/null +++ b/templates/standard_game/screens/screen_logo.c @@ -0,0 +1,81 @@ +/********************************************************************************************** +* +* raylib - Standard Game template +* +* Logo Screen Functions Definitions (Init, Update, Draw, Unload) +* +* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* +* 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) +//---------------------------------------------------------------------------------- + +// Logo screen global variables +static int framesCounter; +static int finishScreen; + +//---------------------------------------------------------------------------------- +// Logo Screen Functions Definition +//---------------------------------------------------------------------------------- + +// Logo Screen Initialization logic +void InitLogoScreen(void) +{ + // TODO: Initialize LOGO screen variables here! + framesCounter = 0; + finishScreen = 0; +} + +// Logo Screen Update logic +void UpdateLogoScreen(void) +{ + // TODO: Update LOGO screen variables here! + + framesCounter++; // Count frames + + // Wait for 2 seconds (120 frames) before jumping to TITLE screen + if (framesCounter > 120) + { + finishScreen = true; + } +} + +// Logo Screen Draw logic +void DrawLogoScreen(void) +{ + // TODO: Draw LOGO screen here! + DrawText("LOGO SCREEN", 20, 20, 40, LIGHTGRAY); + DrawText("WAIT for 2 SECONDS...", 290, 220, 20, GRAY); +} + +// Logo Screen Unload logic +void UnloadLogoScreen(void) +{ + // TODO: Unload LOGO screen variables here! +} + +// Logo Screen should finish? +int FinishLogoScreen(void) +{ + return finishScreen; +} \ No newline at end of file diff --git a/templates/standard_game/screens/screen_logo.o b/templates/standard_game/screens/screen_logo.o new file mode 100644 index 0000000000000000000000000000000000000000..10a997460c0288faaf8b7624a0fd96bd3ab3430c GIT binary patch literal 1362 zcmZ`(-D(q25T4U)ODLiABBD~!CG)ErLI!G2Q$?vRgLWT0|ta zAc6?F@IpmIu@6#+kX-l(K0q&g0IyoVIcIlsLUmwfzWL5%=A5%hIbiZvqU@<{e#M3Nw`N!W|>;XK;>5#9VK{K+0g!2vGmsE`4L1{m%B_&)&;v zwaSh9y@TKBL4JOAI2@kBC$55ok0+Hkq&N5gbj*fx_xJZ@ZjclIrFbKSiUVUl5#}EJ zNcVfPKX0br>#Y>;7R^#_tx#B{2e+5k&6?|(i)N{iE3W2CmSrK$T&T2~b*JjK+c#6? z>W=5xj$f*Jw(X?Si$vU%MLb_4@ggqf5{B^xjc37Kf^w^KP!{GgQ0C{LEd2XC^aivH zrQA$r;?a!3xsRbApnNkd%xyzIL)Ggd;wzt#F`rYRixIjKp=%L(2*j19WWV!3NqQY| zZ-Er|5lGcDf%t7EX(>YYBD5JHKSEZm*$SW0$th7?bmWzlTW;O8s>oBq^;ra&G!Y(C zQIWkIpcp(W(E^n3b;R64#8W2gz!Tkv@@_}W6GZRF7#EScUvwvZI(aKG@dcL8JraE~ z`Q~H)*t0&Ba);vVT^o7 zi9SiohR=QoZ`qA<&8xI+Dla=te+6Gky>n7@C+F@szU?7wI?YZaT-?~kzl*J>=e^1^ cJ>GCyZe>en?#K!nqctC!F)DMhb^hP{3m3w*6951J literal 0 HcmV?d00001 diff --git a/templates/standard_game/screens/screen_options.c b/templates/standard_game/screens/screen_options.c new file mode 100644 index 000000000..bb4906722 --- /dev/null +++ b/templates/standard_game/screens/screen_options.c @@ -0,0 +1,71 @@ +/********************************************************************************************** +* +* raylib - Standard Game template +* +* Options Screen Functions Definitions (Init, Update, Draw, Unload) +* +* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* +* 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) +//---------------------------------------------------------------------------------- + +// Options screen global variables +static int framesCounter; +static int finishScreen; + +//---------------------------------------------------------------------------------- +// 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; +} \ No newline at end of file diff --git a/templates/standard_game/screens/screen_options.o b/templates/standard_game/screens/screen_options.o new file mode 100644 index 0000000000000000000000000000000000000000..17153fd9391c8116c94c9c4f84c5bd26791e5ed7 GIT binary patch literal 1047 zcmZ`&O-sW-5S{IZ6cO>DASe<=L8Qhao;*lF5d}d|1P?-u=~e@6Qj)ZadhqB)=-Hd# z#eX68;GghkcvjzJlXP2k;O)M7JDHswCVL`JY@dQ?B4RmVhVm+mxLS(XK7eP$uw?;* zN~dPk3av=_e<@Sx)jSIVJ))pHF~8%usxR%ZEt6vdq!8bkXq<0lE%DTTi)|5cZ*eTY z2yx|i^)z_z`J4)+?nAo|Pkhkrbc|)I?wq@}*J!NIRqU4UOE)~UeJS0!;wsU2{Jpq7 zAaPp|QzNUY4z>)vU^V4MrRG}=NtIpK3HMdc)u@p= u2{yf!8%iIp<2u1ba(L9lA14RC*z&E*0qMxCdscNo+>TQ9i&`yxBTqkOZH7bu literal 0 HcmV?d00001 diff --git a/templates/standard_game/screens/screen_title.c b/templates/standard_game/screens/screen_title.c new file mode 100644 index 000000000..0082fa12f --- /dev/null +++ b/templates/standard_game/screens/screen_title.c @@ -0,0 +1,81 @@ +/********************************************************************************************** +* +* raylib - Standard Game template +* +* Title Screen Functions Definitions (Init, Update, Draw, Unload) +* +* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* +* 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; +static int finishScreen; + +//---------------------------------------------------------------------------------- +// 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 to change to GAMEPLAY screen + if (IsKeyPressed(KEY_ENTER)) + { + //finishScreen = 1; // OPTIONS + finishScreen = 2; // GAMEPLAY + } +} + +// Title Screen Draw logic +void DrawTitleScreen(void) +{ + // TODO: Draw TITLE screen here! + DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), GREEN); + DrawText("TITLE SCREEN", 20, 20, 40, DARKGREEN); + DrawText("PRESS ENTER to JUMP to GAMEPLAY SCREEN", 160, 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; +} \ No newline at end of file diff --git a/templates/standard_game/screens/screen_title.o b/templates/standard_game/screens/screen_title.o new file mode 100644 index 0000000000000000000000000000000000000000..cbe172970ef8449bd74dfafff655df68dbec40f7 GIT binary patch literal 1617 zcmZ`)PiqrV5T8x9Who(es90^$wdT-6y9Oy(#6v>5w$-$T{6Rz|U6a>jA>EYSZT*9X zLR2gwM7(%YKY(9B3n|2tcu){g@F3`+pTRow-e$8)?7+#fI8-Ltd3k??JFa~PMxwUP{>Qob$$F5My7L!D<^(AuBq z$_WWO_(SZYU3WwTP_5S91jQ6u`%`>&r^8)$K5+zoB@cFPCSp7D2?fVIB_^UA{g}<^ z1DuOZA&FiY6<+54kXSE9q3=O?Uz3-yo|m_^H+6%0B7H+uJMDIHshHK(LME^4E66}D zuNMlczEafls@qgAmzHzn7t+gmE}OpYN2)VM!>n1A=KA`D$#P}WwwdJ?DmG)*V-tQp9krIB8|sn`3de6HACl!${$4~q1YrU@uyKC6IXA=Wl#|=qNY%vqe42av?7^! zGV(O8q&pZP@-@(ZM#c18sKz$xS5$F&0qB#&`It_pKxYsgLmh<~pGzYe;~Z5!&JpE5 z!O;t}lzkXpq8;bld!O6$xi5%B4HeM{>L|?mDC?sQA3gMuwq`bZNB8dmKuvP^ww7Jf zZ7{8Zfm|p*iG=$U=`CGQzCGn3I?&=!Ylvvy`piWf(TaH<^Z-{;iS0A1IQkS~=)#IU z$LbJ#5vY}@^bIZTbYFt60ey|=e|iqS1iV8@=_l||@D<=IkJm>9qyim;E;Tmf tTw(WeHggy7{b literal 0 HcmV?d00001 diff --git a/templates/standard_game/screens/screens.h b/templates/standard_game/screens/screens.h new file mode 100644 index 000000000..eb4aa8b7a --- /dev/null +++ b/templates/standard_game/screens/screens.h @@ -0,0 +1,92 @@ +/********************************************************************************************** +* +* raylib - Standard Game template +* +* Screens Functions Declarations (Init, Update, Draw, Unload) +* +* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* +* 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, TITLE, OPTIONS, GAMEPLAY, ENDING } GameScreen; + +//---------------------------------------------------------------------------------- +// Global Variables Definition +//---------------------------------------------------------------------------------- +GameScreen currentScreen; + +#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 \ No newline at end of file diff --git a/templates/standard_game/standard_game.c b/templates/standard_game/standard_game.c new file mode 100644 index 000000000..e4dafc70a --- /dev/null +++ b/templates/standard_game/standard_game.c @@ -0,0 +1,144 @@ +/******************************************************************************************* +* +* raylib - Standard Game template +* +* +* +* +* This game has been created using raylib (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* +* raylib - Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* +********************************************************************************************/ + +#include "raylib.h" +#include "screens/screens.h" // NOTE: Defines currentScreen + +//---------------------------------------------------------------------------------- +// Main entry point +//---------------------------------------------------------------------------------- +int main(void) +{ + // Initialization + //--------------------------------------------------------- + const int screenWidth = 800; + const int screenHeight = 450; + const char windowTitle[30] = ""; + + InitWindow(screenWidth, screenHeight, windowTitle); + + // TODO: Load global data here (assets that must be available in all screens, i.e. fonts) + + // Define and init first screen + currentScreen = LOGO; // NOTE: currentScreen is defined in screens.h as a global variable + InitLogoScreen(); + + SetTargetFPS(60); + //---------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + switch(currentScreen) + { + case LOGO: + { + UpdateLogoScreen(); + + if (FinishLogoScreen()) + { + UnloadLogoScreen(); + currentScreen = TITLE; + InitTitleScreen(); + } + } break; + case TITLE: + { + UpdateTitleScreen(); + + // NOTE: FinishTitleScreen() return an int defining the screen to jump to + if (FinishTitleScreen() == 1) + { + UnloadTitleScreen(); + currentScreen = OPTIONS; + InitOptionsScreen(); + } + else if (FinishTitleScreen() == 2) + { + UnloadTitleScreen(); + currentScreen = GAMEPLAY; + InitGameplayScreen(); + } + } break; + case OPTIONS: + { + UpdateOptionsScreen(); + + if (FinishOptionsScreen()) + { + UnloadOptionsScreen(); + currentScreen = TITLE; + InitTitleScreen(); + } + } break; + case GAMEPLAY: + { + UpdateGameplayScreen(); + + if (FinishGameplayScreen()) + { + UnloadGameplayScreen(); + currentScreen = ENDING; + InitEndingScreen(); + } + } break; + case ENDING: + { + UpdateEndingScreen(); + + if (FinishEndingScreen()) + { + UnloadEndingScreen(); + currentScreen = TITLE; + InitTitleScreen(); + } + } break; + default: break; + } + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + switch(currentScreen) + { + case LOGO: DrawLogoScreen(); break; + case TITLE: DrawTitleScreen(); break; + case OPTIONS: DrawOptionsScreen(); break; + case GAMEPLAY: DrawGameplayScreen(); break; + case ENDING: DrawEndingScreen(); break; + default: break; + } + + //DrawFPS(10, 10); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + + // TODO: Unload all global loaded data (i.e. fonts) here! + + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} \ No newline at end of file