-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainGameState.cpp
70 lines (59 loc) · 1.38 KB
/
MainGameState.cpp
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
#include "MainGameState.h"
#include "GameStateManager.h"
#include "GameEngine.h"
#include <iostream>
#include "SDL/SDL.h"
#include "SDL/SDL_opengl.h"
using std::cout;
using std::endl;
MainGameState MainGameState::self;
void MainGameState::init()
{
cout << "Initializing MainGameState" << endl;
glClearColor(1.,0.,0.,1.);
glClear(GL_COLOR_BUFFER_BIT);
SDL_GL_SwapBuffers();
}
void MainGameState::cleanup()
{
cout << "Cleaning up MainGameState" << endl;
}
void MainGameState::pause()
{
cout << "Pausing MainGameState" << endl;
}
void MainGameState::resume()
{
cout << "Resuming MainGameState" << endl;
glClearColor(1.,0.,0.,1.);
glClear(GL_COLOR_BUFFER_BIT);
SDL_GL_SwapBuffers();
}
bool MainGameState::execute(GameStateManager* gsm)
{
cout << "Executing MainGameState" << endl;
bool running = true;
bool status = true;
while (running)
{
SDL_Event event;
while(SDL_PollEvent(&event))
{
if (event.type == SDL_QUIT)
{
gsm->game->quit();
running = false;
status = false;
break;
}
Uint8* keys = SDL_GetKeyState(nullptr);
if (keys[SDLK_ESCAPE])
{
gsm->popState();
running = false;
break;
}
}
}
return status;
}