diff options
Diffstat (limited to 'physics.c')
| -rw-r--r-- | physics.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -2,6 +2,7 @@ #include <stdbool.h> #include <stddef.h> +#include <vecmath.h> #include "dat.h" static void mink(Body *a, Body *b, float *minx, float *miny, float *maxx, float *maxy); @@ -43,8 +44,7 @@ entphysics(float delta) if(!e->active) continue; - for(int j = 0; j < 2; j++) - e->body.pos[j] += e->body.vel[j] * delta; + vec2_add_scaled(e->body.pos, e->body.pos, e->body.vel, delta); } } @@ -157,8 +157,7 @@ mapcollision(Body *a) float p[2]; resolvecoll(a, &b, p); - for(int i = 0; i < 2; i++) - a->pos[i] -= p[i]; + vec2_sub(a->pos, a->pos, p); if(p[0] != 0.0) { a->vel[0] = 0; |
