blob: b4d757198b6ae389b1b159c55bf94742b2546f17 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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;
}
|