From 937edea9599718e959f8ed135e97c68728855975 Mon Sep 17 00:00:00 2001 From: quou Date: Sat, 6 May 2023 12:22:50 +1000 Subject: Add solid environment collisions. --- solid.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 solid.c (limited to 'solid.c') diff --git a/solid.c b/solid.c new file mode 100644 index 0000000..40c3656 --- /dev/null +++ b/solid.c @@ -0,0 +1,27 @@ +#include "solid.h" + +Entity new_solid(World* world, int x, int y, int w, int h) { + Entity e; + CCollider* col; + CPosition* pos; + + e = new_entity(world); + add_components( + world, + e, + ctype_position | + ctype_collider | + ctype_solid + ); + pos = &world->positions[e]; + col = &world->colliders[e]; + + pos->x = x; + pos->y = y; + col->x = 0; + col->y = 0; + col->w = w; + col->h = h; + + return e; +} -- cgit v1.2.3-54-g00ecf