Multiple templates to start a game
Some basic to advance templates are provided to be use as base code for new games
This commit is contained in:
parent
815f90974c
commit
1ef1f3d7ea
35 changed files with 2432 additions and 0 deletions
98
templates/simple_game/simple_game.c
Normal file
98
templates/simple_game/simple_game.c
Normal file
|
@ -0,0 +1,98 @@
|
|||
/*******************************************************************************************
|
||||
*
|
||||
* raylib - Simple Game template
|
||||
*
|
||||
* <Game title>
|
||||
* <Game description>
|
||||
*
|
||||
* 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] = "<game name goes here>";
|
||||
|
||||
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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue