forked from NotAShelf/rogged
movement: generalize; use vectors (#16)
Generalized movement, so that all entities move the same. Reviewed-on: NotAShelf/rogged#16 Reviewed-by: raf <raf@notashelf.dev> Co-authored-by: Squirrel Modeller <squirrelmodeller@protonmail.com> Co-committed-by: Squirrel Modeller <squirrelmodeller@protonmail.com>
This commit is contained in:
parent
1d738c35d4
commit
4dfe52ae72
9 changed files with 124 additions and 89 deletions
11
src/render.c
11
src/render.c
|
|
@ -30,7 +30,8 @@ void render_map(const Map *map) {
|
|||
}
|
||||
|
||||
void render_player(const Player *p) {
|
||||
Rectangle rect = {(float)(p->x * TILE_SIZE), (float)(p->y * TILE_SIZE), (float)TILE_SIZE, (float)TILE_SIZE};
|
||||
Rectangle rect = {(float)(p->position.x * TILE_SIZE), (float)(p->position.y * TILE_SIZE), (float)TILE_SIZE,
|
||||
(float)TILE_SIZE};
|
||||
DrawRectangleRec(rect, BLUE);
|
||||
}
|
||||
|
||||
|
|
@ -39,8 +40,8 @@ void render_enemies(const Enemy *enemies, int count) {
|
|||
if (!enemies[i].alive)
|
||||
continue;
|
||||
|
||||
Rectangle rect = {(float)(enemies[i].x * TILE_SIZE), (float)(enemies[i].y * TILE_SIZE), (float)TILE_SIZE,
|
||||
(float)TILE_SIZE};
|
||||
Rectangle rect = {(float)(enemies[i].position.x * TILE_SIZE), (float)(enemies[i].position.y * TILE_SIZE),
|
||||
(float)TILE_SIZE, (float)TILE_SIZE};
|
||||
|
||||
// Different colors based on enemy type
|
||||
Color enemy_color;
|
||||
|
|
@ -72,8 +73,8 @@ void render_enemies(const Enemy *enemies, int count) {
|
|||
bar_color = (Color){200, 180, 40, 255}; // yellow
|
||||
else
|
||||
bar_color = (Color){200, 60, 60, 255}; // red
|
||||
Rectangle hp_bar = {(float)(enemies[i].x * TILE_SIZE), (float)(enemies[i].y * TILE_SIZE - 4), (float)hp_pixels,
|
||||
3};
|
||||
Rectangle hp_bar = {(float)(enemies[i].position.x * TILE_SIZE), (float)(enemies[i].position.y * TILE_SIZE - 4),
|
||||
(float)hp_pixels, 3};
|
||||
DrawRectangleRec(hp_bar, bar_color);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue