-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathcore.h
149 lines (122 loc) · 4.36 KB
/
core.h
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#ifndef GAMEJAM2024_CORE_H
#define GAMEJAM2024_CORE_H
#include <libdragon.h>
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************
Public Core Constants
***************************************************************/
// Use this to standardize player colors
#define PLAYERCOLOR_1 RGBA32(255, 0, 0, 255)
#define PLAYERCOLOR_2 RGBA32(0, 255, 0, 255)
#define PLAYERCOLOR_3 RGBA32(0, 0, 255, 255)
#define PLAYERCOLOR_4 RGBA32(255, 255, 0, 255)
// Player number definition
typedef enum {
PLAYER_1 = 0,
PLAYER_2 = 1,
PLAYER_3 = 2,
PLAYER_4 = 3,
} PlyNum;
// AI difficulty definition
typedef enum {
DIFF_EASY = 0,
DIFF_MEDIUM = 1,
DIFF_HARD = 2,
} AiDiff;
/***************************************************************
Public Core Functions
***************************************************************/
/*==============================
core_get_playercount
Get the number of human players
@return The number of players
==============================*/
uint32_t core_get_playercount();
/*==============================
core_get_playercontroller
Get the controller port of this player.
Because player 1's controller might not be plugged
into port number 1.
@param The player we want
@return The controller port
==============================*/
joypad_port_t core_get_playercontroller(PlyNum ply);
/*==============================
core_get_aidifficulty
Gets the current AI difficulty
@return The AI difficulty
==============================*/
AiDiff core_get_aidifficulty();
/*==============================
core_get_subtick
Gets the current subtick. Use this to help smooth
movements in your draw loop.
@return The current subtick, as a
percentage (0.0f to 1.0f)
==============================*/
double core_get_subtick();
/*==============================
core_get_winner
Returns whether a player has won the last minigame.
@param The player to query
@return True if the player has won, false otherwise.
==============================*/
bool core_get_winner(PlyNum ply);
/*==============================
core_set_winner
Set the winner of the minigame. You can call this
multiple times to set multiple winners.
@param The winning player
==============================*/
void core_set_winner(PlyNum ply);
/***************************************************************
Internal Core Functions
Do not use anything below this line
***************************************************************/
#define TICKRATE 30
#define DELTATIME (1.0f/(double)TICKRATE)
#define MAXPLAYERS 4
#define LEVELCOUNT 8
typedef enum {
LEVEL_LOADSAVE,
LEVEL_MAINMENU,
LEVEL_GAMESETUP,
LEVEL_MINIGAMESELECT,
LEVEL_MINIGAME,
LEVEL_RESULTS,
} LevelDef;
typedef enum {
NR_LEAST = 0,
NR_ROBIN = 1,
NR_RANDOMPLY = 2,
NR_RANDOMGAME = 3,
NR_FREEPLAY = 4,
} NextRound;
typedef struct {
void (*funcPointer_init)(void);
void (*funcPointer_loop)(float deltatime);
void (*funcPointer_fixedloop)(float deltatime);
void (*funcPointer_cleanup)(void);
} Level;
extern void core_initlevels();
extern void core_level_changeto(LevelDef level);
extern void core_level_doinit();
extern void core_level_doloop(float deltatime);
extern void core_level_dofixedloop(float deltatime);
extern void core_level_docleanup();
extern bool core_level_waschanged();
extern void core_set_playercount(bool* enabledconts);
extern void core_get_playerconts(bool* enabledconts);
extern void core_set_aidifficulty(AiDiff difficulty);
extern void core_set_subtick(double subtick);
extern void core_reset_winners();
extern void core_set_nextround(NextRound type);
extern NextRound core_get_nextround();
extern void core_set_curchooser(PlyNum ply);
extern PlyNum core_get_curchooser();
#ifdef __cplusplus
}
#endif
#endif