31 lines
861 B
C
31 lines
861 B
C
#include <gint/display.h>
|
|
#include <gint/gray.h>
|
|
#include <math.h>
|
|
|
|
#include "display_engine.h"
|
|
|
|
void draw_map(const struct game game)
|
|
{
|
|
extern const bopti_image_t img_tileset;
|
|
|
|
for (int i = 0; i < MAP_HEIGHT; i ++)
|
|
{
|
|
for (int j = 0; j < MAP_WIDTH; j++)
|
|
{
|
|
if (game.map.data[i][j] != -1)
|
|
{
|
|
int tile_x = (TILE_SIZE + 1) * (game.map.data[i][j] % TILESET_WIDTH), tile_y = (TILE_SIZE + 1) * (game.map.data[i][j] / TILESET_WIDTH);
|
|
dsubimage(j * TILE_SIZE, i * TILE_SIZE, &img_tileset, tile_x, tile_y, 8, 8, DIMAGE_NONE);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
void draw_player(const struct game game)
|
|
{
|
|
extern const bopti_image_t img_player;
|
|
|
|
dsubimage(game.player.x, game.player.y, &img_player, 9 * game.player.animation_frame, 13 * game.player.direction, 8, 12, DIMAGE_NONE);
|
|
}
|