From aff0792bce397b5f0ec9aa8c4ab262bc61ccc093 Mon Sep 17 00:00:00 2001 From: BoredGuy Date: Wed, 25 Mar 2026 20:34:59 +0300 Subject: Better Level Loading - Object layers coming soon! --- src/wall.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/wall.c') diff --git a/src/wall.c b/src/wall.c index b4a3653..2aa20dd 100644 --- a/src/wall.c +++ b/src/wall.c @@ -1,18 +1,27 @@ #include +#include +#include #include "wall.h" -#define BLOCK_WIDTH 128 -#define BLOCK_HEIGHT 128 - extern struct Texture wall_texture; +static inline bool tile_is_collidable(int tile) { + int non_collidable[] = {65, 122}; + + for (size_t i = 0; i < sizeof(non_collidable) / sizeof(non_collidable[0]); i++) + if (non_collidable[i] == tile) + return false; + + return true; +} + void add_wall(float xpos, float ypos, int tile) { int tile_x = tile % 18; int tile_y = tile / 18; struct entity wall = { .type = Wall_Entity, - .flags = (ENTITY_ACTIVE | ENTITY_COLLISION_ACTIVE | ENTITY_VISIBLE), + .flags = (ENTITY_ACTIVE | ENTITY_VISIBLE), .texture = wall_texture, .sprite_source_rect = (Rectangle) { @@ -42,6 +51,8 @@ void add_wall(float xpos, float ypos, int tile) { }, }; + if (tile_is_collidable(tile)) + wall.flags |= ENTITY_COLLISION_ACTIVE; add_entity(&wall); } -- cgit v1.2.3