diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-06 09:49:23 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-06 09:57:50 +0200 |
commit | 89acc4653fe7ea3a76dd49711b3ac6b704ed509d (patch) | |
tree | dcff8947d840f50ee348e375aca311829dad2e7a /src/tile.hpp | |
parent | 595c113b88dc1e81802b4b1381122f25c0eece74 (diff) |
a
Diffstat (limited to 'src/tile.hpp')
-rw-r--r-- | src/tile.hpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/tile.hpp b/src/tile.hpp new file mode 100644 index 00000000..261c50ee --- /dev/null +++ b/src/tile.hpp @@ -0,0 +1,40 @@ +#pragma once +#include <Magnum/Magnum.h> +#include <Magnum/Math/Vector3.h> +#include <cstddef> +#include <cstdint> +#include <memory> + +namespace Magnum::Examples { + +struct tile_atlas; +constexpr inline Vector3 TILE_SIZE = { 64, 64, 64 }; +constexpr inline std::size_t TILE_MAX_DIM = 16; +constexpr inline std::size_t TILE_COUNT = TILE_MAX_DIM*TILE_MAX_DIM; + +struct tile_image final +{ + std::shared_ptr<tile_atlas> atlas; + std::uint8_t variant = 0xff; + + explicit operator bool() const noexcept { return !!atlas; } +}; + +struct tile final +{ + enum class pass_mode : std::uint8_t { pass_blocked, pass_ok, pass_shoot_through, }; + using enum pass_mode; + + tile_image ground_image, wall_west, wall_north; + pass_mode passability = pass_shoot_through; +}; + +struct local_coords final { + std::uint8_t x = 0, y = 0; + constexpr local_coords() = default; + local_coords(std::size_t x, std::size_t y); + constexpr local_coords(std::uint8_t x, std::uint8_t y) : x{x}, y{y} {} + constexpr std::size_t to_index() const { return y*TILE_MAX_DIM + x; } +}; + +} //namespace Magnum::Examples |