summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohnny Richard <johnnyricha@gmail.com>2021-04-13 02:23:22 +0200
committerJohnny Richard <johnnyricha@gmail.com>2021-04-13 02:28:33 +0200
commit43c0fb1fba4b467fad4260b87cd8149692d44910 (patch)
treec6bcd8df266a02aa5276aef7cfc2257a27286231 /src
parentbde2f21d97460bb90a71acc0fc6e0d4dfa070fc4 (diff)
Add controller to its own header file
Diffstat (limited to 'src')
-rw-r--r--src/controller.h21
-rw-r--r--src/main.c11
2 files changed, 24 insertions, 8 deletions
diff --git a/src/controller.h b/src/controller.h
new file mode 100644
index 0000000..bf22335
--- /dev/null
+++ b/src/controller.h
@@ -0,0 +1,21 @@
+#ifndef CONTROLLER_H
+#define CONTROLLER_H
+
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct controller_t {
+ bool up;
+ bool down;
+ bool left;
+ bool right;
+} controller_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CONTROLLER_H */
diff --git a/src/main.c b/src/main.c
index 022a888..4f685b2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -3,16 +3,11 @@
#include <stdbool.h>
#include <SDL.h>
+#include "controller.h"
+
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
-typedef struct Controller {
- bool up;
- bool down;
- bool left;
- bool right;
-} Controller;
-
int
main (int argc,
char *args[])
@@ -41,7 +36,7 @@ main (int argc,
SDL_Rect rect = { .x = 0, .y = 0, .w = 20, .h = 20 };
bool quit = false;
- Controller controller = {0};
+ controller_t controller = {0};
while (!quit) {
screenSurface = SDL_GetWindowSurface(window);