summaryrefslogtreecommitdiff
path: root/pong.h
diff options
context:
space:
mode:
authorJacob McDonnell <jacob@jacobmcdonnell.com>2024-02-19 14:00:11 -0500
committerJacob McDonnell <jacob@jacobmcdonnell.com>2024-02-19 14:00:11 -0500
commit9d4fbd735e60c8bfd8360a9cdcfc1c757a6cced1 (patch)
tree3b7aa9cc4741aa50ddf1ac4f77f07cca3d12ffdf /pong.h
Initial Commit
Diffstat (limited to 'pong.h')
-rw-r--r--pong.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/pong.h b/pong.h
new file mode 100644
index 0000000..8520db3
--- /dev/null
+++ b/pong.h
@@ -0,0 +1,30 @@
+#ifndef PONG_H
+#define PONG_H
+
+#include <stdint.h>
+
+typedef struct point_t {
+ int32_t x;
+ int32_t y;
+} point_t;
+
+/* paddles have a fixed x position and velocity */
+struct moveable_t {
+ point_t position;
+ point_t velocity;
+ uint8_t width;
+ uint8_t height;
+};
+
+typedef struct moveable_t ball_t;
+typedef struct moveable_t paddle_t;
+
+void UpdatePosition ( point_t * const position, const point_t velocity );
+bool CheckMoveableCollision ( const struct moveable_t m1, const struct moveable_t m2 );
+bool CheckLeftWallCollision ( const struct moveable_t m );
+bool CheckRightWallCollision ( const struct moveable_t m );
+bool CheckGroundCollision ( const struct moveable_t m );
+bool CheckCeilingCollision ( const struct moveable_t m );
+void Reset ( ball_t * const ball );
+
+#endif //PONG_H