mirror of https://git.sr.ht/~kikoodx/sle
39 lines
1.0 KiB
C
39 lines
1.0 KiB
C
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
|
/* Copyright (C) 2021 KikooDX */
|
|
|
|
#include "tile_picker/draw.h"
|
|
#include "conf.h"
|
|
#include "options.h"
|
|
#include <raylib.h>
|
|
|
|
void tileset_draw(Texture2D tileset, struct Options options,
|
|
int selected_tile)
|
|
{
|
|
int x;
|
|
int y;
|
|
/* draw tiles */
|
|
for (x = 0; x < options.tileset_width; x += 1) {
|
|
for (y = 0; y < options.tileset_height; y += 1) {
|
|
const Rectangle tile_rect = {
|
|
x * options.tile_width,
|
|
y * options.tile_height, options.tile_width,
|
|
options.tile_height};
|
|
const Vector2 tile_pos = {
|
|
x * (options.tile_width +
|
|
options.picker_padding) +
|
|
options.picker_padding,
|
|
y * (options.tile_height +
|
|
options.picker_padding) +
|
|
options.picker_padding};
|
|
/* apply tint if tile isn't selected */
|
|
Color tint = UNSELECTED_TILE_COLOR;
|
|
if (x + y * options.tileset_width ==
|
|
selected_tile)
|
|
tint = WHITE;
|
|
/* draw the tile */
|
|
DrawTextureRec(tileset, tile_rect, tile_pos,
|
|
tint);
|
|
}
|
|
}
|
|
}
|