-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
54 lines (49 loc) · 1.23 KB
/
main.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
#include <iostream>
#include "src/Game.h"
Game* game = nullptr;
int main(int argc, char* args[]){
Uint32 frameStart;
int frameTime;
game = new Game();
while(1)
{
switch(game->session)
{
case INIT:
game->init(GAME_TITLE, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, SCREEN_HEIGHT);
break;
case LOAD_RESOURCES:
game->loadResources();
break;
case LOAD_MIX:
game->loadMix();
break;
case LOAD_DATA:
game->loadData();
break;
case LOGIN:
game->loginProcess();
break;
case REGISTER:
game->registProcess();
break;
case RUNNING:
frameStart = SDL_GetTicks();
game->handleEvents();
game->update();
game->render();
frameTime = SDL_GetTicks() - frameStart;
if(frameDelay > frameTime){
SDL_Delay(frameDelay - frameTime);
}
break;
case SAVE_DATA:
game->saveData();
break;
case CLEAR:
game->clean();
return 1;
}
}
return 1;
}