added shape_new_square to construct a square collision shape
This commit is contained in:
parent
d3d5382eb5
commit
25e4fa652c
|
@ -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.");
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue