mirror of https://git.sr.ht/~kikoodx/sle
30 lines
735 B
C
30 lines
735 B
C
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
|
/* Copyright (C) 2021 KikooDX */
|
|
|
|
#include "conf.h"
|
|
#include "level.h"
|
|
#include <raylib.h>
|
|
#include <stdlib.h>
|
|
|
|
void level_draw(struct Level level, Texture2D tileset)
|
|
{
|
|
int x;
|
|
int y;
|
|
for (x = 0; x < level.width; x += 1) {
|
|
for (y = 0; y < level.height; y += 1) {
|
|
const int tile =
|
|
level.data[x + y * level.width];
|
|
Rectangle tile_rect = {
|
|
(int)(tile % tileset.width) * tile_width,
|
|
(int)(tile / tileset.width) * tile_width,
|
|
tile_width, tile_height};
|
|
Vector2 tile_pos = {
|
|
x * tile_width + draw_offset_x,
|
|
y * tile_height + draw_offset_y};
|
|
if (tile)
|
|
DrawTextureRec(tileset, tile_rect,
|
|
tile_pos, WHITE);
|
|
}
|
|
}
|
|
}
|