sle/src/tile_picker/draw.c

33 lines
845 B
C

/* SPDX-License-Identifier: GPL-3.0-or-later */
/* Copyright (C) 2021 KikooDX */
#include "tile_picker/draw.h"
#include "conf.h"
#include <raylib.h>
void tileset_draw(Texture2D tileset, int selected_tile)
{
int x;
int y;
/* draw tiles */
for (x = 0; x < TILESET_WIDTH; x += 1) {
for (y = 0; y < TILESET_HEIGHT; y += 1) {
const Rectangle tile_rect = {
x * TILE_WIDTH, y * TILE_HEIGHT, TILE_WIDTH,
TILE_HEIGHT};
const Vector2 tile_pos = {
x * (TILE_WIDTH + PICKER_PADDING) +
PICKER_PADDING,
y * (TILE_HEIGHT + PICKER_PADDING) +
PICKER_PADDING};
/* apply tint if tile isn't selected */
Color tint = unselected_tile_color;
if (x + y * TILESET_WIDTH == selected_tile)
tint = WHITE;
/* draw the tile */
DrawTextureRec(tileset, tile_rect, tile_pos,
tint);
}
}
}