get tiles

This commit is contained in:
KikooDX 2021-12-16 23:27:04 +01:00
parent a3c7245dd0
commit 689044f03b
3 changed files with 19 additions and 0 deletions

View File

@ -1,3 +1,4 @@
#pragma once
#define TILE_SIZE 16
#define TILE_OOB 0

View File

@ -21,4 +21,8 @@ void level_deinit(void);
void level_load(const struct LevelBin *);
void level_reload(void);
void level_regen_visual_data(void);
void level_draw(void);
int level_get(int x, int y);
int level_get_px(int x, int y);

View File

@ -77,6 +77,20 @@ level_draw(void)
}
}
int
level_get(int x, int y)
{
if (x < 0 || y < 0 || x >= level.width || y >= level.height)
return TILE_OOB;
return level.data[x + y * level.width];
}
int
level_get_px(int x, int y)
{
return level_get(x / TILE_SIZE, y / TILE_SIZE);
}
static void
level_free(void)
{