]> git.lizzy.rs Git - nothing.git/blob - src/rect.h
(#110) Implement player_checkpoint
[nothing.git] / src / rect.h
1 #ifndef RECT_H_
2 #define RECT_H_
3
4 #include <SDL2/SDL.h>
5 #include "./point.h"
6
7 typedef enum rect_side_t {
8     RECT_SIDE_LEFT = 0,
9     RECT_SIDE_RIGHT,
10     RECT_SIDE_TOP,
11     RECT_SIDE_BOTTOM,
12
13     RECT_SIDE_N
14 } rect_side_t;
15
16 typedef struct rect_t {
17     float x, y, w, h;
18 } rect_t;
19
20 typedef struct line_t {
21     point_t p1;
22     point_t p2;
23 } line_t;
24
25 rect_t rect(float x, float y, float w, float h);
26 rect_t rect_from_vecs(point_t position, vec_t size);
27 rect_t rect_from_sdl(const SDL_Rect *rect);
28
29 rect_t rects_overlap_area(rect_t rect1, rect_t rect2);
30
31 int rect_contains_point(rect_t rect, point_t p);
32
33 int rects_overlap(rect_t rect1, rect_t rect2);
34
35 void rect_object_impact(const rect_t *object,
36                         const rect_t *obstacle,
37                         int *sides);
38
39 line_t rect_side(rect_t rect, rect_side_t side);
40
41 rect_t rect_from_point(point_t p, float w, float h);
42
43 float line_length(line_t line);
44
45 SDL_Rect rect_for_sdl(rect_t rect);
46
47 #endif  // RECT_H_