-
Notifications
You must be signed in to change notification settings - Fork 0
/
breakout_platform.h
66 lines (52 loc) · 1.74 KB
/
breakout_platform.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
// NOTE: Common definitions and typedefs - may be freely used by platform layer
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef unsigned long long int u64;
typedef signed char i8;
typedef signed short i16;
typedef signed int i32;
typedef signed long long int i64;
typedef float f32;
typedef double f64;
typedef unsigned int b32;
#define function static
#define global static
#define persistent static
#define Assert(x) if(!(x)) { *(int*)(0) = 0; }
#define StaticAssert(x) typedef char static_assert_##__LINE__[(x)?1:-1]
#define ArrayLength(x) (sizeof(x)/sizeof(x[0]))
#define Min(x, y) ((x) <= (y) ? (x) : (y))
#define Max(x, y) ((x) >= (y) ? (x) : (y))
// NOTE: Game structs and declarations - platform must use and call following API
typedef struct
{
u8 Buffer[10 * 1024];
} game_memory;
typedef struct
{
i32 Width;
i32 Height;
i32 Pitch;
u8* At;
} game_screen;
enum
{
GAME_KEYS_RETURN_Pos,
GAME_KEYS_SPACE_Pos,
GAME_KEYS_LEFT_Pos,
GAME_KEYS_RIGHT_Pos,
GAME_KEYS_UP_Pos,
GAME_KEYS_DOWN_Pos,
GAME_KEYS_ESCAPE_Pos,
};
#define GAME_KEYS_RETURN_Msk (1 << GAME_KEYS_RETURN_Pos)
#define GAME_KEYS_SPACE_Msk (1 << GAME_KEYS_SPACE_Pos)
#define GAME_KEYS_LEFT_Msk (1 << GAME_KEYS_LEFT_Pos)
#define GAME_KEYS_RIGHT_Msk (1 << GAME_KEYS_RIGHT_Pos)
#define GAME_KEYS_UP_Msk (1 << GAME_KEYS_UP_Pos)
#define GAME_KEYS_DOWN_Msk (1 << GAME_KEYS_DOWN_Pos)
#define GAME_KEYS_ESCAPE_Msk (1 << GAME_KEYS_ESCAPE_Pos)
function void GameInit(game_memory* Memory, i32 Width, i32 Height);
function void GameResolutionChanged(game_memory* Memory, i32 PrevWidth, i32 PrevHeight, i32 Width, i32 Height);
function void GameUpdate(game_memory* Memory, game_screen* Screen, unsigned Keys, int SecondsSinceStart);