gfx and 2-2 and multi objects

This commit is contained in:
2026-02-08 20:01:32 -06:00
parent ce57691f96
commit e06ab8f76b
12 changed files with 483 additions and 8 deletions

View File

@@ -2,6 +2,7 @@
#define global_objects
#include <math.h>
#include <stdlib.h>
#define flaot float
@@ -25,6 +26,11 @@ void point_mul(Point *A, Point *B){
A->y = A->y * B->y;
}
void point_div(Point *A, Point *B){
A->x = A->x / B->x;
A->y = A->y / B->y;
}
float magnitude(flaot x, flaot y) {
return sqrt((pow(x,2) + pow(y,2)));
}
@@ -38,4 +44,23 @@ void point_set_mag(Point *point, float mag){
point->y = ry;
}
void point_limit(Point *point, float mag){
flaot getmag = magnitude(point->x, point->y);
flaot rx, ry;
if (getmag > mag){
rx = (point->x / getmag) * mag;
ry = (point->y / getmag) * mag;
} else {
rx = point->x;
ry = point->y;
}
point->x = rx;
point->y = ry;
}
float RandomFloat(float min, float max){
return ((max - min) * ((float)rand() / (double)RAND_MAX)) + min;
}
#endif