mirror of https://git.sr.ht/~kikoodx/momento
29 lines
730 B
C
29 lines
730 B
C
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
|
/* Copyright (C) 2021 KikooDX */
|
|
|
|
#include "conf.h"
|
|
#include "level.h"
|
|
#include <gint/display.h>
|
|
|
|
extern struct Level level;
|
|
extern bopti_image_t bimg_tileset;
|
|
|
|
void level_draw(void)
|
|
{
|
|
int x;
|
|
int y;
|
|
const int tileset_width = bimg_tileset.width / TILE_WIDTH;
|
|
for (y = 0; y < level.height; y += 1)
|
|
for (x = 0; x < level.width; x += 1) {
|
|
const int draw_x = x * TILE_WIDTH;
|
|
const int draw_y = y * TILE_HEIGHT;
|
|
const Tile tile =
|
|
level.data[x + y * level.width];
|
|
dsubimage(
|
|
draw_x, draw_y, &bimg_tileset,
|
|
(int)(tile % tileset_width) * TILE_WIDTH,
|
|
(int)(tile / tileset_width) * TILE_HEIGHT,
|
|
TILE_WIDTH, TILE_HEIGHT, DIMAGE_NONE);
|
|
}
|
|
}
|