From c9a8845b53ab13c00ed535a2075cc45765dbbfea Mon Sep 17 00:00:00 2001 From: BoredGuy Date: Mon, 23 Mar 2026 19:28:36 +0300 Subject: Level Loading!!! --- src/wall.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/wall.c') 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 }, -- cgit v1.2.3