PCBrawl/src/tools.c

20 lines
423 B
C

#include "tools.h"
#include "lzy.h"
#include <math.h>
#include <stdlib.h>
void log_int(int x) {
char buf[64];
sprintf(buf, "%d", x);
LZY_Log(buf);
}
int sign(int x) { return (x > 0) - (x < 0); /* from jtmm2 */ }
int length(struct Vec2 *a, struct Vec2 *b) {
const int dist_x = abs(a->x - b->x);
const int dist_y = abs(a->y - b->y);
const float dist = sqrt(dist_x * dist_x + dist_y * dist_y);
return dist;
}