-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.h
More file actions
57 lines (42 loc) · 1.02 KB
/
Copy pathcommon.h
File metadata and controls
57 lines (42 loc) · 1.02 KB
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
#ifndef _COMMON_H_
#define _COMMON_H_
#include <SDL3/SDL.h>
#include <stdbool.h>
#include <stddef.h>
#include <math.h>
#define min(a, b) a < b ? a : b
#define max(a, b) a > b ? a : b
#define clamp(x, u, l) max(min(x, u), l)
#define rad(deg) (deg/180.0 * M_PI)
typedef struct SDL {
bool initiated;
SDL_Window *window;
SDL_Renderer *renderer;
} SDL;
typedef struct Controller {
bool forward;
bool backward;
bool left;
bool right;
bool up;
bool down;
int xrot;
int yrot;
} Controller;
typedef struct Math {
float sin[360];
float cos[360];
} Math;
typedef struct Player {
int x,y,z; /* Position */
int a; /* Angle of rotation */
int l; /* Look up down */
} Player;
void sdl_init(SDL* sdl, int sw, int sh, float scale);
void sdl_quit(SDL* sdl);
void sdl_perror(char *func);
void sdl_fatal(char *func);
void math_init(Math *math);
void controller_input(Controller *ctrl, SDL_Event *e);
void player_move(Player *player, Controller *ctrl);
#endif // _COMMON_H_