added shape_new_square to construct a square collision shape

This commit is contained in:
Sara 2023-10-08 23:09:17 +02:00
parent d3d5382eb5
commit 25e4fa652c
2 changed files with 10 additions and 0 deletions

View file

@ -83,6 +83,15 @@ Shape* shape_new(const Vector* points, size_t points_len) {
return self;
}
Shape* shape_new_square(Vector size) {
return shape_new((Vector[4]){
ZeroVector,
(Vector){0.f, size.y},
size,
(Vector){size.x, 0.f}
}, 4);
}
Shape* shape_clone(const Shape* source) {
Shape* self = malloc(sizeof(Shape));
ASSERT_RETURN(self != NULL, NULL, "Failed to allocate space for shape object.");

View file

@ -7,6 +7,7 @@
typedef struct Shape Shape;
extern Shape* shape_new(const Vector* points, size_t points_len);
extern Shape* shape_new_square(Vector size);
extern Shape* shape_clone(const Shape* source);
extern void shape_destroy(Shape* self);