summaryrefslogtreecommitdiff
path: root/src/level.h
diff options
context:
space:
mode:
authorJun Zhang <jun@junz.org>2022-01-30 12:30:02 +0800
committerGitHub <noreply@github.com>2022-01-29 21:30:02 -0700
commitcb7af3f4cac90f95926477b4001f9f80037568d5 (patch)
tree022f4700c796a9935acd3ee0d0fd80a812a78464 /src/level.h
parent99b4763f1028e72bb06d8db6c7e8ace469f8989c (diff)
refactor: adjust the project infra. (#1)
* refactor: adjust the project infra. This patch adds cmake build system to the project, and adjust infrastructure stuff. Signed-off-by: Jun Zhang <jun@junz.org> * fix: remove compiler flags that only exist in GCC. Signed-off-by: Jun Zhang <jun@junz.org>
Diffstat (limited to 'src/level.h')
-rw-r--r--src/level.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/level.h b/src/level.h
new file mode 100644
index 0000000..0ffdac2
--- /dev/null
+++ b/src/level.h
@@ -0,0 +1,28 @@
+#pragma once
+
+#include <cstdint>
+#include <cstring>
+
+class Level {
+public:
+ Level(int width, int height);
+ ~Level() { delete[] m_tiles; }
+
+ uint8_t get(int x, int y);
+ void set(int x, int y, uint8_t tile);
+ bool inBounds(int x, int y) { return x >= 0 && x < m_width && y >= 0 && y < m_height; }
+private:
+ int m_width, m_height;
+ uint8_t* m_tiles;
+};
+
+enum RailDirection {
+ NorthSouth = 1,
+ EastWest,
+ SouthEast,
+ SouthWest,
+ NorthWest,
+ NorthEast,
+};
+
+RailDirection ChooseDirection(Level& level, int x, int y); \ No newline at end of file