forked from kdx/jtmm2-old
44 lines
907 B
C
44 lines
907 B
C
#include <gint/display.h>
|
|
|
|
#include "conf.h"
|
|
#include "level.h"
|
|
#include "camera.h"
|
|
|
|
void level_step(const Level *level)
|
|
{
|
|
}
|
|
|
|
void level_draw(const Level *level, Camera *camera)
|
|
{
|
|
layer_draw(level, camera, 0);
|
|
}
|
|
|
|
void layer_draw(const Level *level, Camera *camera, uint layer_id)
|
|
{
|
|
const uint8_t *layer = level->layers[layer_id];
|
|
for (uint y = 0; y < level->height; ++y)
|
|
{
|
|
for (uint x = 0; x < level->width; ++x)
|
|
{
|
|
const uint8_t cell = layer[x + y * level->width];
|
|
#ifdef FX9860G
|
|
const int color = C_BLACK;
|
|
#endif /* FX9860G */
|
|
#ifdef FXCG50
|
|
const int color = C_GREEN;
|
|
#endif /* FXCG50 */
|
|
if (cell == 1)
|
|
{
|
|
Vec tl = {x, y};
|
|
Vec br;
|
|
vec_mul(&tl, VEC_PRECISION * TILE_SIZE);
|
|
vec_div(&tl, VEC_PRECISION);
|
|
vec_sub(&tl, camera->offset);
|
|
vec_cpy(&br, tl);
|
|
vec_add(&br, (Vec){TILE_SIZE - 1, TILE_SIZE - 1});
|
|
vec_drect(tl, br, color);
|
|
}
|
|
}
|
|
}
|
|
}
|