From 7f856467a086ec9a3ebd1ccdf12e578dffb9c98b Mon Sep 17 00:00:00 2001 From: Simponic Date: Sat, 8 Aug 2020 18:16:34 -0600 Subject: Player added --- include/velocity.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 include/velocity.h (limited to 'include/velocity.h') diff --git a/include/velocity.h b/include/velocity.h new file mode 100644 index 0000000..278226c --- /dev/null +++ b/include/velocity.h @@ -0,0 +1,35 @@ +#include "types.h" +#include "fixed.h" +#include "point.h" + +#ifndef VELOCITY_H +#define VELOCITY_H + +typedef struct VELOCITY { + FIXED dx; + FIXED dy; +} ALIGN(4) VELOCITY; + +static inline VELOCITY createVelocity (FIXED dx, FIXED dy) { + // Create velocity from data + VELOCITY temp; + temp.dx = dx; + temp.dy = dy; + return temp; +} + +static inline VELOCITY addVelocities (VELOCITY *a, VELOCITY *b) { + // Add two velocities + VELOCITY temp; + temp.dx = a->dx + b->dx; + temp.dy = a->dy + b->dy; + return temp; +} + +static inline void updatePoint (POINT *pt, VELOCITY *vel) { + // Update a point with a velocity + pt->x += vel->dx; + pt->y += vel->dy; +} + +#endif // VELOCITY_H -- cgit v1.2.3-70-g09d2