/* SPDX-License-Identifier: MIT * Copyright (c) 2021 KikooDX * This file is part of * [Painfull Success CG](https://git.sr.ht/~kikoodx/painfull-success-cg), * which is MIT licensed. The MIT license requires this copyright notice to be * included in all copies and substantial portions of the software. */ #include #include #include "level.h" #include "tiles.h" void level_draw(Level level) { /* Pixel position (where we draw). */ uint16_t x = DRAW_OFFSET_X; uint16_t y = DRAW_OFFSET_Y; /* Cursor position. */ uint8_t cx = 0; while (cx < LEVEL_WIDTH) { uint8_t cy = 0; while (cy < LEVEL_HEIGHT) { const tile_t tile = level.content[cy * LEVEL_WIDTH + cx]; const int color = tile_color(tile); drect(x, y, x + TILE_SIZE - 1, y + TILE_SIZE - 1, color); y += TILE_SIZE; cy += 1; } y = DRAW_OFFSET_Y; x += TILE_SIZE; cx += 1; } }