-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.cpp
More file actions
124 lines (102 loc) · 3.07 KB
/
Game.cpp
File metadata and controls
124 lines (102 loc) · 3.07 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/***************************************************************************************
* Monkeying Around ( in 3D )
* --------------------------
* $path : E:\Program Files\Microsoft Visual Studio\MyProjects\Monkeying Around\Game.h
* $auth : Josiah T. Avery
* $date : i6/24/06
*
* -------------------------------------------------------------------------------------
* Wrapper routines for functionality just beneath main loop.
*
* 'GAME' level
****************************************************************************************/
#include "Game.h"
#include "GameDefs.h"
#include "GameLogic.h"
#include "FileSpecs.h"
#include "GUI.h"
/*
** Sets up everything required to start a game.
*/
void G_Init( pGame_t pGame )
{
pSession_t currentSession = &pGame->currentSession;
currentSession->gameMode = GM_BASIC;
currentSession->difficultyLevel = LVL_BASIC;
currentSession->activeCubes = 0;
currentSession->totalCubes = 0;
currentSession->currentLevel = 0;
currentSession->secondsToNextLevel = 0; // change this later
currentSession->currentTime = 0;
currentSession->totalPlayingTime = 0;
currentSession->activeCube = NULL;
currentSession->currentScore = 0;
currentSession->highScore = 0;
currentSession->howUrgent = URG_NORMAL;
currentSession->paused = m_false;
currentSession->inProgress = m_true;
GUI_SetRestraints( LVL_BASIC , ¤tSession->gui );
// currentSession->gameGrid = (m_boolean**)GL_AllocateGameGrid( LVL_BASIC );
GL_GenerateRandomColors();
GL_AddCube( currentSession->activeCube );
GL_GenerateCube( currentSession->activeCube );
GL_AddCube( ¤tSession->nextCube );
GL_GenerateCube( ¤tSession->nextCube );
//currentSession->activeCube = ¤tSession->nextCube;
}
/*
** Changes game difficulty. ( via menu??? )
*/
void G_ChangeDifficulty( pGame_t pGame , int difficulty )
{
pSession_t currentSession = &pGame->currentSession;
switch( difficulty )
{
case LVL_BASIC:
{
currentSession->gameMode = GM_BASIC;
currentSession->difficultyLevel = LVL_BASIC;
break;
}
case LVL_NORMAL:
{
currentSession->gameMode = GM_NORMAL;
currentSession->difficultyLevel = LVL_NORMAL;
break;
}
case LVL_ADVANCED:
{
currentSession->gameMode = GM_ADVANCE;
currentSession->difficultyLevel = LVL_ADVANCED;
break;
}
}
}
/*
** Performs all the actions required to render a single frame
*/
void G_RunCycle( pGame_t pGame )
{
pSession_t currentSession = &pGame->currentSession;
if( currentSession->activeCube->active )
{
GL_CheckFreeDirections( currentSession->activeCube , currentSession->gameGrid );
GL_UserMoveCube( currentSession->activeCube );
GL_SendCubeToGameGrid( currentSession->activeCube );
GL_ProcessGameGrid( currentSession->gameGrid );
}
else
{
GL_AddCube( ¤tSession->nextCube );
GL_GenerateCube( ¤tSession->nextCube );
}
ELM_DrawCubePoly( currentSession->activeCube );
GUI_Draw( ¤tSession->gui );
}
/*
** Shuts down current game ( prior to exit )
*/
void G_Shutdown( pGame_t pGame )
{
FS_WriteSaveFile( &pGame->saveFile );
}