Cool kid make boring stuff. Cool kid no cool anymore :(

This commit is contained in:
KikooDX 2021-01-06 18:42:19 +01:00
parent 8804a12a90
commit c3fe17824c
2 changed files with 13 additions and 18 deletions

View File

@ -13,4 +13,5 @@
#define FPS 32
#endif /* FXCG50 */
#define TILE_PX_SIZE (8 * SCALE)
#define VEC_SCALED_DCENTER (Vec){DWIDTH / (2 * SCALE), DHEIGHT / (2 * SCALE)}

View File

@ -18,6 +18,12 @@ void level_draw(const Level *level, Camera *camera) {
void layer_draw(const Level *level, Camera *camera, uint layer_id) {
const Tile *layer = level->layers[layer_id];
#ifdef FX9860G
const int color = C_LIGHT;
#endif /* FX9860G */
#ifdef FXCG50
const int color = C_GREEN;
#endif /* FXCG50 */
Vec display_tl, display_br;
vec_cpy(&display_tl, camera->pos);
vec_cpy(&display_br, display_tl);
@ -31,24 +37,12 @@ void layer_draw(const Level *level, Camera *camera, uint layer_id) {
int end_y = (display_br.y < level->height) ? (display_br.y + 1) : (level->height);
for (int y = start_y; y < end_y; ++y) {
for (int x = start_x; x < end_x; ++x) {
const Tile cell = layer[x + y * level->width];
#ifdef FX9860G
const int color = C_LIGHT;
#endif /* FX9860G */
#ifdef FXCG50
const int color = C_GREEN;
#endif /* FXCG50 */
if (cell == 1) {
Vec tl = {x, y};
Vec br;
vec_mul(&tl, TILE_SIZE);
vec_div(&tl, VEC_PRECISION);
vec_sub(&tl, camera->offset);
vec_mul(&tl, SCALE);
vec_cpy(&br, tl);
vec_add(&br, (Vec){TILE_SIZE / VEC_PRECISION * SCALE - 1,
TILE_SIZE / VEC_PRECISION * SCALE - 1});
vec_drect(tl, br, color);
const Tile tile = layer[x + y * level->width];
if (tile) {
Vec tl = {
(x * TILE_SIZE / VEC_PRECISION - camera->offset.x) * SCALE,
(y * TILE_SIZE / VEC_PRECISION - camera->offset.y) * SCALE };
drect(tl.x, tl.y, tl.x + TILE_PX_SIZE, tl.y + TILE_PX_SIZE, color);
}
}
}