summaryrefslogtreecommitdiff
path: root/src/wall.c
diff options
context:
space:
mode:
authorBoredGuy <osome3717@gmail.com>2026-03-23 19:28:36 +0300
committerBoredGuy <osome3717@gmail.com>2026-03-23 19:28:36 +0300
commitc9a8845b53ab13c00ed535a2075cc45765dbbfea (patch)
tree3f28626d6be0945efed8d6d18ba4bc09409aaeb1 /src/wall.c
parente446e70fea6ef68c0807c9d6793402f1cd2d3929 (diff)
Level Loading!!!
Diffstat (limited to 'src/wall.c')
-rw-r--r--src/wall.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/wall.c b/src/wall.c
index 5a17f21..b4a3653 100644
--- a/src/wall.c
+++ b/src/wall.c
@@ -6,21 +6,24 @@
extern struct Texture wall_texture;
-void add_wall(float xpos, float ypos) {
+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),
.texture = wall_texture,
.sprite_source_rect = (Rectangle) {
- .x = 0,
- .y = 0,
+ .x = tile_x * 129,
+ .y = tile_y * 129,
.width = 128,
.height = 128
},
.sprite_dest_rect = (Rectangle) {
- .x = xpos - BLOCK_WIDTH / 2,
- .y = ypos - BLOCK_HEIGHT / 2,
+ .x = -BLOCK_WIDTH / 2,
+ .y = -BLOCK_HEIGHT / 2,
.width = BLOCK_WIDTH,
.height = BLOCK_HEIGHT
},
@@ -32,8 +35,8 @@ void add_wall(float xpos, float ypos) {
.velocity = (Vector2) {0},
.collider = (Rectangle) {
- .x = xpos - BLOCK_WIDTH / 2,
- .y = ypos - BLOCK_HEIGHT / 2,
+ .x = -BLOCK_WIDTH / 2,
+ .y = -BLOCK_HEIGHT / 2,
.width = BLOCK_WIDTH,
.height = BLOCK_HEIGHT
},