diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2022-03-12 12:09:58 -0500 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2022-03-12 12:09:58 -0500 |
| commit | be9ccb73bc20b03f62c77f5d529602a10ef4eda9 (patch) | |
| tree | 6f88a9b780a75e52b2f04b6f61167f4ef46590a7 /src/direction.h | |
| parent | c1a88a064a0cddbc1df2e716ef2102d22bbf681b (diff) | |
| download | ether-be9ccb73bc20b03f62c77f5d529602a10ef4eda9.tar.gz ether-be9ccb73bc20b03f62c77f5d529602a10ef4eda9.tar.bz2 ether-be9ccb73bc20b03f62c77f5d529602a10ef4eda9.zip | |
player has a sprite now thanks to world of solaria
Diffstat (limited to 'src/direction.h')
| -rw-r--r-- | src/direction.h | 22 |
1 files changed, 22 insertions, 0 deletions
| diff --git a/src/direction.h b/src/direction.h new file mode 100644 index 0000000..0fe3e5a --- /dev/null +++ b/src/direction.h | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | #ifndef DIRECTION_H_42BDAFB9 | ||
| 2 | #define DIRECTION_H_42BDAFB9 | ||
| 3 | |||
| 4 | #include <string_view> | ||
| 5 | #include <stdexcept> | ||
| 6 | |||
| 7 | enum class Direction { | ||
| 8 | up, | ||
| 9 | down, | ||
| 10 | left, | ||
| 11 | right | ||
| 12 | }; | ||
| 13 | |||
| 14 | inline Direction directionFromString(std::string_view str) { | ||
| 15 | if (str == "up") return Direction::up; | ||
| 16 | if (str == "right") return Direction::right; | ||
| 17 | if (str == "down") return Direction::down; | ||
| 18 | if (str == "left") return Direction::left; | ||
| 19 | throw std::invalid_argument("Invalid direction: " + std::string(str)); | ||
| 20 | } | ||
| 21 | |||
| 22 | #endif /* end of include guard: DIRECTION_H_42BDAFB9 */ | ||
