diff options
| author | BoredGuy <osome3717@gmail.com> | 2026-03-25 20:34:59 +0300 |
|---|---|---|
| committer | BoredGuy <osome3717@gmail.com> | 2026-03-25 20:34:59 +0300 |
| commit | aff0792bce397b5f0ec9aa8c4ab262bc61ccc093 (patch) | |
| tree | 3ae41aa198d13b8638b8abbf0fcc643a8a149b2d /src/wall.c | |
| parent | c9a8845b53ab13c00ed535a2075cc45765dbbfea (diff) | |
Better Level Loading
- Object layers coming soon!
Diffstat (limited to 'src/wall.c')
| -rw-r--r-- | src/wall.c | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -1,18 +1,27 @@ #include <raylib.h> +#include <stdbool.h> +#include <stdlib.h> #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); } |
