mirror of https://git.sr.ht/~kikoodx/momento
50 lines
1.0 KiB
C
50 lines
1.0 KiB
C
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
|
/* Copyright (C) 2021 KikooDX */
|
|
|
|
#include "conf.h"
|
|
#include "level.h"
|
|
#include "tiles.h"
|
|
#include <gint/display.h>
|
|
|
|
extern const bopti_image_t bimg_tileset;
|
|
extern const bopti_image_t bimg_water;
|
|
|
|
static void water_draw(void);
|
|
|
|
void
|
|
level_draw(void)
|
|
{
|
|
int i;
|
|
|
|
if (level.water_level >= 0)
|
|
water_draw();
|
|
|
|
i = level.height * level.width;
|
|
while (i-- > 0) {
|
|
const struct VisualTile *visual_tile = &level.visual_data[i];
|
|
if (visual_tile->visible) {
|
|
dsubimage(visual_tile->x, visual_tile->y, &bimg_tileset,
|
|
visual_tile->texture_x,
|
|
visual_tile->texture_y, TILE_WIDTH,
|
|
TILE_HEIGHT, DIMAGE_NOCLIP);
|
|
}
|
|
}
|
|
}
|
|
|
|
static void
|
|
water_draw(void)
|
|
{
|
|
int x;
|
|
const int y = level.water_level;
|
|
|
|
x = level.width;
|
|
while (x-- > 0) {
|
|
const Tile tile = level_get_tile(x, y);
|
|
if (tile != TILE_SOLID)
|
|
dsubimage(
|
|
x * TILE_WIDTH, y * TILE_HEIGHT, &bimg_water,
|
|
(int)(level.water_timer / WATER_FLOW) * TILE_WIDTH,
|
|
0, TILE_WIDTH, bimg_water.height, DIMAGE_NOCLIP);
|
|
}
|
|
}
|