summaryrefslogtreecommitdiff
path: root/src/wall.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/wall.c')
-rw-r--r--src/wall.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/wall.c b/src/wall.c
index 6ee3a2a..5a17f21 100644
--- a/src/wall.c
+++ b/src/wall.c
@@ -1,11 +1,30 @@
#include <raylib.h>
#include "wall.h"
-void add_wall(float xpos, float ypos, float width, float height) {
+#define BLOCK_WIDTH 128
+#define BLOCK_HEIGHT 128
+
+extern struct Texture wall_texture;
+
+void add_wall(float xpos, float ypos) {
struct entity wall = {
.type = Wall_Entity,
.flags = (ENTITY_ACTIVE | ENTITY_COLLISION_ACTIVE | ENTITY_VISIBLE),
+ .texture = wall_texture,
+ .sprite_source_rect = (Rectangle) {
+ .x = 0,
+ .y = 0,
+ .width = 128,
+ .height = 128
+ },
+ .sprite_dest_rect = (Rectangle) {
+ .x = xpos - BLOCK_WIDTH / 2,
+ .y = ypos - BLOCK_HEIGHT / 2,
+ .width = BLOCK_WIDTH,
+ .height = BLOCK_HEIGHT
+ },
+
.position = {
.x = xpos,
.y = ypos
@@ -13,17 +32,13 @@ void add_wall(float xpos, float ypos, float width, float height) {
.velocity = (Vector2) {0},
.collider = (Rectangle) {
- .x = xpos - width / 2,
- .y = ypos - height / 2,
- .width = width,
- .height = height
+ .x = xpos - BLOCK_WIDTH / 2,
+ .y = ypos - BLOCK_HEIGHT / 2,
+ .width = BLOCK_WIDTH,
+ .height = BLOCK_HEIGHT
},
};
add_entity(&wall);
}
-
-void draw_wall(const struct entity* wall) {
- DrawRectangleRec(get_entity_collider_world(wall), RED);
-}