render: add player sprite. welcome to dude man
This commit is contained in:
parent
eed5c3aff3
commit
5a5663afca
6 changed files with 8 additions and 5 deletions
BIN
assets/entities/player.png
Normal file
BIN
assets/entities/player.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 214 B |
BIN
assets/entities/player.png.kra
Normal file
BIN
assets/entities/player.png.kra
Normal file
Binary file not shown.
BIN
assets/entities/player_white.png
Normal file
BIN
assets/entities/player_white.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 198 B |
|
|
@ -496,6 +496,8 @@ static void game_loop(void) {
|
||||||
GameState gs;
|
GameState gs;
|
||||||
memset(&gs, 0, sizeof(GameState));
|
memset(&gs, 0, sizeof(GameState));
|
||||||
load_audio_assets(&gs);
|
load_audio_assets(&gs);
|
||||||
|
// entities
|
||||||
|
Texture2D player_tile = LoadTexture("./assets/entities/player_white.png");
|
||||||
// Initialize first floor
|
// Initialize first floor
|
||||||
rng_seed(12345);
|
rng_seed(12345);
|
||||||
init_floor(&gs, 1);
|
init_floor(&gs, 1);
|
||||||
|
|
@ -543,7 +545,7 @@ static void game_loop(void) {
|
||||||
render_map(&gs.map);
|
render_map(&gs.map);
|
||||||
render_items(gs.items, gs.item_count);
|
render_items(gs.items, gs.item_count);
|
||||||
render_enemies(gs.enemies, gs.enemy_count);
|
render_enemies(gs.enemies, gs.enemy_count);
|
||||||
render_player(&gs.player);
|
render_player(&gs.player, &player_tile);
|
||||||
EndMode2D();
|
EndMode2D();
|
||||||
|
|
||||||
// Floating texts follow world shake
|
// Floating texts follow world shake
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,10 @@ void render_map(const Map *map) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void render_player(const Player *p) {
|
void render_player(const Player *p, Texture2D *ptile) {
|
||||||
Rectangle rect = {(float)(p->x * TILE_SIZE), (float)(p->y * TILE_SIZE), (float)TILE_SIZE, (float)TILE_SIZE};
|
// Rectangle rect = {(float)(p->x * TILE_SIZE), (float)(p->y * TILE_SIZE), (float)TILE_SIZE, (float)TILE_SIZE};
|
||||||
DrawRectangleRec(rect, BLUE);
|
// DrawRectangleRec(rect, BLUE);
|
||||||
|
DrawTexture(*ptile, (float)(p->x * TILE_SIZE), (float)(p->y * TILE_SIZE), (Color){255, 255, 255, 255});
|
||||||
}
|
}
|
||||||
|
|
||||||
void render_enemies(const Enemy *enemies, int count) {
|
void render_enemies(const Enemy *enemies, int count) {
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@
|
||||||
void render_map(const Map *map);
|
void render_map(const Map *map);
|
||||||
|
|
||||||
// Render the player
|
// Render the player
|
||||||
void render_player(const Player *p);
|
void render_player(const Player *p, Texture2D *ptile);
|
||||||
|
|
||||||
// Render all enemies
|
// Render all enemies
|
||||||
void render_enemies(const Enemy *enemies, int count);
|
void render_enemies(const Enemy *enemies, int count);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue