summaryrefslogtreecommitdiff
path: root/src/wall.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/wall.c')
-rw-r--r--src/wall.c19
1 files changed, 15 insertions, 4 deletions
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 <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);
}