From 7c438c2a0e25d22323b5def545f32e97eee689f0 Mon Sep 17 00:00:00 2001 From: BoredGuy Date: Mon, 23 Mar 2026 17:11:28 +0300 Subject: Asset system - Multiple entity updates --- src/wall.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'src/wall.c') 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 #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); -} -- cgit v1.2.3