Archeus 0.0.0
A C library and game engine that focuses on documentation
Loading...
Searching...
No Matches
rectangle.h
Go to the documentation of this file.
1#ifndef ARC_MATH_RECT_H_
2#define ARC_MATH_RECT_H_
3
4#include <stdint.h>
5#include "point.h"
6#include "vector2.h"
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12typedef struct ARC_Rect {
13 int32_t x;
14 int32_t y;
15 int32_t w;
16 int32_t h;
18
19typedef struct ARC_URect {
20 uint32_t x;
21 uint32_t y;
22 uint32_t w;
23 uint32_t h;
25
26typedef struct ARC_FRect {
27 float x;
28 float y;
29 float w;
30 float h;
32
33/**
34 * @brief centers rect on given bounds
35 *
36 * @param rect ARC_Rect to be centered
37 * @param bounds ARC_Rect area to center rect on
38 */
39void ARC_Rect_CenterOn(ARC_Rect *rect, ARC_Rect *bounds);
40
41/**
42 * @brief centers rect on given bounds
43 *
44 * @param rect ARC_FRect to be centered
45 * @param bounds ARC_FRect area to center rect on
46 */
48
49/**
50 * @brief casts Rect to FRect
51 *
52 * @param rect ARC_Rect to be casted
53 *
54 * @return ARC_FRect
55 */
57
58/**
59 * @brief casts FRect to Rect
60 *
61 * @param rect ARC_FRect to be casted
62 *
63 * @return ARC_Rect
64 */
66
67/**
68 * @brief checks if two ARC_Rects intersect
69 *
70 * @param rect1 ARC_Rect that will be checked against rect2
71 * @param rect2 ARC_Rect that will be checked against rect1
72 *
73 * @return 1 if they intersect, 0 if they don't intersect
74 */
75int32_t ARC_Rect_Intersects(ARC_Rect *rect1, ARC_Rect *rect2);
76
77/**
78 * @brief checks if two ARC_FRects intersect
79 *
80 * @param rect1 ARC_FRect that will be checked against rect2
81 * @param rect2 ARC_FRect that will be checked against rect1
82 *
83 * @return 1 if they intersect, 0 if they don't intersect
84 */
86
87/**
88 * @brief checks if ARC_Rect intersects with point
89 *
90 * @param rect ARC_Rect that will be checked against point
91 * @param point ARC_Point that will be checked against rect
92 *
93 * @return 1 if they intersect, 0 if they don't intersect
94 */
96
97/**
98 * @brief checks if ARC_FRect intersects with point
99 *
100 * @param rect ARC_FRect that will be checked against point
101 * @param point ARC_Point that will be checked against rect
102 *
103 * @return 1 if they intersect, 0 if they don't intersect
104 */
106
107/**
108 * @brief checks if ARC_Rect intersects a line
109 *
110 * @note need to update this documenation to word it better
111 *
112 * @param rect ARC_Rect that will be checked against line
113 * @param x1 first point's x value
114 * @param y1 first point's y value
115 * @param y2 second point's x value
116 * @param y2 second point's y value
117 *
118 * @return 1 if they intersect, 0 if they don't intersect
119 */
120int32_t ARC_Rect_LineIntersects(ARC_Rect *rect, int32_t *x1, int32_t *y1, int32_t *x2, int32_t *y2);
121
122/**
123 * @brief checks for a ARC_Rect on ARC_Rect collision and slides on collision
124 *
125 * @note need to update this documenation to word it better
126 *
127 * @param rect ARC_Rect that might collide with the wall
128 * @param velocity the ammount ARC_Rect will move
129 * @param wall ARC_Rect that might have collision with rect
130 *
131 * @note velocity is updated based on colliding,
132 * rect's values are not changed,
133 * velocity should be applied after
134 */
136
137#ifdef __cplusplus
138}
139#endif
140
141#endif // ARC_MATH_POINT_H_
int32_t ARC_Rect_Intersects(ARC_Rect *rect1, ARC_Rect *rect2)
checks if two ARC_Rects intersect
ARC_Rect ARC_FRect_CastToRect(ARC_FRect *rect)
casts FRect to Rect
struct ARC_URect ARC_URect
void ARC_FRect_CollideAndSlide(ARC_FRect *rect, ARC_Vector2 *velocity, ARC_FRect *wall)
checks for a ARC_Rect on ARC_Rect collision and slides on collision
ARC_FRect ARC_Rect_CastToFRect(ARC_Rect *rect)
casts Rect to FRect
void ARC_Rect_CenterOn(ARC_Rect *rect, ARC_Rect *bounds)
centers rect on given bounds
int32_t ARC_FRect_IntersectsPoint(ARC_FRect *rect, ARC_Point *point)
checks if ARC_FRect intersects with point
int32_t ARC_FRect_Intersects(ARC_FRect *rect1, ARC_FRect *rect2)
checks if two ARC_FRects intersect
int32_t ARC_Rect_IntersectsPoint(ARC_Rect *rect, ARC_Point *point)
checks if ARC_Rect intersects with point
struct ARC_FRect ARC_FRect
struct ARC_Rect ARC_Rect
void ARC_FRect_CenterOn(ARC_FRect *rect, ARC_FRect *bounds)
centers rect on given bounds
int32_t ARC_Rect_LineIntersects(ARC_Rect *rect, int32_t *x1, int32_t *y1, int32_t *x2, int32_t *y2)
checks if ARC_Rect intersects a line
float y
Definition rectangle.h:28
float x
Definition rectangle.h:27
float w
Definition rectangle.h:29
float h
Definition rectangle.h:30
int32_t x
Definition rectangle.h:13
int32_t w
Definition rectangle.h:15
int32_t y
Definition rectangle.h:14
int32_t h
Definition rectangle.h:16
uint32_t x
Definition rectangle.h:20
uint32_t w
Definition rectangle.h:22
uint32_t h
Definition rectangle.h:23
uint32_t y
Definition rectangle.h:21