-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.c
42 lines (36 loc) · 1.27 KB
/
main.c
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
/*Use this only if you want to enable logging to file instead of UAE console (heavy performance hit, not recommended)*/
#define GENERIC_MAIN_LOG_PATH "game.log"
#include <ace/generic/main.h>
#include <ace/managers/key.h>
#include <ace/managers/state.h>
// Without it compiler will yell about undeclared gameGsCreate etc
#include "src/game.h"
#include "src/menu.h"
#include "src/states.h"
tStateManager *g_pStateManager;
tState *g_pGameState;
tState *g_pMenuState;
void genericCreate(void) {
// Here goes your startup code
keyCreate(); // We'll use keyboard
// Initialize gamestate
timerCreate();
g_pStateManager = stateManagerCreate();
g_pGameState = stateCreate(gameGsCreate, gameGsLoop, gameGsDestroy, 0, 0, 0);
g_pMenuState = stateCreate(menuGsCreate, menuGsLoop, menuGsDestroy, 0, 0, 0);
statePush(g_pStateManager, g_pGameState);
}
void genericProcess(void) {
// Here goes code done each game frame
timerProcess();
keyProcess();
stateProcess(g_pStateManager); // Process current gamestate's loop
}
void genericDestroy(void) {
// Here goes your cleanup code
stateManagerDestroy(g_pStateManager);
stateDestroy(g_pGameState);
//stateDestroy(g_pMenuState);//might not be needed
keyDestroy(); // We don't need it anymore
logWrite("Goodbye, Amiga!\n");
}