mirror of https://git.sr.ht/~kikoodx/sle
36 lines
970 B
C
36 lines
970 B
C
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
|
/* Copyright (C) 2021 KikooDX */
|
|
|
|
#include "conf.h"
|
|
#include "editing_area/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];
|
|
const Rectangle tile_rect = {
|
|
(int)(tile % TILESET_WIDTH) * TILE_WIDTH,
|
|
(int)(tile / TILESET_HEIGHT) * TILE_WIDTH,
|
|
TILE_WIDTH, TILE_HEIGHT};
|
|
const Vector2 tile_pos = {
|
|
x * TILE_WIDTH + draw_offset_x,
|
|
y * TILE_HEIGHT + draw_offset_y};
|
|
if (tile)
|
|
DrawTextureRec(tileset, tile_rect,
|
|
tile_pos, WHITE);
|
|
}
|
|
}
|
|
}
|
|
|
|
void editor_mouse_draw(int x, int y) {
|
|
const int tx = x * TILE_WIDTH + draw_offset_x;
|
|
const int ty = y * TILE_HEIGHT + draw_offset_y;
|
|
DrawRectangle(tx, ty, TILE_WIDTH, TILE_HEIGHT, overring_tile_color);
|
|
}
|