forked from NotAShelf/rogged
render: add player sprite. welcome to dude man
This commit is contained in:
parent
4dfe52ae72
commit
0b3608b18c
6 changed files with 10 additions and 6 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 |
|
|
@ -505,6 +505,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);
|
||||||
|
|
@ -552,7 +554,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
|
||||||
|
|
|
||||||
10
src/render.c
10
src/render.c
|
|
@ -29,10 +29,12 @@ void render_map(const Map *map) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void render_player(const Player *p) {
|
void render_player(const Player *p, Texture2D *ptile) {
|
||||||
Rectangle rect = {(float)(p->position.x * TILE_SIZE), (float)(p->position.y * 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};
|
// (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