diff options
author | cflip <cflip@cflip.net> | 2022-03-06 10:59:56 -0700 |
---|---|---|
committer | cflip <cflip@cflip.net> | 2022-03-06 11:05:05 -0700 |
commit | c48dbb7a7cbff7dc6d413edc42a011c261047297 (patch) | |
tree | 55d69061e55aabe73698539cb2f5602e465ae8c9 /src/level.h | |
parent | d198dd25af201aaacc7782f4bd36d2cfa5f0c05b (diff) |
Create new tile byte format
Track tiles now have their direction information stored in the high 4
bits of the tile byte, creating a clearer separation between the type of
tile and other persistent data.
This will make the code more managable for adding new tile types and with
the new macros and enums the code is much easier to read and understand.
Diffstat (limited to 'src/level.h')
-rw-r--r-- | src/level.h | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/level.h b/src/level.h index e915da3..d24ccb4 100644 --- a/src/level.h +++ b/src/level.h @@ -5,8 +5,26 @@ #include <cstring> #include <vector> +#define TILE_TYPE(x) ((x)&0xf) +#define TILE_DATA(x) (x >> 4 & 0xf) +#define MAKE_TILE(t, d) ((((d) & 0xf) << 4) + ((t)&0xf)) + class Train; +enum TileType : uint8_t { + TileGround, + TileTrack +}; + +enum TrackDirection : uint8_t { + NorthSouth, + EastWest, + SouthEast, + SouthWest, + NorthWest, + NorthEast, +}; + class Level { public: Level(int width, int height, Bitmap& tileSprites); @@ -30,13 +48,4 @@ private: std::vector<Train*> m_vehicles; }; -enum RailDirection { - NorthSouth = 1, - EastWest, - SouthEast, - SouthWest, - NorthWest, - NorthEast, -}; - -RailDirection ChooseDirection(Level& level, int x, int y);
\ No newline at end of file +TrackDirection ChooseDirection(Level& level, int x, int y);
\ No newline at end of file |