2020-09-21 11:04:53 +02:00
|
|
|
#include <gint/display.h>
|
|
|
|
|
2020-09-21 14:15:58 +02:00
|
|
|
#include "conf.h"
|
2020-09-11 18:07:53 +02:00
|
|
|
#include "level.h"
|
|
|
|
#include "camera.h"
|
|
|
|
|
2020-09-21 11:04:53 +02:00
|
|
|
void level_step(const Level *level)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void level_draw(const Level *level, Camera *camera)
|
2020-09-11 18:07:53 +02:00
|
|
|
{
|
2020-09-21 11:04:53 +02:00
|
|
|
layer_draw(level, camera, 0);
|
2020-09-11 18:07:53 +02:00
|
|
|
}
|
|
|
|
|
2020-09-21 11:04:53 +02:00
|
|
|
void layer_draw(const Level *level, Camera *camera, uint layer_id)
|
2020-09-11 18:07:53 +02:00
|
|
|
{
|
2020-09-21 11:04:53 +02:00
|
|
|
const uint8_t *layer = level->layers[layer_id];
|
2020-09-21 12:01:54 +02:00
|
|
|
for (uint y = 0; y < level->height; ++y)
|
2020-09-21 11:04:53 +02:00
|
|
|
{
|
2020-09-21 12:01:54 +02:00
|
|
|
for (uint x = 0; x < level->width; ++x)
|
2020-09-21 11:04:53 +02:00
|
|
|
{
|
|
|
|
const uint8_t cell = layer[x + y * level->width];
|
|
|
|
#ifdef FX9860G
|
2020-09-21 14:15:58 +02:00
|
|
|
const int color = C_BLACK;
|
2020-09-21 11:04:53 +02:00
|
|
|
#endif /* FX9860G */
|
|
|
|
#ifdef FXCG50
|
2020-09-21 14:15:58 +02:00
|
|
|
const int color = C_GREEN;
|
2020-09-21 11:04:53 +02:00
|
|
|
#endif /* FXCG50 */
|
2020-09-21 14:15:58 +02:00
|
|
|
if (cell == 1)
|
|
|
|
{
|
|
|
|
Vec tl = {x, y};
|
|
|
|
Vec br;
|
|
|
|
vec_mul(&tl, VEC_PRECISION * TILE_SIZE);
|
|
|
|
vec_sub(&tl, camera->pos);
|
|
|
|
vec_div(&tl, VEC_PRECISION);
|
|
|
|
vec_sub(&tl, VEC_DCENTER);
|
|
|
|
vec_cpy(&br, tl);
|
|
|
|
vec_add(&br, (Vec){TILE_SIZE - 1, TILE_SIZE - 1});
|
|
|
|
vec_drect(tl, br, color);
|
|
|
|
}
|
2020-09-21 11:04:53 +02:00
|
|
|
}
|
|
|
|
}
|
2020-09-11 18:07:53 +02:00
|
|
|
}
|