2d-platformer/Engine-Core/include/utility.h

111 lines
1.7 KiB
C++

#pragma once
#include <SFML/Graphics/Sprite.hpp>
#include <cstdint>
#include <string_view>
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using s8 = int8_t;
using s16 = int16_t;
using s32 = int32_t;
using s64 = int64_t;
using tag_t = uint8_t;
using subtag_t = uint8_t;
using index_t = uint16_t;
namespace Tag
{
enum : tag_t
{
player,
tile,
enemy,
tag_count
};
}
namespace SubTag
{
enum : subtag_t
{
enemy_weak,
enemy_strong,
floor_tile,
background_tile,
subtag_count
};
}
namespace ErrorCode
{
enum : int
{
noError,
entityOverflow,
};
}
namespace util
{
using namespace std::string_view_literals;
inline constexpr index_t MAX_PLAYERS{1u};
inline constexpr index_t MAX_TILES {1'000u};
inline constexpr index_t MAX_ENEMIES {1'000u};
inline constexpr index_t MAX_ENTITIES {MAX_PLAYERS + MAX_TILES + MAX_ENEMIES};
inline constexpr tag_t TAG_COUNT {Tag::tag_count};
// used for imgui
inline constexpr const char* tagStringsC[TAG_COUNT] =
{
"player",
"tile",
"enemy",
};
inline constexpr std::string_view tagStrings[TAG_COUNT] =
{
"player"sv,
"tile"sv,
"enemy"sv,
};
inline constexpr index_t tagStart[TAG_COUNT] =
{
0,//player
1,//tile start
MAX_TILES,//enemy start
};
inline constexpr index_t tagSize[TAG_COUNT] =
{
MAX_PLAYERS,
MAX_TILES,
MAX_ENEMIES,
};
inline constexpr index_t getTagStart(tag_t tag)
{
return tagStart[tag];
}
inline constexpr index_t getTagSize(tag_t tag)
{
return tagSize[tag];
}
inline constexpr const char* getTagStringC(tag_t tag)
{
return tagStringsC[tag];
}
inline constexpr std::string_view getTagString(tag_t tag)
{
return tagStrings[tag];
}
}