diff options
Diffstat (limited to 'src/wall.c')
| -rw-r--r-- | src/wall.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -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 }, |
