summaryrefslogtreecommitdiff
path: root/src/entity.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/entity.h')
-rw-r--r--src/entity.h44
1 files changed, 32 insertions, 12 deletions
diff --git a/src/entity.h b/src/entity.h
index f9c6a74..479f4e0 100644
--- a/src/entity.h
+++ b/src/entity.h
@@ -1,30 +1,50 @@
#ifndef ENTITY_H
#define ENTITY_H
+#include <stdbool.h>
#include <stdint.h>
#ifndef M_PI
#define M_PI 3.141592f
#endif
+struct Vec2d
+{
+ union
+ {
+ struct
+ {
+ float x;
+ float y;
+ };
+ struct
+ {
+ float w;
+ float h;
+ };
+ float xy[2];
+ float d[2];
+ };
+};
+
struct Entity
{
- float angle;
- float speed;
float mass;
float size;
- float x;
- float y;
+ struct Vec2d position;
+ struct Vec2d velocity;
uint32_t color;
};
-struct Vec2d
-{
- float angle;
- float length;
-};
-
-struct Vec2d vec2d_add(float angle1, float length1, float angle2, float length2);
-void entity_accelerate(struct Entity *e, float angle, float acceleration);
+void entity_accelerate(struct Entity *e, struct Vec2d *v);
+struct Vec2d vec2d_add(float x0, float y0, float x1, float y1);
+struct Vec2d vec2d_al_to_xy(struct Vec2d v);
+float vec2d_get_angle(float x, float y);
+bool vec2d_equal(struct Vec2d v0, struct Vec2d v1);
+float vec2d_get_length(float x, float y);
+struct Vec2d vec2d_negate(struct Vec2d v);
+struct Vec2d vec2d_normalize(float x, float y);
+struct Vec2d vec2d_scale(float x, float y, float s);
+struct Vec2d vec2d_xy_to_al(struct Vec2d v);
#endif