]> git.lizzy.rs Git - nothing.git/blobdiff - src/math/rect.h
Merge pull request #924 from RIscRIpt/manual_sdl2
[nothing.git] / src / math / rect.h
index 5b1181030ed922dc7556a2a11ed580a8e2a83d39..9b045b5cc5d5bcafd43cb19f1cd1abcebb8f6010 100644 (file)
@@ -1,48 +1,54 @@
 #ifndef RECT_H_
 #define RECT_H_
 
-#include <SDL2/SDL.h>
+#include <SDL.h>
 
 #include "math/point.h"
 
-typedef enum rect_side_t {
+typedef enum Rect_side {
     RECT_SIDE_LEFT = 0,
     RECT_SIDE_RIGHT,
     RECT_SIDE_TOP,
     RECT_SIDE_BOTTOM,
 
     RECT_SIDE_N
-} rect_side_t;
+} Rect_side;
 
-typedef struct rect_t {
+typedef struct Rect {
     float x, y, w, h;
-} rect_t;
+} Rect;
 
-typedef struct line_t {
-    point_t p1;
-    point_t p2;
-} line_t;
+typedef struct Line {
+    Point p1;
+    Point p2;
+} Line;
 
-rect_t rect(float x, float y, float w, float h);
-rect_t rect_from_vecs(point_t position, vec_t size);
-rect_t rect_from_sdl(const SDL_Rect *rect);
+Rect rect(float x, float y, float w, float h);
+Rect rect_from_vecs(Point position, Vec size);
+Rect rect_from_points(Point p1, Point p2);
+Rect rect_from_sdl(const SDL_Rect *rect);
 
-rect_t rects_overlap_area(rect_t rect1, rect_t rect2);
+Rect rects_overlap_area(Rect rect1, Rect rect2);
 
-int rect_contains_point(rect_t rect, point_t p);
+int rect_contains_point(Rect rect, Point p);
 
-int rects_overlap(rect_t rect1, rect_t rect2);
+int rects_overlap(Rect rect1, Rect rect2);
 
-void rect_object_impact(rect_t object,
-                        rect_t obstacle,
+void rect_object_impact(Rect object,
+                        Rect obstacle,
                         int *sides);
 
-line_t rect_side(rect_t rect, rect_side_t side);
+Line rect_side(Rect rect, Rect_side side);
 
-rect_t rect_from_point(point_t p, float w, float h);
+Rect rect_from_point(Point p, float w, float h);
 
-float line_length(line_t line);
+float line_length(Line line);
 
-SDL_Rect rect_for_sdl(rect_t rect);
+SDL_Rect rect_for_sdl(Rect rect);
+
+Vec rect_center(Rect rect);
+
+Vec rect_snap(Rect pivot, Rect *rect);
+Vec rect_impulse(Rect *r1, Rect *r2);
 
 #endif  // RECT_H_