diff --git a/README.md b/README.md index 739e568..a30f8bd 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ fullkning.exe ## Create your own level +### Manually + You can create your own level by creating a `.level` file with the following format... ```txt @@ -63,3 +65,65 @@ For each coordinate you will have a `VirtualBlock` which is your cyan `O` target ``` For example this is the level 4. + +### With level editor + +#### Windows + +Since `v0.2.0`, you can create your own level with the level editor by running the following command... + +```batch +levelmaker.exe +``` + +...you will see a window like this... + +```batch +&&&&&&&&&&&& +& & +& $ & +& & +& & +& & +& & +& & +& & +& & +& & +& & +& & +& & +& & +& & +& & +& & +& & +& & +& & +&&&&&&&&&&&& +Use {W, A, S, D}+ENTER to move the cursor +Use {P, R}+ENTER to place and remove a block +Use {Q}+ENTER to quit +``` + +...and you can create your own level by moving the cursor with `W`, `A`, `S`, `D` and placing or removing a block with `P` and `R`. + +ℹ️ - The blocks are placed under the `$` character if possible + +Then you can save your level by pressing `Q` and the level will be saved in the `levels` folder. + +#### Others + +You can create your own level with the level editor by running the following command... + +```bash +g++ levelmaker.cpp -o levelmaker -std=c++17 +./levelmaker +``` + +...you will see a window like the one above, now you can create your own level by moving the cursor with `W`, `A`, `S`, `D` and placing or removing a block with `P` and `R`. + +ℹ️ - The blocks are placed under the `$` character if possible +⚠️ - Due to problems with raw input, you will have to press `ENTER` after each key press + +Then you can save your level by pressing `Q` and the level will be saved in the `levels` folder. diff --git a/levelmaker.cpp b/levelmaker.cpp index 2cc43ac..b3cbdda 100644 --- a/levelmaker.cpp +++ b/levelmaker.cpp @@ -1,6 +1,9 @@ #include "include/sista/sista.hpp" #include #include +#ifdef _WIN32 + #include +#endif #define WIDTH 10 #define HEIGHT 20 @@ -43,8 +46,15 @@ int main(int argc, char* argv[]) { std::cout << "Use {Q}+ENTER to quit" << std::endl; while (true) { - cursor_handler.set({30, 30}); - char input = std::cin.get(); + #ifdef _WIN32 + char input = getch(); + #elif __APPLE__ + cursor_handler.set({20, 30}); + char input = std::cin.get(); + #else + cursor_handler.set({20, 30}); + char input = std::cin.get(); + #endif switch (input) { case 'w': case 'W': if (builder->getCoordinates().y > 0) { diff --git a/levelmaker.exe b/levelmaker.exe index 945d13c..6473aa6 100644 Binary files a/levelmaker.exe and b/levelmaker.exe differ