26 lines
610 B
Plaintext
26 lines
610 B
Plaintext
////////////////////////////////////////////////////////////
|
|
//~ Tile helpers
|
|
|
|
i32 S_TileIdxFromTilePos(Vec2 p)
|
|
{
|
|
i32 result = ClampI32(FloorF32(p.x) + (FloorF32(p.y) * S_TilesPitch), 0, S_TilesCount);
|
|
return result;
|
|
}
|
|
|
|
#if IsLanguageC
|
|
String S_TileNameFromKind(S_TileKind kind)
|
|
{
|
|
PERSIST Readonly String tile_names[S_TileKind_COUNT] = {
|
|
#define X(name, ...) [S_TileKind_##name] = CompLit(#name),
|
|
S_TilesXMacro(X)
|
|
#undef X
|
|
};
|
|
String result = Zi;
|
|
if (kind >= 0 && kind < countof(tile_names))
|
|
{
|
|
result = tile_names[kind];
|
|
}
|
|
return result;
|
|
}
|
|
#endif
|