-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
91 lines (78 loc) · 1.88 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
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
#include <gbdk/platform.h>
#include <rand.h>
#include "modes/hudmode.h"
#include "modes/explorationmode.h"
#include "model/gameobject.h"
#define EXPLORATION_MODE 1
#define START_SCREEN_MODE 2
#define HUD_MODE 3
int gameState = EXPLORATION_MODE;
byte joypadCurrent=0;
struct Hud hud;
struct ExplorationMode explorationMode;
void init_game(void) {
initrand(DIV_REG);
struct GameObject* ship = gameobjects(GO_SHIP);
ship->world.x = 0;
ship->world.y = 0;
ship->vector.x = 0;
ship->vector.y = 1;
ship->isAlive = true;
struct GameObject* planet1 = gameobjects(GO_PLANET1);
planet1->world.x = -64;
planet1->world.y = -64;
}
void main(void)
{
DISPLAY_ON;
init_game();
ExplorationMode_init(&explorationMode);
int wait = 0;
// Loop forever
while(1) {
if(wait > 0)wait++;
if(wait > 50)wait = 0;
joypadCurrent=joypad();
if (joypadCurrent & J_START && wait == 0)
{
switch (gameState)
{
case EXPLORATION_MODE:
gameState = HUD_MODE;
Hud_init(&hud);
wait = 1;
break;
case HUD_MODE:
gameState = EXPLORATION_MODE;
ExplorationMode_init(&explorationMode);
wait = 1;
break;
default:
break;
}
}
switch (gameState)
{
case EXPLORATION_MODE:
ExplorationMode_update(&explorationMode);
ExplorationMode_processInput(&explorationMode, joypadCurrent);
break;
case HUD_MODE:
Hud_processInput(&hud, joypadCurrent);
Hud_drawScreen(&hud);
break;
default:
break;
}
/*if(gameState == EXPLORATION_MODE) {
ExplorationMode_update(&explorationMode);
ExplorationMode_processInput(&explorationMode, joypadCurrent);
}
else if(gameState == HUD_MODE) {
Hud_processInput(&hud, joypadCurrent);
Hud_drawScreen(&hud);
}*/
// Done processing, yield CPU and wait for start of next frame
wait_vbl_done();
}
}