diff options
| author | BoredGuy <osome3717@gmail.com> | 2026-03-23 17:11:28 +0300 |
|---|---|---|
| committer | BoredGuy <osome3717@gmail.com> | 2026-03-23 17:11:28 +0300 |
| commit | 7c438c2a0e25d22323b5def545f32e97eee689f0 (patch) | |
| tree | a9e2cf29a967c88d022ea8e6c20a522a9c482610 /src/wall.c | |
| parent | 6dbd16cd920b51bc24b60d0561bd707ff8862cc5 (diff) | |
Asset system
- Multiple entity updates
Diffstat (limited to 'src/wall.c')
| -rw-r--r-- | src/wall.c | 33 |
1 files changed, 24 insertions, 9 deletions
@@ -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); -} |
