28 lines
1.1 KiB
C
28 lines
1.1 KiB
C
#include "display_engine.h"
|
|
|
|
void display_map(const int x_offset, const int y_offset)
|
|
{
|
|
extern const struct map map_world;
|
|
extern const bopti_image_t img_tileset;
|
|
|
|
for (int layer = 0 ; layer < map_world.nb_layers; layer++)
|
|
{
|
|
for (int y = 0 ; y <= SCREEN_HEIGHT; y ++)
|
|
{
|
|
for (int x = 0 ; x <= SCREEN_WIDTH; x ++)
|
|
{
|
|
unsigned int tile_id = 0;
|
|
if (x < map_world.width && y < map_world.height) tile_id = map_world.layers[layer][(y + y_offset / TILE_SIZE) * map_world.width + (x + x_offset / TILE_SIZE)];
|
|
|
|
if (tile_id != 0)
|
|
{
|
|
tile_id --;
|
|
unsigned int tile_x = TILE_SIZE * (tile_id % TILESET_WIDTH);
|
|
unsigned int tile_y = TILE_SIZE * (tile_id / TILESET_WIDTH);
|
|
|
|
dsubimage(x * TILE_SIZE - (x_offset % TILE_SIZE), y * TILE_SIZE - (y_offset % TILE_SIZE), &img_tileset, tile_x, tile_y, TILE_SIZE, TILE_SIZE, DIMAGE_NONE);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |