diff --git a/.clang-tidy b/.clang-tidy index b43782f1..b298228c 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,5 @@ --- -Checks: '*,-fuchsia-*,-google-*,-zircon-*,-abseil-*,-modernize-use-trailing-return-type,-llvm*, -hicpp-uppercase-literal-suffix, -readability-uppercase-literal-suffix' +Checks: '*,-fuchsia-*,-google-*,-zircon-*,-abseil-*,-modernize-use-trailing-return-type,-llvm*,-hicpp-uppercase-literal-suffix, -readability-uppercase-literal-suffix, -readability-implicit-bool-conversion,-cppcoreguidelines-avoid-magic-numbers, -readability-magic-numbers, -cppcoreguidelines-pro-type-union-access,-cppcoreguidelines-pro-bounds-pointer-arithmetic, -cppcoreguidelines-pro-type-reinterpret-cast-cppcoreguidelines-pro-type-vararg, -cppcoreguidelines-pro-type-vararg, -hicpp-vararg, -altera-id-dependent-backward-branch, -bugprone-easily-swappable-parameters, -readability-identifier-length, -altera-unroll-loops, -cppcoreguidelines-non-private-member-variables-in-classes, -altera-struct-pack-align, -misc-non-private-member-variables-in-classes, -cppcoreguidelines-pro-type-static-cast-downcast, -readability-convert-member-functions-to-static, -cppcoreguidelines-owning-memory' WarningsAsErrors: '*' HeaderFilterRegex: '' -FormatStyle: none +FormatStyle: none \ No newline at end of file diff --git a/.github/workflows/code_quality.yml b/.github/workflows/code_quality.yml index 2d544688..d537307d 100644 --- a/.github/workflows/code_quality.yml +++ b/.github/workflows/code_quality.yml @@ -17,3 +17,6 @@ jobs: with: exclude_dir: dependencies apt_pckgs: xorg-dev + verbose: true + cppcheck_args: | + --enable=all --suppress=functionStatic --suppress=unusedFunction --inline-suppr --inconclusive \ No newline at end of file diff --git a/.gitignore b/.gitignore index 564828ac..37827050 100644 --- a/.gitignore +++ b/.gitignore @@ -308,11 +308,11 @@ paket-files/ # Project specific folders build .vscode -dependencies/Freetype/Freetype* -dependencies/GLM/glm* -dependencies/STB_IMAGE/STB_IMAGE* -dependencies/JSON/JSON* -dependencies/FMT/FMT* -dependencies/Imgui/IMGUI* -dependencies/glfw/GLFW* +dependencies/freetype/freetype* +dependencies/glm/glm* +dependencies/stb_image/stb_image* +dependencies/json/json* +dependencies/fmt/fmt* +dependencies/imgui/imgui* +dependencies/glfw/glfw* *imgui.ini diff --git a/Assets/Images/house1.png b/Assets/Images/house1.png deleted file mode 100644 index b146f951..00000000 Binary files a/Assets/Images/house1.png and /dev/null differ diff --git a/README.md b/README.md index d36680c8..6b4bda2a 100644 --- a/README.md +++ b/README.md @@ -2,22 +2,22 @@ ![Windows](https://github.com/JacobDomagala/DGame/workflows/Windows%20Full%20Build/badge.svg) ![Ubuntu](https://github.com/JacobDomagala/DGame/workflows/Ubuntu%20Full%20Build/badge.svg) -# DGame +# Looper +2D Top-down shooter game (and level editor) written in modern C++. -# Build -**To build this project CMake version 3.5 is required!** +## Build + +Looper is CMake based project working both on Linux (Ubuntu) and Windows. To build it, you will need at least C++17 compiler and CMake version 3.18.
-**Windows:** -- create build folder -- inside build folder run cmake command, i.e. -> cmake -G "Visual Studio 15 2017 Win64" .. -- this command will generate Visual Studio solution file for x64 arch +Typical build process would look like this: +```bash +# Create build directory +mkdir build && cd build +# Generate build system for Windows/Linux +cmake -G "Visual Studio 16 2019" .. +cmake -G "Ninja" .. -# TODO -- Linux compatibility -- Improve enemy AI -- New assets -- Multiplayer -- Sound -- Menu +# Build +cmake --build . +``` \ No newline at end of file diff --git a/Assets/GameInit.txt b/assets/GameInit.txt similarity index 100% rename from Assets/GameInit.txt rename to assets/GameInit.txt diff --git a/Assets/Fonts/segoeui.ttf b/assets/fonts/segoeui.ttf similarity index 100% rename from Assets/Fonts/segoeui.ttf rename to assets/fonts/segoeui.ttf diff --git a/Assets/Images/Default128.png b/assets/images/Default128.png similarity index 100% rename from Assets/Images/Default128.png rename to assets/images/Default128.png diff --git a/Assets/Images/Enemy.png b/assets/images/Enemy.png similarity index 100% rename from Assets/Images/Enemy.png rename to assets/images/Enemy.png diff --git a/Assets/Images/Level1.png b/assets/images/Level1.png similarity index 100% rename from Assets/Images/Level1.png rename to assets/images/Level1.png diff --git a/Assets/Images/Level1_Char.png b/assets/images/Level1_Char.png similarity index 100% rename from Assets/Images/Level1_Char.png rename to assets/images/Level1_Char.png diff --git a/Assets/Images/Level1_VectorField.png b/assets/images/Level1_VectorField.png similarity index 100% rename from Assets/Images/Level1_VectorField.png rename to assets/images/Level1_VectorField.png diff --git a/Assets/Images/Level1_collision.png b/assets/images/Level1_collision.png similarity index 100% rename from Assets/Images/Level1_collision.png rename to assets/images/Level1_collision.png diff --git a/Assets/Images/NodeSprite.png b/assets/images/NodeSprite.png similarity index 100% rename from Assets/Images/NodeSprite.png rename to assets/images/NodeSprite.png diff --git a/assets/images/house1.png b/assets/images/house1.png new file mode 100644 index 00000000..a3065bf8 Binary files /dev/null and b/assets/images/house1.png differ diff --git a/Assets/Images/white.png b/assets/images/white.png similarity index 100% rename from Assets/Images/white.png rename to assets/images/white.png diff --git a/Assets/Levels/Level1/Default.png b/assets/levels/Level1/Default.png similarity index 100% rename from Assets/Levels/Level1/Default.png rename to assets/levels/Level1/Default.png diff --git a/Assets/Levels/Level1/Default128.png b/assets/levels/Level1/Default128.png similarity index 100% rename from Assets/Levels/Level1/Default128.png rename to assets/levels/Level1/Default128.png diff --git a/Assets/Levels/Level1/Defaultsmall.png b/assets/levels/Level1/Defaultsmall.png similarity index 100% rename from Assets/Levels/Level1/Defaultsmall.png rename to assets/levels/Level1/Defaultsmall.png diff --git a/Assets/Levels/Level1/Level1.png b/assets/levels/Level1/Level1.png similarity index 100% rename from Assets/Levels/Level1/Level1.png rename to assets/levels/Level1/Level1.png diff --git a/Assets/Levels/Level1/Level1.txt b/assets/levels/Level1/Level1.txt similarity index 100% rename from Assets/Levels/Level1/Level1.txt rename to assets/levels/Level1/Level1.txt diff --git a/Assets/Levels/Level1/Level1_Char.png b/assets/levels/Level1/Level1_Char.png similarity index 100% rename from Assets/Levels/Level1/Level1_Char.png rename to assets/levels/Level1/Level1_Char.png diff --git a/Assets/Levels/Level1/Level1_VectorField.png b/assets/levels/Level1/Level1_VectorField.png similarity index 100% rename from Assets/Levels/Level1/Level1_VectorField.png rename to assets/levels/Level1/Level1_VectorField.png diff --git a/Assets/Levels/Level1/Level1_VectorFieldTest1.png b/assets/levels/Level1/Level1_VectorFieldTest1.png similarity index 100% rename from Assets/Levels/Level1/Level1_VectorFieldTest1.png rename to assets/levels/Level1/Level1_VectorFieldTest1.png diff --git a/Assets/Levels/Level1/Level1_VectorFieldTest2.png b/assets/levels/Level1/Level1_VectorFieldTest2.png similarity index 100% rename from Assets/Levels/Level1/Level1_VectorFieldTest2.png rename to assets/levels/Level1/Level1_VectorFieldTest2.png diff --git a/Assets/Levels/Level1/Level1_collision.png b/assets/levels/Level1/Level1_collision.png similarity index 100% rename from Assets/Levels/Level1/Level1_collision.png rename to assets/levels/Level1/Level1_collision.png diff --git a/Assets/Levels/Level1/back.png b/assets/levels/Level1/back.png similarity index 100% rename from Assets/Levels/Level1/back.png rename to assets/levels/Level1/back.png diff --git a/Assets/Levels/TestLevel/Default.png b/assets/levels/TestLevel/Default.png similarity index 100% rename from Assets/Levels/TestLevel/Default.png rename to assets/levels/TestLevel/Default.png diff --git a/Assets/Levels/TestLevel/Default128.png b/assets/levels/TestLevel/Default128.png similarity index 100% rename from Assets/Levels/TestLevel/Default128.png rename to assets/levels/TestLevel/Default128.png diff --git a/Assets/Levels/TestLevel/Defaultsmall.png b/assets/levels/TestLevel/Defaultsmall.png similarity index 100% rename from Assets/Levels/TestLevel/Defaultsmall.png rename to assets/levels/TestLevel/Defaultsmall.png diff --git a/Assets/Levels/TestLevel/Level1.png b/assets/levels/TestLevel/Level1.png similarity index 100% rename from Assets/Levels/TestLevel/Level1.png rename to assets/levels/TestLevel/Level1.png diff --git a/Assets/Levels/TestLevel/Level1_Char.png b/assets/levels/TestLevel/Level1_Char.png similarity index 100% rename from Assets/Levels/TestLevel/Level1_Char.png rename to assets/levels/TestLevel/Level1_Char.png diff --git a/Assets/Levels/TestLevel/Level1_VectorField.png b/assets/levels/TestLevel/Level1_VectorField.png similarity index 100% rename from Assets/Levels/TestLevel/Level1_VectorField.png rename to assets/levels/TestLevel/Level1_VectorField.png diff --git a/Assets/Levels/TestLevel/Level1_collision.png b/assets/levels/TestLevel/Level1_collision.png similarity index 100% rename from Assets/Levels/TestLevel/Level1_collision.png rename to assets/levels/TestLevel/Level1_collision.png diff --git a/Assets/Levels/TestLevel/TestLevel.dgl b/assets/levels/TestLevel/TestLevel.dgl similarity index 76% rename from Assets/Levels/TestLevel/TestLevel.dgl rename to assets/levels/TestLevel/TestLevel.dgl index d6b8972f..300fe9f8 100644 --- a/Assets/Levels/TestLevel/TestLevel.dgl +++ b/assets/levels/TestLevel/TestLevel.dgl @@ -11,31 +11,17 @@ "animate positions": [ { "end position": [ - 1630.0, - 718.0 - ], - "time duration": 2 - }, - { - "end position": [ - 1884.0, - 562.0 - ], - "time duration": 2 - }, - { - "end position": [ - 2092.0, - 658.0 + 2801.0, + 188.0 ], "time duration": 2 } ], "animation type": "Reversable", - "name": "DummyName", + "name": "Enemy_0", "position": [ - 1363, - 441 + 2655.79345703125, + 906.0271606445313 ], "rotation": 0.0, "scale": [ @@ -46,31 +32,24 @@ 128.0, 128.0 ], - "texture": "Default128.png", + "texture": "Enemy.png", "weapons": "glock" }, { "animate positions": [ { "end position": [ - 1979.0, - 1625.0 - ], - "time duration": 2 - }, - { - "end position": [ - 1945.0, - 1381.0 + 2882.0, + 1156.0 ], "time duration": 2 } ], "animation type": "Reversable", - "name": "DummyName", + "name": "Enemy_1", "position": [ - 1664, - 1982 + 2760.100341796875, + 1749.5760498046875 ], "rotation": 0.0, "scale": [ @@ -81,139 +60,151 @@ 128.0, 128.0 ], - "texture": "Default128.png", + "texture": "Enemy.png", "weapons": "glock" } ], "OBJECTS": [ { "has collision": true, - "name": "DummyName", + "name": "House_0", "occupied nodes": [ { "tile position": [ - 3, - 8 + -1, + -1 ] }, { "tile position": [ - 4, - 8 + -1, + -1 ] }, { "tile position": [ 5, - 8 + 0 ] }, { "tile position": [ - 6, - 8 + 5, + 1 ] }, { "tile position": [ - 7, - 8 + 5, + 2 ] }, { "tile position": [ - 3, - 8 + 5, + 3 ] }, { "tile position": [ - 3, - 9 + 5, + 4 ] }, { "tile position": [ - 3, - 10 + 5, + 5 ] }, { "tile position": [ - 3, - 11 + 5, + 6 ] }, { "tile position": [ - 3, - 12 + 5, + 6 ] }, { "tile position": [ - 3, - 12 + 6, + 6 ] }, { "tile position": [ - 4, - 12 + 7, + 6 ] }, { "tile position": [ - 5, - 12 + 8, + 6 ] }, { "tile position": [ - 6, - 12 + 9, + 6 ] }, { "tile position": [ - 7, - 12 + -1, + -1 ] }, { "tile position": [ - 7, - 8 + 9, + 0 ] }, { "tile position": [ - 7, - 9 + 9, + 1 ] }, { "tile position": [ - 7, - 10 + 9, + 2 ] }, { "tile position": [ - 7, - 11 + 9, + 3 ] }, { "tile position": [ - 7, - 12 + 9, + 4 + ] + }, + { + "tile position": [ + 9, + 5 + ] + }, + { + "tile position": [ + 9, + 6 ] } ], "position": [ - 713, - 1391 + 1002.2954711914063, + 367.6463623046875 ], "rotation": -1.5749990940093994, "scale": [ @@ -221,326 +212,1768 @@ 1.0 ], "size": [ - 500.0, + 892.0, 500.0 ], - "texture": "D:\\Projects\\DGame\\Assets\\Images\\house1.png" + "texture": "house1.png" }, { "has collision": true, - "name": "DummyName", + "name": "House_1", "occupied nodes": [ { "tile position": [ - 9, - 9 + -1, + -1 ] }, { "tile position": [ - 9, - 10 + 0, + 4 ] }, { "tile position": [ - 10, - 10 + 0, + 5 ] }, { "tile position": [ - 10, - 11 + 0, + 6 ] }, { "tile position": [ - 11, - 11 + 0, + 7 ] }, { "tile position": [ - 11, + 0, + 8 + ] + }, + { + "tile position": [ + -1, + -1 + ] + }, + { + "tile position": [ + 0, 12 ] }, { "tile position": [ - 5, - 11 + 1, + 12 ] }, { "tile position": [ - 6, - 10 + 2, + 12 ] }, { "tile position": [ - 6, - 11 + 3, + 12 ] }, { "tile position": [ - 7, - 9 + 3, + 13 ] }, { "tile position": [ - 7, - 10 + 3, + 7 ] }, { "tile position": [ - 8, - 9 + 3, + 8 ] }, { "tile position": [ - 9, + 3, 9 ] }, { "tile position": [ - 5, - 11 + 3, + 10 ] }, { "tile position": [ - 6, + 3, 11 ] }, { "tile position": [ - 6, + 3, 12 ] }, { "tile position": [ - 7, - 12 + 3, + 13 ] }, { "tile position": [ - 7, - 13 + 4, + 5 ] }, { "tile position": [ - 7, - 14 + 4, + 6 ] }, { "tile position": [ - 8, - 14 + 4, + 7 ] }, { "tile position": [ - 8, - 13 + 0, + 4 ] }, { "tile position": [ - 8, - 14 + 1, + 4 ] }, { "tile position": [ - 9, - 13 + 1, + 5 ] }, { "tile position": [ - 10, - 12 + 2, + 5 ] }, { "tile position": [ - 10, - 13 + 3, + 5 ] }, { "tile position": [ - 11, - 12 + 4, + 5 ] } ], "position": [ - 1100, - 1502 + 240.8369140625, + 1146.927978515625 ], - "rotation": -0.5999999642372131, + "rotation": -3.0500025749206543, "scale": [ 1.0, 1.0 ], "size": [ 500.0, - 500.0 + 1000.0 ], - "texture": "D:\\Projects\\DGame\\Assets\\Images\\house1.png" + "texture": "house1.png" }, { "has collision": true, - "name": "DummyName", + "name": "House_2", "occupied nodes": [ { "tile position": [ - 9, - 11 + 14, + 3 + ] + }, + { + "tile position": [ + 14, + 4 + ] + }, + { + "tile position": [ + 14, + 5 + ] + }, + { + "tile position": [ + 15, + 5 + ] + }, + { + "tile position": [ + 15, + 6 + ] + }, + { + "tile position": [ + 16, + 6 + ] + }, + { + "tile position": [ + 16, + 7 + ] + }, + { + "tile position": [ + 16, + 8 + ] + }, + { + "tile position": [ + 10, + 5 + ] + }, + { + "tile position": [ + 11, + 5 + ] + }, + { + "tile position": [ + 12, + 4 + ] + }, + { + "tile position": [ + 12, + 5 + ] + }, + { + "tile position": [ + 13, + 3 + ] + }, + { + "tile position": [ + 13, + 4 + ] + }, + { + "tile position": [ + 14, + 3 + ] + }, + { + "tile position": [ + 10, + 5 + ] + }, + { + "tile position": [ + 10, + 6 + ] + }, + { + "tile position": [ + 11, + 6 + ] + }, + { + "tile position": [ + 11, + 7 + ] + }, + { + "tile position": [ + 12, + 7 + ] + }, + { + "tile position": [ + 12, + 8 + ] + }, + { + "tile position": [ + 12, + 9 + ] + }, + { + "tile position": [ + 13, + 9 + ] + }, + { + "tile position": [ + 13, + 10 + ] + }, + { + "tile position": [ + 13, + 9 + ] + }, + { + "tile position": [ + 13, + 10 + ] + }, + { + "tile position": [ + 14, + 9 + ] + }, + { + "tile position": [ + 15, + 8 + ] + }, + { + "tile position": [ + 15, + 9 + ] + }, + { + "tile position": [ + 16, + 8 + ] + } + ], + "position": [ + 1762.0, + 895.0 + ], + "rotation": -0.550000011920929, + "scale": [ + 1.0, + 1.0 + ], + "size": [ + 500.0, + 647.0 + ], + "texture": "house1.png" + }, + { + "has collision": true, + "name": "House_3", + "occupied nodes": [ + { + "tile position": [ + 10, + 14 + ] + }, + { + "tile position": [ + 11, + 14 + ] + }, + { + "tile position": [ + 12, + 14 + ] + }, + { + "tile position": [ + 12, + 11 + ] + }, + { + "tile position": [ + 12, + 12 + ] + }, + { + "tile position": [ + 12, + 13 + ] + }, + { + "tile position": [ + 12, + 14 + ] + }, + { + "tile position": [ + 10, + 11 + ] + }, + { + "tile position": [ + 11, + 11 + ] + }, + { + "tile position": [ + 12, + 11 + ] + }, + { + "tile position": [ + 10, + 11 + ] + }, + { + "tile position": [ + 10, + 12 + ] + }, + { + "tile position": [ + 10, + 13 + ] + }, + { + "tile position": [ + 10, + 14 + ] + } + ], + "position": [ + 1465.0, + 1665.0 + ], + "rotation": 1.5749990940093994, + "scale": [ + 1.0, + 1.0 + ], + "size": [ + 406.0, + 346.0 + ], + "texture": "house1.png" + }, + { + "has collision": true, + "name": "DummyName", + "occupied nodes": [ + { + "tile position": [ + -1, + -1 + ] + }, + { + "tile position": [ + 12, + 0 + ] + }, + { + "tile position": [ + 13, + 0 + ] + }, + { + "tile position": [ + 13, + 1 + ] + }, + { + "tile position": [ + 14, + 1 + ] + }, + { + "tile position": [ + 14, + 2 + ] + }, + { + "tile position": [ + 15, + 2 + ] + }, + { + "tile position": [ + 15, + 3 + ] + }, + { + "tile position": [ + 16, + 3 + ] + }, + { + "tile position": [ + -1, + -1 + ] + }, + { + "tile position": [ + 7, + 3 + ] + }, + { + "tile position": [ + 7, + 4 + ] + }, + { + "tile position": [ + 8, + 2 + ] + }, + { + "tile position": [ + 8, + 3 + ] + }, + { + "tile position": [ + 9, + 1 + ] + }, + { + "tile position": [ + 9, + 2 + ] + }, + { + "tile position": [ + 10, + 0 + ] + }, + { + "tile position": [ + 10, + 1 + ] + }, + { + "tile position": [ + 11, + 0 + ] + }, + { + "tile position": [ + 6, + 4 + ] + }, + { + "tile position": [ + 7, + 4 + ] + }, + { + "tile position": [ + 7, + 5 + ] + }, + { + "tile position": [ + 8, + 5 + ] + }, + { + "tile position": [ + 8, + 6 + ] + }, + { + "tile position": [ + 9, + 6 + ] + }, + { + "tile position": [ + 9, + 7 + ] + }, + { + "tile position": [ + 10, + 7 + ] + }, + { + "tile position": [ + 10, + 8 + ] + }, + { + "tile position": [ + 11, + 8 + ] + }, + { + "tile position": [ + 11, + 8 + ] + }, + { + "tile position": [ + 12, + 7 + ] + }, + { + "tile position": [ + 12, + 8 + ] + }, + { + "tile position": [ + 13, + 6 + ] + }, + { + "tile position": [ + 13, + 7 + ] + }, + { + "tile position": [ + 14, + 5 + ] + }, + { + "tile position": [ + 14, + 6 + ] + }, + { + "tile position": [ + 15, + 4 + ] + }, + { + "tile position": [ + 15, + 5 + ] + }, + { + "tile position": [ + 16, + 3 + ] + }, + { + "tile position": [ + 16, + 4 + ] + } + ], + "position": [ + 1493.0, + 533.0 + ], + "rotation": -0.7999998331069946, + "scale": [ + 1.0, + 1.0 + ], + "size": [ + 905.0, + 797.0 + ], + "texture": "house1.png" + }, + { + "has collision": true, + "name": "DummyName", + "occupied nodes": [ + { + "tile position": [ + -1, + -1 + ] + }, + { + "tile position": [ + 0, + 0 + ] + }, + { + "tile position": [ + 0, + 1 + ] + }, + { + "tile position": [ + 1, + 0 + ] + }, + { + "tile position": [ + -1, + -1 + ] + }, + { + "tile position": [ + 0, + 5 + ] + }, + { + "tile position": [ + 0, + 6 + ] + }, + { + "tile position": [ + 1, + 6 + ] + }, + { + "tile position": [ + 1, + 7 + ] + }, + { + "tile position": [ + 1, + 8 + ] + }, + { + "tile position": [ + 2, + 8 + ] + }, + { + "tile position": [ + 2, + 8 + ] + }, + { + "tile position": [ + 3, + 7 + ] + }, + { + "tile position": [ + 3, + 8 + ] + }, + { + "tile position": [ + 4, + 7 + ] + }, + { + "tile position": [ + 5, + 6 + ] + }, + { + "tile position": [ + 5, + 7 + ] + }, + { + "tile position": [ + 6, + 5 + ] + }, + { + "tile position": [ + 6, + 6 + ] + }, + { + "tile position": [ + 7, + 4 + ] + }, + { + "tile position": [ + 7, + 5 + ] + }, + { + "tile position": [ + 8, + 4 + ] + }, + { + "tile position": [ + -1, + -1 + ] + }, + { + "tile position": [ + 5, + 0 + ] + }, + { + "tile position": [ + 6, + 0 + ] + }, + { + "tile position": [ + 6, + 1 + ] + }, + { + "tile position": [ + 7, + 1 + ] + }, + { + "tile position": [ + 7, + 2 + ] + }, + { + "tile position": [ + 7, + 3 + ] + }, + { + "tile position": [ + 8, + 3 + ] + }, + { + "tile position": [ + 8, + 4 + ] + } + ], + "position": [ + 421.5709533691406, + 444.7692565917969 + ], + "rotation": 4.025006294250488, + "scale": [ + 1.0, + 1.0 + ], + "size": [ + 1000.0, + 1000.0 + ], + "texture": "house1.png" + }, + { + "has collision": true, + "name": "DummyName", + "occupied nodes": [ + { + "tile position": [ + -1, + -1 + ] + }, + { + "tile position": [ + 4, + 21 + ] + }, + { + "tile position": [ + 4, + 22 + ] + }, + { + "tile position": [ + 5, + 22 + ] + }, + { + "tile position": [ + 6, + 22 + ] + }, + { + "tile position": [ + 6, + 23 + ] + }, + { + "tile position": [ + 7, + 23 + ] + }, + { + "tile position": [ + 8, + 23 + ] + }, + { + "tile position": [ + -1, + -1 + ] + }, + { + "tile position": [ + 12, + 22 + ] + }, + { + "tile position": [ + 12, + 23 + ] + }, + { + "tile position": [ + 13, + 22 + ] + }, + { + "tile position": [ + 6, + 18 + ] + }, + { + "tile position": [ + 7, + 18 + ] + }, + { + "tile position": [ + 7, + 19 + ] + }, + { + "tile position": [ + 8, + 19 + ] + }, + { + "tile position": [ + 9, + 19 + ] + }, + { + "tile position": [ + 9, + 20 + ] + }, + { + "tile position": [ + 10, + 20 + ] + }, + { + "tile position": [ + 10, + 21 + ] + }, + { + "tile position": [ + 11, + 21 + ] + }, + { + "tile position": [ + 12, + 21 + ] + }, + { + "tile position": [ + 12, + 22 + ] + }, + { + "tile position": [ + 13, + 22 + ] + }, + { + "tile position": [ + 4, + 21 + ] + }, + { + "tile position": [ + 5, + 19 + ] + }, + { + "tile position": [ + 5, + 20 + ] + }, + { + "tile position": [ + 5, + 21 + ] + }, + { + "tile position": [ + 6, + 18 + ] + }, + { + "tile position": [ + 6, + 19 + ] + } + ], + "position": [ + 1133.0, + 2832.0 + ], + "rotation": 2.1249990463256836, + "scale": [ + 1.0, + 1.0 + ], + "size": [ + 500.0, + 946.0 + ], + "texture": "house1.png" + }, + { + "has collision": true, + "name": "DummyName", + "occupied nodes": [ + { + "tile position": [ + 17, + 7 + ] + }, + { + "tile position": [ + 17, + 8 + ] + }, + { + "tile position": [ + 17, + 9 + ] + }, + { + "tile position": [ + 17, + 10 + ] + }, + { + "tile position": [ + 17, + 11 + ] + }, + { + "tile position": [ + 17, + 12 + ] + }, + { + "tile position": [ + 17, + 13 + ] + }, + { + "tile position": [ + 17, + 14 + ] + }, + { + "tile position": [ + 10, + 6 + ] + }, + { + "tile position": [ + 11, + 6 + ] + }, + { + "tile position": [ + 12, + 6 + ] + }, + { + "tile position": [ + 13, + 6 + ] + }, + { + "tile position": [ + 14, + 6 + ] + }, + { + "tile position": [ + 14, + 7 + ] + }, + { + "tile position": [ + 15, + 7 + ] + }, + { + "tile position": [ + 16, + 7 + ] + }, + { + "tile position": [ + 17, + 7 + ] + }, + { + "tile position": [ + 9, + 12 + ] + }, + { + "tile position": [ + 9, + 13 + ] + }, + { + "tile position": [ + 9, + 14 + ] + }, + { + "tile position": [ + 10, + 6 + ] + }, + { + "tile position": [ + 10, + 7 + ] + }, + { + "tile position": [ + 10, + 8 + ] + }, + { + "tile position": [ + 10, + 9 + ] + }, + { + "tile position": [ + 10, + 10 + ] + }, + { + "tile position": [ + 10, + 11 + ] + }, + { + "tile position": [ + 10, + 12 + ] + }, + { + "tile position": [ + 9, + 14 + ] + }, + { + "tile position": [ + 10, + 14 + ] + }, + { + "tile position": [ + 11, + 14 + ] + }, + { + "tile position": [ + 12, + 14 + ] + }, + { + "tile position": [ + 13, + 14 + ] + }, + { + "tile position": [ + 14, + 14 + ] + }, + { + "tile position": [ + 15, + 14 + ] + }, + { + "tile position": [ + 16, + 14 + ] + }, + { + "tile position": [ + 17, + 14 + ] + } + ], + "position": [ + 1785.8309326171875, + 1393.478515625 + ], + "rotation": 0.025000033900141716, + "scale": [ + 1.0, + 1.0 + ], + "size": [ + 1000.0, + 1000.0 + ], + "texture": "house1.png" + }, + { + "has collision": true, + "name": "DummyName", + "occupied nodes": [ + { + "tile position": [ + -1, + -1 + ] + }, + { + "tile position": [ + 0, + 22 + ] + }, + { + "tile position": [ + 0, + 23 + ] + }, + { + "tile position": [ + -1, + -1 + ] + }, + { + "tile position": [ + 4, + 23 + ] + }, + { + "tile position": [ + 5, + 23 + ] + }, + { + "tile position": [ + 6, + 22 + ] + }, + { + "tile position": [ + 7, + 21 + ] + }, + { + "tile position": [ + 7, + 22 + ] + }, + { + "tile position": [ + 8, + 21 + ] + }, + { + "tile position": [ + 3, + 14 + ] + }, + { + "tile position": [ + 3, + 15 + ] + }, + { + "tile position": [ + 4, + 15 + ] + }, + { + "tile position": [ + 4, + 16 + ] + }, + { + "tile position": [ + 5, + 16 + ] + }, + { + "tile position": [ + 5, + 17 + ] + }, + { + "tile position": [ + 6, + 17 + ] + }, + { + "tile position": [ + 6, + 18 + ] + }, + { + "tile position": [ + 6, + 19 + ] + }, + { + "tile position": [ + 7, + 19 + ] + }, + { + "tile position": [ + 7, + 20 + ] + }, + { + "tile position": [ + 8, + 20 + ] + }, + { + "tile position": [ + 8, + 21 + ] + }, + { + "tile position": [ + -1, + -1 + ] + }, + { + "tile position": [ + 0, + 16 + ] + }, + { + "tile position": [ + 0, + 17 + ] + }, + { + "tile position": [ + 1, + 16 + ] + }, + { + "tile position": [ + 2, + 15 + ] + }, + { + "tile position": [ + 2, + 16 + ] + }, + { + "tile position": [ + 3, + 14 + ] + }, + { + "tile position": [ + 3, + 15 + ] + } + ], + "position": [ + 378.2022399902344, + 2609.970703125 + ], + "rotation": 2.500000476837158, + "scale": [ + 1.0, + 1.0 + ], + "size": [ + 1000.0, + 1000.0 + ], + "texture": "house1.png" + }, + { + "has collision": true, + "name": "DummyName", + "occupied nodes": [ + { + "tile position": [ + -1, + -1 + ] + }, + { + "tile position": [ + -1, + -1 + ] + }, + { + "tile position": [ + 0, + 16 + ] + }, + { + "tile position": [ + 0, + 17 ] }, { "tile position": [ - 9, - 12 + 1, + 17 ] }, { "tile position": [ - 9, - 13 + 2, + 17 ] }, { "tile position": [ - 9, - 14 + 2, + 18 ] }, { "tile position": [ - 9, - 15 + 2, + 17 ] }, { "tile position": [ - 5, - 11 + 2, + 18 ] }, { "tile position": [ - 6, - 11 + 3, + 16 ] }, { "tile position": [ - 7, - 11 + 3, + 17 ] }, { "tile position": [ - 8, - 11 + 4, + 15 ] }, { "tile position": [ - 9, - 11 + 4, + 16 ] }, { "tile position": [ - 5, - 11 + -1, + -1 ] }, { "tile position": [ - 5, - 12 + 0, + 11 ] }, { "tile position": [ - 5, - 13 + 0, + 12 ] }, { "tile position": [ - 5, - 14 + 1, + 12 ] }, { "tile position": [ - 5, - 15 + 2, + 12 ] }, { "tile position": [ - 5, - 15 + 2, + 13 ] }, { "tile position": [ - 6, - 15 + 3, + 13 ] }, { "tile position": [ - 7, - 15 + 3, + 14 ] }, { "tile position": [ - 8, - 15 + 4, + 14 ] }, { "tile position": [ - 9, + 4, 15 ] } ], "position": [ - 950, - 1677 + 155.54559326171875, + 1897.436767578125 ], - "rotation": 0.0, + "rotation": -2.500000476837158, "scale": [ 1.0, 1.0 ], "size": [ - 500.0, + 824.0, 500.0 ], - "texture": "D:\\Projects\\DGame\\Assets\\Images\\house1.png" + "texture": "house1.png" }, { "has collision": true, @@ -548,103 +1981,139 @@ "occupied nodes": [ { "tile position": [ - 9, - 15 + -1, + -1 ] }, { "tile position": [ - 9, - 16 + 14, + 23 ] }, { "tile position": [ - 9, - 17 + 15, + 23 ] }, { "tile position": [ - 6, - 15 + 16, + 23 ] }, { "tile position": [ - 7, - 15 + 16, + 19 ] }, { "tile position": [ - 8, - 15 + 16, + 20 ] }, { "tile position": [ - 9, - 15 + 16, + 21 ] }, { "tile position": [ - 6, - 15 + 16, + 22 ] }, { "tile position": [ - 6, - 16 + 16, + 23 ] }, { "tile position": [ - 6, - 17 + 12, + 20 ] }, { "tile position": [ - 6, - 17 + 13, + 20 ] }, { "tile position": [ - 7, - 17 + 14, + 20 ] }, { "tile position": [ - 8, - 17 + 15, + 19 ] }, { "tile position": [ - 9, - 17 + 15, + 20 + ] + }, + { + "tile position": [ + 16, + 19 + ] + }, + { + "tile position": [ + -1, + -1 + ] + }, + { + "tile position": [ + 12, + 20 + ] + }, + { + "tile position": [ + 12, + 21 + ] + }, + { + "tile position": [ + 12, + 22 + ] + }, + { + "tile position": [ + 12, + 23 ] } ], "position": [ - 1006, - 2114 + 1848.8544921875, + 2828.10986328125 ], - "rotation": 0.0, + "rotation": 1.3999992609024048, "scale": [ 1.0, 1.0 ], "size": [ - 406.0, - 346.0 + 500.0, + 500.0 ], - "texture": "D:\\Projects\\DGame\\Assets\\Images\\house1.png" + "texture": "house1.png" } ], "PATHFINDER": { @@ -659,7 +2128,10 @@ 0 ], "id": 0, - "occupied": false, + "nodesOccupying": [ + 12884901897 + ], + "occupied": true, "position": [ 64.0, 64.0 @@ -676,7 +2148,10 @@ 0 ], "id": 1, - "occupied": false, + "nodesOccupying": [ + 12884901897 + ], + "occupied": true, "position": [ 192.0, 64.0 @@ -693,6 +2168,7 @@ 0 ], "id": 2, + "nodesOccupying": [], "occupied": false, "position": [ 320.0, @@ -710,6 +2186,7 @@ 0 ], "id": 3, + "nodesOccupying": [], "occupied": false, "position": [ 448.0, @@ -727,6 +2204,7 @@ 0 ], "id": 4, + "nodesOccupying": [], "occupied": false, "position": [ 576.0, @@ -744,7 +2222,11 @@ 0 ], "id": 5, - "occupied": false, + "nodesOccupying": [ + 12884901897, + 12884901892 + ], + "occupied": true, "position": [ 704.0, 64.0 @@ -761,7 +2243,10 @@ 0 ], "id": 6, - "occupied": false, + "nodesOccupying": [ + 12884901897 + ], + "occupied": true, "position": [ 832.0, 64.0 @@ -778,6 +2263,7 @@ 0 ], "id": 7, + "nodesOccupying": [], "occupied": false, "position": [ 960.0, @@ -795,6 +2281,7 @@ 0 ], "id": 8, + "nodesOccupying": [], "occupied": false, "position": [ 1088.0, @@ -812,7 +2299,10 @@ 0 ], "id": 9, - "occupied": false, + "nodesOccupying": [ + 12884901892 + ], + "occupied": true, "position": [ 1216.0, 64.0 @@ -829,7 +2319,10 @@ 0 ], "id": 10, - "occupied": false, + "nodesOccupying": [ + 12884901896 + ], + "occupied": true, "position": [ 1344.0, 64.0 @@ -846,7 +2339,10 @@ 0 ], "id": 11, - "occupied": false, + "nodesOccupying": [ + 12884901896 + ], + "occupied": true, "position": [ 1472.0, 64.0 @@ -863,7 +2359,10 @@ 0 ], "id": 12, - "occupied": false, + "nodesOccupying": [ + 12884901896 + ], + "occupied": true, "position": [ 1600.0, 64.0 @@ -880,7 +2379,10 @@ 0 ], "id": 13, - "occupied": false, + "nodesOccupying": [ + 12884901896 + ], + "occupied": true, "position": [ 1728.0, 64.0 @@ -897,6 +2399,7 @@ 0 ], "id": 14, + "nodesOccupying": [], "occupied": false, "position": [ 1856.0, @@ -914,6 +2417,7 @@ 0 ], "id": 15, + "nodesOccupying": [], "occupied": false, "position": [ 1984.0, @@ -931,6 +2435,7 @@ 0 ], "id": 16, + "nodesOccupying": [], "occupied": false, "position": [ 2112.0, @@ -948,6 +2453,7 @@ 0 ], "id": 17, + "nodesOccupying": [], "occupied": false, "position": [ 2240.0, @@ -965,6 +2471,7 @@ 0 ], "id": 18, + "nodesOccupying": [], "occupied": false, "position": [ 2368.0, @@ -982,6 +2489,7 @@ 0 ], "id": 19, + "nodesOccupying": [], "occupied": false, "position": [ 2496.0, @@ -999,6 +2507,7 @@ 0 ], "id": 20, + "nodesOccupying": [], "occupied": false, "position": [ 2624.0, @@ -1016,6 +2525,7 @@ 0 ], "id": 21, + "nodesOccupying": [], "occupied": false, "position": [ 2752.0, @@ -1033,6 +2543,7 @@ 0 ], "id": 22, + "nodesOccupying": [], "occupied": false, "position": [ 2880.0, @@ -1049,6 +2560,7 @@ 0 ], "id": 23, + "nodesOccupying": [], "occupied": false, "position": [ 3008.0, @@ -1066,7 +2578,10 @@ 1 ], "id": 24, - "occupied": false, + "nodesOccupying": [ + 12884901897 + ], + "occupied": true, "position": [ 64.0, 192.0 @@ -1084,6 +2599,7 @@ 1 ], "id": 25, + "nodesOccupying": [], "occupied": false, "position": [ 192.0, @@ -1102,6 +2618,7 @@ 1 ], "id": 26, + "nodesOccupying": [], "occupied": false, "position": [ 320.0, @@ -1120,6 +2637,7 @@ 1 ], "id": 27, + "nodesOccupying": [], "occupied": false, "position": [ 448.0, @@ -1138,6 +2656,7 @@ 1 ], "id": 28, + "nodesOccupying": [], "occupied": false, "position": [ 576.0, @@ -1156,7 +2675,10 @@ 1 ], "id": 29, - "occupied": false, + "nodesOccupying": [ + 12884901892 + ], + "occupied": true, "position": [ 704.0, 192.0 @@ -1174,7 +2696,10 @@ 1 ], "id": 30, - "occupied": false, + "nodesOccupying": [ + 12884901897 + ], + "occupied": true, "position": [ 832.0, 192.0 @@ -1192,7 +2717,10 @@ 1 ], "id": 31, - "occupied": false, + "nodesOccupying": [ + 12884901897 + ], + "occupied": true, "position": [ 960.0, 192.0 @@ -1210,6 +2738,7 @@ 1 ], "id": 32, + "nodesOccupying": [], "occupied": false, "position": [ 1088.0, @@ -1228,7 +2757,11 @@ 1 ], "id": 33, - "occupied": false, + "nodesOccupying": [ + 12884901896, + 12884901892 + ], + "occupied": true, "position": [ 1216.0, 192.0 @@ -1246,7 +2779,10 @@ 1 ], "id": 34, - "occupied": false, + "nodesOccupying": [ + 12884901896 + ], + "occupied": true, "position": [ 1344.0, 192.0 @@ -1264,6 +2800,7 @@ 1 ], "id": 35, + "nodesOccupying": [], "occupied": false, "position": [ 1472.0, @@ -1282,6 +2819,7 @@ 1 ], "id": 36, + "nodesOccupying": [], "occupied": false, "position": [ 1600.0, @@ -1300,7 +2838,10 @@ 1 ], "id": 37, - "occupied": false, + "nodesOccupying": [ + 12884901896 + ], + "occupied": true, "position": [ 1728.0, 192.0 @@ -1318,7 +2859,10 @@ 1 ], "id": 38, - "occupied": false, + "nodesOccupying": [ + 12884901896 + ], + "occupied": true, "position": [ 1856.0, 192.0 @@ -1336,6 +2880,7 @@ 1 ], "id": 39, + "nodesOccupying": [], "occupied": false, "position": [ 1984.0, @@ -1354,6 +2899,7 @@ 1 ], "id": 40, + "nodesOccupying": [], "occupied": false, "position": [ 2112.0, @@ -1372,6 +2918,7 @@ 1 ], "id": 41, + "nodesOccupying": [], "occupied": false, "position": [ 2240.0, @@ -1390,6 +2937,7 @@ 1 ], "id": 42, + "nodesOccupying": [], "occupied": false, "position": [ 2368.0, @@ -1408,6 +2956,7 @@ 1 ], "id": 43, + "nodesOccupying": [], "occupied": false, "position": [ 2496.0, @@ -1426,6 +2975,7 @@ 1 ], "id": 44, + "nodesOccupying": [], "occupied": false, "position": [ 2624.0, @@ -1444,6 +2994,7 @@ 1 ], "id": 45, + "nodesOccupying": [], "occupied": false, "position": [ 2752.0, @@ -1462,6 +3013,7 @@ 1 ], "id": 46, + "nodesOccupying": [], "occupied": false, "position": [ 2880.0, @@ -1479,6 +3031,7 @@ 1 ], "id": 47, + "nodesOccupying": [], "occupied": false, "position": [ 3008.0, @@ -1496,6 +3049,7 @@ 2 ], "id": 48, + "nodesOccupying": [], "occupied": false, "position": [ 64.0, @@ -1514,6 +3068,7 @@ 2 ], "id": 49, + "nodesOccupying": [], "occupied": false, "position": [ 192.0, @@ -1532,6 +3087,7 @@ 2 ], "id": 50, + "nodesOccupying": [], "occupied": false, "position": [ 320.0, @@ -1550,6 +3106,7 @@ 2 ], "id": 51, + "nodesOccupying": [], "occupied": false, "position": [ 448.0, @@ -1568,6 +3125,7 @@ 2 ], "id": 52, + "nodesOccupying": [], "occupied": false, "position": [ 576.0, @@ -1586,7 +3144,10 @@ 2 ], "id": 53, - "occupied": false, + "nodesOccupying": [ + 12884901892 + ], + "occupied": true, "position": [ 704.0, 320.0 @@ -1604,6 +3165,7 @@ 2 ], "id": 54, + "nodesOccupying": [], "occupied": false, "position": [ 832.0, @@ -1622,7 +3184,10 @@ 2 ], "id": 55, - "occupied": false, + "nodesOccupying": [ + 12884901897 + ], + "occupied": true, "position": [ 960.0, 320.0 @@ -1640,7 +3205,10 @@ 2 ], "id": 56, - "occupied": false, + "nodesOccupying": [ + 12884901896 + ], + "occupied": true, "position": [ 1088.0, 320.0 @@ -1658,7 +3226,11 @@ 2 ], "id": 57, - "occupied": false, + "nodesOccupying": [ + 12884901896, + 12884901892 + ], + "occupied": true, "position": [ 1216.0, 320.0 @@ -1676,6 +3248,7 @@ 2 ], "id": 58, + "nodesOccupying": [], "occupied": false, "position": [ 1344.0, @@ -1694,6 +3267,7 @@ 2 ], "id": 59, + "nodesOccupying": [], "occupied": false, "position": [ 1472.0, @@ -1712,6 +3286,7 @@ 2 ], "id": 60, + "nodesOccupying": [], "occupied": false, "position": [ 1600.0, @@ -1730,6 +3305,7 @@ 2 ], "id": 61, + "nodesOccupying": [], "occupied": false, "position": [ 1728.0, @@ -1748,7 +3324,10 @@ 2 ], "id": 62, - "occupied": false, + "nodesOccupying": [ + 12884901896 + ], + "occupied": true, "position": [ 1856.0, 320.0 @@ -1766,7 +3345,10 @@ 2 ], "id": 63, - "occupied": false, + "nodesOccupying": [ + 12884901896 + ], + "occupied": true, "position": [ 1984.0, 320.0 @@ -1784,6 +3366,7 @@ 2 ], "id": 64, + "nodesOccupying": [], "occupied": false, "position": [ 2112.0, @@ -1802,6 +3385,7 @@ 2 ], "id": 65, + "nodesOccupying": [], "occupied": false, "position": [ 2240.0, @@ -1820,6 +3404,7 @@ 2 ], "id": 66, + "nodesOccupying": [], "occupied": false, "position": [ 2368.0, @@ -1838,6 +3423,7 @@ 2 ], "id": 67, + "nodesOccupying": [], "occupied": false, "position": [ 2496.0, @@ -1856,6 +3442,7 @@ 2 ], "id": 68, + "nodesOccupying": [], "occupied": false, "position": [ 2624.0, @@ -1874,6 +3461,7 @@ 2 ], "id": 69, + "nodesOccupying": [], "occupied": false, "position": [ 2752.0, @@ -1892,6 +3480,7 @@ 2 ], "id": 70, + "nodesOccupying": [], "occupied": false, "position": [ 2880.0, @@ -1909,6 +3498,7 @@ 2 ], "id": 71, + "nodesOccupying": [], "occupied": false, "position": [ 3008.0, @@ -1926,6 +3516,7 @@ 3 ], "id": 72, + "nodesOccupying": [], "occupied": false, "position": [ 64.0, @@ -1944,6 +3535,7 @@ 3 ], "id": 73, + "nodesOccupying": [], "occupied": false, "position": [ 192.0, @@ -1962,6 +3554,7 @@ 3 ], "id": 74, + "nodesOccupying": [], "occupied": false, "position": [ 320.0, @@ -1980,6 +3573,7 @@ 3 ], "id": 75, + "nodesOccupying": [], "occupied": false, "position": [ 448.0, @@ -1998,6 +3592,7 @@ 3 ], "id": 76, + "nodesOccupying": [], "occupied": false, "position": [ 576.0, @@ -2016,7 +3611,10 @@ 3 ], "id": 77, - "occupied": false, + "nodesOccupying": [ + 12884901892 + ], + "occupied": true, "position": [ 704.0, 448.0 @@ -2034,6 +3632,7 @@ 3 ], "id": 78, + "nodesOccupying": [], "occupied": false, "position": [ 832.0, @@ -2052,7 +3651,11 @@ 3 ], "id": 79, - "occupied": false, + "nodesOccupying": [ + 12884901897, + 12884901896 + ], + "occupied": true, "position": [ 960.0, 448.0 @@ -2070,7 +3673,11 @@ 3 ], "id": 80, - "occupied": false, + "nodesOccupying": [ + 12884901897, + 12884901896 + ], + "occupied": true, "position": [ 1088.0, 448.0 @@ -2088,7 +3695,10 @@ 3 ], "id": 81, - "occupied": false, + "nodesOccupying": [ + 12884901892 + ], + "occupied": true, "position": [ 1216.0, 448.0 @@ -2106,6 +3716,7 @@ 3 ], "id": 82, + "nodesOccupying": [], "occupied": false, "position": [ 1344.0, @@ -2124,6 +3735,7 @@ 3 ], "id": 83, + "nodesOccupying": [], "occupied": false, "position": [ 1472.0, @@ -2142,6 +3754,7 @@ 3 ], "id": 84, + "nodesOccupying": [], "occupied": false, "position": [ 1600.0, @@ -2160,7 +3773,10 @@ 3 ], "id": 85, - "occupied": false, + "nodesOccupying": [ + 12884901894 + ], + "occupied": true, "position": [ 1728.0, 448.0 @@ -2178,7 +3794,11 @@ 3 ], "id": 86, - "occupied": false, + "nodesOccupying": [ + 12884901894, + 12884901894 + ], + "occupied": true, "position": [ 1856.0, 448.0 @@ -2196,7 +3816,10 @@ 3 ], "id": 87, - "occupied": false, + "nodesOccupying": [ + 12884901896 + ], + "occupied": true, "position": [ 1984.0, 448.0 @@ -2214,7 +3837,11 @@ 3 ], "id": 88, - "occupied": false, + "nodesOccupying": [ + 12884901896, + 12884901896 + ], + "occupied": true, "position": [ 2112.0, 448.0 @@ -2232,6 +3859,7 @@ 3 ], "id": 89, + "nodesOccupying": [], "occupied": false, "position": [ 2240.0, @@ -2250,6 +3878,7 @@ 3 ], "id": 90, + "nodesOccupying": [], "occupied": false, "position": [ 2368.0, @@ -2268,6 +3897,7 @@ 3 ], "id": 91, + "nodesOccupying": [], "occupied": false, "position": [ 2496.0, @@ -2286,6 +3916,7 @@ 3 ], "id": 92, + "nodesOccupying": [], "occupied": false, "position": [ 2624.0, @@ -2304,6 +3935,7 @@ 3 ], "id": 93, + "nodesOccupying": [], "occupied": false, "position": [ 2752.0, @@ -2322,6 +3954,7 @@ 3 ], "id": 94, + "nodesOccupying": [], "occupied": false, "position": [ 2880.0, @@ -2339,6 +3972,7 @@ 3 ], "id": 95, + "nodesOccupying": [], "occupied": false, "position": [ 3008.0, @@ -2356,7 +3990,11 @@ 4 ], "id": 96, - "occupied": false, + "nodesOccupying": [ + 12884901893, + 12884901893 + ], + "occupied": true, "position": [ 64.0, 576.0 @@ -2374,7 +4012,10 @@ 4 ], "id": 97, - "occupied": false, + "nodesOccupying": [ + 12884901893 + ], + "occupied": true, "position": [ 192.0, 576.0 @@ -2392,6 +4033,7 @@ 4 ], "id": 98, + "nodesOccupying": [], "occupied": false, "position": [ 320.0, @@ -2410,6 +4052,7 @@ 4 ], "id": 99, + "nodesOccupying": [], "occupied": false, "position": [ 448.0, @@ -2428,6 +4071,7 @@ 4 ], "id": 100, + "nodesOccupying": [], "occupied": false, "position": [ 576.0, @@ -2446,7 +4090,10 @@ 4 ], "id": 101, - "occupied": false, + "nodesOccupying": [ + 12884901892 + ], + "occupied": true, "position": [ 704.0, 576.0 @@ -2464,7 +4111,10 @@ 4 ], "id": 102, - "occupied": false, + "nodesOccupying": [ + 12884901896 + ], + "occupied": true, "position": [ 832.0, 576.0 @@ -2482,7 +4132,12 @@ 4 ], "id": 103, - "occupied": false, + "nodesOccupying": [ + 12884901897, + 12884901896, + 12884901896 + ], + "occupied": true, "position": [ 960.0, 576.0 @@ -2500,7 +4155,11 @@ 4 ], "id": 104, - "occupied": false, + "nodesOccupying": [ + 12884901897, + 12884901897 + ], + "occupied": true, "position": [ 1088.0, 576.0 @@ -2518,7 +4177,10 @@ 4 ], "id": 105, - "occupied": false, + "nodesOccupying": [ + 12884901892 + ], + "occupied": true, "position": [ 1216.0, 576.0 @@ -2536,6 +4198,7 @@ 4 ], "id": 106, + "nodesOccupying": [], "occupied": false, "position": [ 1344.0, @@ -2554,6 +4217,7 @@ 4 ], "id": 107, + "nodesOccupying": [], "occupied": false, "position": [ 1472.0, @@ -2572,7 +4236,10 @@ 4 ], "id": 108, - "occupied": false, + "nodesOccupying": [ + 12884901894 + ], + "occupied": true, "position": [ 1600.0, 576.0 @@ -2590,7 +4257,10 @@ 4 ], "id": 109, - "occupied": false, + "nodesOccupying": [ + 12884901894 + ], + "occupied": true, "position": [ 1728.0, 576.0 @@ -2608,7 +4278,10 @@ 4 ], "id": 110, - "occupied": false, + "nodesOccupying": [ + 12884901894 + ], + "occupied": true, "position": [ 1856.0, 576.0 @@ -2626,7 +4299,10 @@ 4 ], "id": 111, - "occupied": false, + "nodesOccupying": [ + 12884901896 + ], + "occupied": true, "position": [ 1984.0, 576.0 @@ -2644,7 +4320,10 @@ 4 ], "id": 112, - "occupied": false, + "nodesOccupying": [ + 12884901896 + ], + "occupied": true, "position": [ 2112.0, 576.0 @@ -2662,6 +4341,7 @@ 4 ], "id": 113, + "nodesOccupying": [], "occupied": false, "position": [ 2240.0, @@ -2680,6 +4360,7 @@ 4 ], "id": 114, + "nodesOccupying": [], "occupied": false, "position": [ 2368.0, @@ -2698,6 +4379,7 @@ 4 ], "id": 115, + "nodesOccupying": [], "occupied": false, "position": [ 2496.0, @@ -2716,6 +4398,7 @@ 4 ], "id": 116, + "nodesOccupying": [], "occupied": false, "position": [ 2624.0, @@ -2734,6 +4417,7 @@ 4 ], "id": 117, + "nodesOccupying": [], "occupied": false, "position": [ 2752.0, @@ -2752,6 +4436,7 @@ 4 ], "id": 118, + "nodesOccupying": [], "occupied": false, "position": [ 2880.0, @@ -2769,6 +4454,7 @@ 4 ], "id": 119, + "nodesOccupying": [], "occupied": false, "position": [ 3008.0, @@ -2786,7 +4472,11 @@ 5 ], "id": 120, - "occupied": false, + "nodesOccupying": [ + 12884901897, + 12884901893 + ], + "occupied": true, "position": [ 64.0, 704.0 @@ -2804,7 +4494,10 @@ 5 ], "id": 121, - "occupied": false, + "nodesOccupying": [ + 12884901893 + ], + "occupied": true, "position": [ 192.0, 704.0 @@ -2822,7 +4515,10 @@ 5 ], "id": 122, - "occupied": false, + "nodesOccupying": [ + 12884901893 + ], + "occupied": true, "position": [ 320.0, 704.0 @@ -2840,7 +4536,10 @@ 5 ], "id": 123, - "occupied": false, + "nodesOccupying": [ + 12884901893 + ], + "occupied": true, "position": [ 448.0, 704.0 @@ -2858,7 +4557,11 @@ 5 ], "id": 124, - "occupied": false, + "nodesOccupying": [ + 12884901893, + 12884901893 + ], + "occupied": true, "position": [ 576.0, 704.0 @@ -2876,7 +4579,10 @@ 5 ], "id": 125, - "occupied": false, + "nodesOccupying": [ + 12884901892 + ], + "occupied": true, "position": [ 704.0, 704.0 @@ -2894,7 +4600,10 @@ 5 ], "id": 126, - "occupied": false, + "nodesOccupying": [ + 12884901897 + ], + "occupied": true, "position": [ 832.0, 704.0 @@ -2912,7 +4621,11 @@ 5 ], "id": 127, - "occupied": false, + "nodesOccupying": [ + 12884901897, + 12884901896 + ], + "occupied": true, "position": [ 960.0, 704.0 @@ -2930,7 +4643,10 @@ 5 ], "id": 128, - "occupied": false, + "nodesOccupying": [ + 12884901896 + ], + "occupied": true, "position": [ 1088.0, 704.0 @@ -2948,7 +4664,10 @@ 5 ], "id": 129, - "occupied": false, + "nodesOccupying": [ + 12884901892 + ], + "occupied": true, "position": [ 1216.0, 704.0 @@ -2966,7 +4685,11 @@ 5 ], "id": 130, - "occupied": false, + "nodesOccupying": [ + 12884901894, + 12884901894 + ], + "occupied": true, "position": [ 1344.0, 704.0 @@ -2984,7 +4707,10 @@ 5 ], "id": 131, - "occupied": false, + "nodesOccupying": [ + 12884901894 + ], + "occupied": true, "position": [ 1472.0, 704.0 @@ -3002,7 +4728,10 @@ 5 ], "id": 132, - "occupied": false, + "nodesOccupying": [ + 12884901894 + ], + "occupied": true, "position": [ 1600.0, 704.0 @@ -3020,6 +4749,7 @@ 5 ], "id": 133, + "nodesOccupying": [], "occupied": false, "position": [ 1728.0, @@ -3038,7 +4768,11 @@ 5 ], "id": 134, - "occupied": false, + "nodesOccupying": [ + 12884901896, + 12884901894 + ], + "occupied": true, "position": [ 1856.0, 704.0 @@ -3056,7 +4790,11 @@ 5 ], "id": 135, - "occupied": false, + "nodesOccupying": [ + 12884901896, + 12884901894 + ], + "occupied": true, "position": [ 1984.0, 704.0 @@ -3074,6 +4812,7 @@ 5 ], "id": 136, + "nodesOccupying": [], "occupied": false, "position": [ 2112.0, @@ -3092,6 +4831,7 @@ 5 ], "id": 137, + "nodesOccupying": [], "occupied": false, "position": [ 2240.0, @@ -3110,6 +4850,7 @@ 5 ], "id": 138, + "nodesOccupying": [], "occupied": false, "position": [ 2368.0, @@ -3128,6 +4869,7 @@ 5 ], "id": 139, + "nodesOccupying": [], "occupied": false, "position": [ 2496.0, @@ -3146,6 +4888,7 @@ 5 ], "id": 140, + "nodesOccupying": [], "occupied": false, "position": [ 2624.0, @@ -3164,6 +4907,7 @@ 5 ], "id": 141, + "nodesOccupying": [], "occupied": false, "position": [ 2752.0, @@ -3182,6 +4926,7 @@ 5 ], "id": 142, + "nodesOccupying": [], "occupied": false, "position": [ 2880.0, @@ -3199,6 +4944,7 @@ 5 ], "id": 143, + "nodesOccupying": [], "occupied": false, "position": [ 3008.0, @@ -3216,7 +4962,11 @@ 6 ], "id": 144, - "occupied": false, + "nodesOccupying": [ + 12884901897, + 12884901893 + ], + "occupied": true, "position": [ 64.0, 832.0 @@ -3234,7 +4984,10 @@ 6 ], "id": 145, - "occupied": false, + "nodesOccupying": [ + 12884901897 + ], + "occupied": true, "position": [ 192.0, 832.0 @@ -3252,6 +5005,7 @@ 6 ], "id": 146, + "nodesOccupying": [], "occupied": false, "position": [ 320.0, @@ -3270,6 +5024,7 @@ 6 ], "id": 147, + "nodesOccupying": [], "occupied": false, "position": [ 448.0, @@ -3288,7 +5043,10 @@ 6 ], "id": 148, - "occupied": false, + "nodesOccupying": [ + 12884901893 + ], + "occupied": true, "position": [ 576.0, 832.0 @@ -3306,7 +5064,12 @@ 6 ], "id": 149, - "occupied": false, + "nodesOccupying": [ + 12884901897, + 12884901892, + 12884901892 + ], + "occupied": true, "position": [ 704.0, 832.0 @@ -3324,7 +5087,11 @@ 6 ], "id": 150, - "occupied": false, + "nodesOccupying": [ + 12884901897, + 12884901892 + ], + "occupied": true, "position": [ 832.0, 832.0 @@ -3342,7 +5109,10 @@ 6 ], "id": 151, - "occupied": false, + "nodesOccupying": [ + 12884901892 + ], + "occupied": true, "position": [ 960.0, 832.0 @@ -3360,7 +5130,11 @@ 6 ], "id": 152, - "occupied": false, + "nodesOccupying": [ + 12884901896, + 12884901892 + ], + "occupied": true, "position": [ 1088.0, 832.0 @@ -3378,7 +5152,12 @@ 6 ], "id": 153, - "occupied": false, + "nodesOccupying": [ + 12884901896, + 12884901892, + 12884901892 + ], + "occupied": true, "position": [ 1216.0, 832.0 @@ -3396,7 +5175,12 @@ 6 ], "id": 154, - "occupied": false, + "nodesOccupying": [ + 12884901894, + 12884901899, + 12884901899 + ], + "occupied": true, "position": [ 1344.0, 832.0 @@ -3414,7 +5198,11 @@ 6 ], "id": 155, - "occupied": false, + "nodesOccupying": [ + 12884901894, + 12884901899 + ], + "occupied": true, "position": [ 1472.0, 832.0 @@ -3432,7 +5220,10 @@ 6 ], "id": 156, - "occupied": false, + "nodesOccupying": [ + 12884901899 + ], + "occupied": true, "position": [ 1600.0, 832.0 @@ -3450,7 +5241,11 @@ 6 ], "id": 157, - "occupied": false, + "nodesOccupying": [ + 12884901896, + 12884901899 + ], + "occupied": true, "position": [ 1728.0, 832.0 @@ -3468,7 +5263,11 @@ 6 ], "id": 158, - "occupied": false, + "nodesOccupying": [ + 12884901896, + 12884901899 + ], + "occupied": true, "position": [ 1856.0, 832.0 @@ -3486,7 +5285,10 @@ 6 ], "id": 159, - "occupied": false, + "nodesOccupying": [ + 12884901894 + ], + "occupied": true, "position": [ 1984.0, 832.0 @@ -3504,7 +5306,10 @@ 6 ], "id": 160, - "occupied": false, + "nodesOccupying": [ + 12884901894 + ], + "occupied": true, "position": [ 2112.0, 832.0 @@ -3522,6 +5327,7 @@ 6 ], "id": 161, + "nodesOccupying": [], "occupied": false, "position": [ 2240.0, @@ -3540,6 +5346,7 @@ 6 ], "id": 162, + "nodesOccupying": [], "occupied": false, "position": [ 2368.0, @@ -3558,6 +5365,7 @@ 6 ], "id": 163, + "nodesOccupying": [], "occupied": false, "position": [ 2496.0, @@ -3576,6 +5384,7 @@ 6 ], "id": 164, + "nodesOccupying": [], "occupied": false, "position": [ 2624.0, @@ -3594,6 +5403,7 @@ 6 ], "id": 165, + "nodesOccupying": [], "occupied": false, "position": [ 2752.0, @@ -3612,6 +5422,7 @@ 6 ], "id": 166, + "nodesOccupying": [], "occupied": false, "position": [ 2880.0, @@ -3629,6 +5440,7 @@ 6 ], "id": 167, + "nodesOccupying": [], "occupied": false, "position": [ 3008.0, @@ -3646,7 +5458,10 @@ 7 ], "id": 168, - "occupied": false, + "nodesOccupying": [ + 12884901893 + ], + "occupied": true, "position": [ 64.0, 960.0 @@ -3664,7 +5479,10 @@ 7 ], "id": 169, - "occupied": false, + "nodesOccupying": [ + 12884901897 + ], + "occupied": true, "position": [ 192.0, 960.0 @@ -3682,6 +5500,7 @@ 7 ], "id": 170, + "nodesOccupying": [], "occupied": false, "position": [ 320.0, @@ -3700,7 +5519,11 @@ 7 ], "id": 171, - "occupied": false, + "nodesOccupying": [ + 12884901897, + 12884901893 + ], + "occupied": true, "position": [ 448.0, 960.0 @@ -3718,7 +5541,11 @@ 7 ], "id": 172, - "occupied": false, + "nodesOccupying": [ + 12884901897, + 12884901893 + ], + "occupied": true, "position": [ 576.0, 960.0 @@ -3736,7 +5563,10 @@ 7 ], "id": 173, - "occupied": false, + "nodesOccupying": [ + 12884901897 + ], + "occupied": true, "position": [ 704.0, 960.0 @@ -3754,6 +5584,7 @@ 7 ], "id": 174, + "nodesOccupying": [], "occupied": false, "position": [ 832.0, @@ -3772,6 +5603,7 @@ 7 ], "id": 175, + "nodesOccupying": [], "occupied": false, "position": [ 960.0, @@ -3790,6 +5622,7 @@ 7 ], "id": 176, + "nodesOccupying": [], "occupied": false, "position": [ 1088.0, @@ -3808,7 +5641,10 @@ 7 ], "id": 177, - "occupied": false, + "nodesOccupying": [ + 12884901896 + ], + "occupied": true, "position": [ 1216.0, 960.0 @@ -3826,7 +5662,11 @@ 7 ], "id": 178, - "occupied": false, + "nodesOccupying": [ + 12884901896, + 12884901899 + ], + "occupied": true, "position": [ 1344.0, 960.0 @@ -3844,7 +5684,10 @@ 7 ], "id": 179, - "occupied": false, + "nodesOccupying": [ + 12884901894 + ], + "occupied": true, "position": [ 1472.0, 960.0 @@ -3862,7 +5705,11 @@ 7 ], "id": 180, - "occupied": false, + "nodesOccupying": [ + 12884901896, + 12884901894 + ], + "occupied": true, "position": [ 1600.0, 960.0 @@ -3880,7 +5727,10 @@ 7 ], "id": 181, - "occupied": false, + "nodesOccupying": [ + 12884901896 + ], + "occupied": true, "position": [ 1728.0, 960.0 @@ -3898,7 +5748,10 @@ 7 ], "id": 182, - "occupied": false, + "nodesOccupying": [ + 12884901899 + ], + "occupied": true, "position": [ 1856.0, 960.0 @@ -3916,7 +5769,10 @@ 7 ], "id": 183, - "occupied": false, + "nodesOccupying": [ + 12884901899 + ], + "occupied": true, "position": [ 1984.0, 960.0 @@ -3934,7 +5790,11 @@ 7 ], "id": 184, - "occupied": false, + "nodesOccupying": [ + 12884901894, + 12884901899 + ], + "occupied": true, "position": [ 2112.0, 960.0 @@ -3952,7 +5812,11 @@ 7 ], "id": 185, - "occupied": false, + "nodesOccupying": [ + 12884901899, + 12884901899 + ], + "occupied": true, "position": [ 2240.0, 960.0 @@ -3970,6 +5834,7 @@ 7 ], "id": 186, + "nodesOccupying": [], "occupied": false, "position": [ 2368.0, @@ -3988,6 +5853,7 @@ 7 ], "id": 187, + "nodesOccupying": [], "occupied": false, "position": [ 2496.0, @@ -4006,6 +5872,7 @@ 7 ], "id": 188, + "nodesOccupying": [], "occupied": false, "position": [ 2624.0, @@ -4024,6 +5891,7 @@ 7 ], "id": 189, + "nodesOccupying": [], "occupied": false, "position": [ 2752.0, @@ -4042,6 +5910,7 @@ 7 ], "id": 190, + "nodesOccupying": [], "occupied": false, "position": [ 2880.0, @@ -4059,6 +5928,7 @@ 7 ], "id": 191, + "nodesOccupying": [], "occupied": false, "position": [ 3008.0, @@ -4076,7 +5946,10 @@ 8 ], "id": 192, - "occupied": false, + "nodesOccupying": [ + 12884901893 + ], + "occupied": true, "position": [ 64.0, 1088.0 @@ -4094,7 +5967,10 @@ 8 ], "id": 193, - "occupied": false, + "nodesOccupying": [ + 12884901897 + ], + "occupied": true, "position": [ 192.0, 1088.0 @@ -4112,7 +5988,11 @@ 8 ], "id": 194, - "occupied": false, + "nodesOccupying": [ + 12884901897, + 12884901897 + ], + "occupied": true, "position": [ 320.0, 1088.0 @@ -4130,6 +6010,10 @@ 8 ], "id": 195, + "nodesOccupying": [ + 12884901897, + 12884901893 + ], "occupied": true, "position": [ 448.0, @@ -4148,7 +6032,8 @@ 8 ], "id": 196, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 576.0, 1088.0 @@ -4166,7 +6051,8 @@ 8 ], "id": 197, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 704.0, 1088.0 @@ -4184,7 +6070,8 @@ 8 ], "id": 198, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 832.0, 1088.0 @@ -4202,7 +6089,8 @@ 8 ], "id": 199, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 960.0, 1088.0 @@ -4220,6 +6108,7 @@ 8 ], "id": 200, + "nodesOccupying": [], "occupied": false, "position": [ 1088.0, @@ -4238,6 +6127,7 @@ 8 ], "id": 201, + "nodesOccupying": [], "occupied": false, "position": [ 1216.0, @@ -4256,7 +6146,11 @@ 8 ], "id": 202, - "occupied": false, + "nodesOccupying": [ + 12884901896, + 12884901899 + ], + "occupied": true, "position": [ 1344.0, 1088.0 @@ -4274,7 +6168,11 @@ 8 ], "id": 203, - "occupied": false, + "nodesOccupying": [ + 12884901896, + 12884901896 + ], + "occupied": true, "position": [ 1472.0, 1088.0 @@ -4292,7 +6190,11 @@ 8 ], "id": 204, - "occupied": false, + "nodesOccupying": [ + 12884901896, + 12884901894 + ], + "occupied": true, "position": [ 1600.0, 1088.0 @@ -4310,6 +6212,7 @@ 8 ], "id": 205, + "nodesOccupying": [], "occupied": false, "position": [ 1728.0, @@ -4328,6 +6231,7 @@ 8 ], "id": 206, + "nodesOccupying": [], "occupied": false, "position": [ 1856.0, @@ -4346,7 +6250,10 @@ 8 ], "id": 207, - "occupied": false, + "nodesOccupying": [ + 12884901894 + ], + "occupied": true, "position": [ 1984.0, 1088.0 @@ -4364,7 +6271,11 @@ 8 ], "id": 208, - "occupied": false, + "nodesOccupying": [ + 12884901894, + 12884901894 + ], + "occupied": true, "position": [ 2112.0, 1088.0 @@ -4382,7 +6293,10 @@ 8 ], "id": 209, - "occupied": false, + "nodesOccupying": [ + 12884901899 + ], + "occupied": true, "position": [ 2240.0, 1088.0 @@ -4400,6 +6314,7 @@ 8 ], "id": 210, + "nodesOccupying": [], "occupied": false, "position": [ 2368.0, @@ -4418,6 +6333,7 @@ 8 ], "id": 211, + "nodesOccupying": [], "occupied": false, "position": [ 2496.0, @@ -4436,6 +6352,7 @@ 8 ], "id": 212, + "nodesOccupying": [], "occupied": false, "position": [ 2624.0, @@ -4454,6 +6371,7 @@ 8 ], "id": 213, + "nodesOccupying": [], "occupied": false, "position": [ 2752.0, @@ -4472,6 +6390,7 @@ 8 ], "id": 214, + "nodesOccupying": [], "occupied": false, "position": [ 2880.0, @@ -4489,6 +6408,7 @@ 8 ], "id": 215, + "nodesOccupying": [], "occupied": false, "position": [ 3008.0, @@ -4506,6 +6426,7 @@ 9 ], "id": 216, + "nodesOccupying": [], "occupied": false, "position": [ 64.0, @@ -4524,6 +6445,7 @@ 9 ], "id": 217, + "nodesOccupying": [], "occupied": false, "position": [ 192.0, @@ -4542,6 +6464,7 @@ 9 ], "id": 218, + "nodesOccupying": [], "occupied": false, "position": [ 320.0, @@ -4560,6 +6483,9 @@ 9 ], "id": 219, + "nodesOccupying": [ + 12884901893 + ], "occupied": true, "position": [ 448.0, @@ -4578,6 +6504,7 @@ 9 ], "id": 220, + "nodesOccupying": [], "occupied": false, "position": [ 576.0, @@ -4596,6 +6523,7 @@ 9 ], "id": 221, + "nodesOccupying": [], "occupied": false, "position": [ 704.0, @@ -4614,6 +6542,7 @@ 9 ], "id": 222, + "nodesOccupying": [], "occupied": false, "position": [ 832.0, @@ -4632,7 +6561,8 @@ 9 ], "id": 223, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 960.0, 1216.0 @@ -4650,7 +6580,8 @@ 9 ], "id": 224, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 1088.0, 1216.0 @@ -4668,7 +6599,8 @@ 9 ], "id": 225, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 1216.0, 1216.0 @@ -4686,7 +6618,10 @@ 9 ], "id": 226, - "occupied": false, + "nodesOccupying": [ + 12884901899 + ], + "occupied": true, "position": [ 1344.0, 1216.0 @@ -4704,6 +6639,7 @@ 9 ], "id": 227, + "nodesOccupying": [], "occupied": false, "position": [ 1472.0, @@ -4722,7 +6658,10 @@ 9 ], "id": 228, - "occupied": false, + "nodesOccupying": [ + 12884901894 + ], + "occupied": true, "position": [ 1600.0, 1216.0 @@ -4740,7 +6679,11 @@ 9 ], "id": 229, - "occupied": false, + "nodesOccupying": [ + 12884901894, + 12884901894 + ], + "occupied": true, "position": [ 1728.0, 1216.0 @@ -4758,7 +6701,10 @@ 9 ], "id": 230, - "occupied": false, + "nodesOccupying": [ + 12884901894 + ], + "occupied": true, "position": [ 1856.0, 1216.0 @@ -4776,7 +6722,10 @@ 9 ], "id": 231, - "occupied": false, + "nodesOccupying": [ + 12884901894 + ], + "occupied": true, "position": [ 1984.0, 1216.0 @@ -4794,6 +6743,7 @@ 9 ], "id": 232, + "nodesOccupying": [], "occupied": false, "position": [ 2112.0, @@ -4812,7 +6762,10 @@ 9 ], "id": 233, - "occupied": false, + "nodesOccupying": [ + 12884901899 + ], + "occupied": true, "position": [ 2240.0, 1216.0 @@ -4830,6 +6783,7 @@ 9 ], "id": 234, + "nodesOccupying": [], "occupied": false, "position": [ 2368.0, @@ -4848,6 +6802,7 @@ 9 ], "id": 235, + "nodesOccupying": [], "occupied": false, "position": [ 2496.0, @@ -4866,6 +6821,7 @@ 9 ], "id": 236, + "nodesOccupying": [], "occupied": false, "position": [ 2624.0, @@ -4884,6 +6840,7 @@ 9 ], "id": 237, + "nodesOccupying": [], "occupied": false, "position": [ 2752.0, @@ -4902,6 +6859,7 @@ 9 ], "id": 238, + "nodesOccupying": [], "occupied": false, "position": [ 2880.0, @@ -4919,6 +6877,7 @@ 9 ], "id": 239, + "nodesOccupying": [], "occupied": false, "position": [ 3008.0, @@ -4936,6 +6895,7 @@ 10 ], "id": 240, + "nodesOccupying": [], "occupied": false, "position": [ 64.0, @@ -4954,6 +6914,7 @@ 10 ], "id": 241, + "nodesOccupying": [], "occupied": false, "position": [ 192.0, @@ -4972,6 +6933,7 @@ 10 ], "id": 242, + "nodesOccupying": [], "occupied": false, "position": [ 320.0, @@ -4990,6 +6952,9 @@ 10 ], "id": 243, + "nodesOccupying": [ + 12884901893 + ], "occupied": true, "position": [ 448.0, @@ -5008,6 +6973,7 @@ 10 ], "id": 244, + "nodesOccupying": [], "occupied": false, "position": [ 576.0, @@ -5026,6 +6992,7 @@ 10 ], "id": 245, + "nodesOccupying": [], "occupied": false, "position": [ 704.0, @@ -5044,7 +7011,8 @@ 10 ], "id": 246, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 832.0, 1344.0 @@ -5062,7 +7030,8 @@ 10 ], "id": 247, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 960.0, 1344.0 @@ -5080,6 +7049,7 @@ 10 ], "id": 248, + "nodesOccupying": [], "occupied": false, "position": [ 1088.0, @@ -5098,7 +7068,8 @@ 10 ], "id": 249, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 1216.0, 1344.0 @@ -5116,6 +7087,9 @@ 10 ], "id": 250, + "nodesOccupying": [ + 12884901899 + ], "occupied": true, "position": [ 1344.0, @@ -5134,6 +7108,7 @@ 10 ], "id": 251, + "nodesOccupying": [], "occupied": false, "position": [ 1472.0, @@ -5152,6 +7127,7 @@ 10 ], "id": 252, + "nodesOccupying": [], "occupied": false, "position": [ 1600.0, @@ -5170,7 +7146,11 @@ 10 ], "id": 253, - "occupied": false, + "nodesOccupying": [ + 12884901894, + 12884901894 + ], + "occupied": true, "position": [ 1728.0, 1344.0 @@ -5188,6 +7168,7 @@ 10 ], "id": 254, + "nodesOccupying": [], "occupied": false, "position": [ 1856.0, @@ -5206,6 +7187,7 @@ 10 ], "id": 255, + "nodesOccupying": [], "occupied": false, "position": [ 1984.0, @@ -5224,6 +7206,7 @@ 10 ], "id": 256, + "nodesOccupying": [], "occupied": false, "position": [ 2112.0, @@ -5242,7 +7225,10 @@ 10 ], "id": 257, - "occupied": false, + "nodesOccupying": [ + 12884901899 + ], + "occupied": true, "position": [ 2240.0, 1344.0 @@ -5260,6 +7246,7 @@ 10 ], "id": 258, + "nodesOccupying": [], "occupied": false, "position": [ 2368.0, @@ -5278,6 +7265,7 @@ 10 ], "id": 259, + "nodesOccupying": [], "occupied": false, "position": [ 2496.0, @@ -5296,6 +7284,7 @@ 10 ], "id": 260, + "nodesOccupying": [], "occupied": false, "position": [ 2624.0, @@ -5314,6 +7303,7 @@ 10 ], "id": 261, + "nodesOccupying": [], "occupied": false, "position": [ 2752.0, @@ -5332,6 +7322,7 @@ 10 ], "id": 262, + "nodesOccupying": [], "occupied": false, "position": [ 2880.0, @@ -5349,6 +7340,7 @@ 10 ], "id": 263, + "nodesOccupying": [], "occupied": false, "position": [ 3008.0, @@ -5366,7 +7358,10 @@ 11 ], "id": 264, - "occupied": false, + "nodesOccupying": [ + 12884901901 + ], + "occupied": true, "position": [ 64.0, 1472.0 @@ -5384,6 +7379,7 @@ 11 ], "id": 265, + "nodesOccupying": [], "occupied": false, "position": [ 192.0, @@ -5402,6 +7398,7 @@ 11 ], "id": 266, + "nodesOccupying": [], "occupied": false, "position": [ 320.0, @@ -5420,6 +7417,9 @@ 11 ], "id": 267, + "nodesOccupying": [ + 12884901893 + ], "occupied": true, "position": [ 448.0, @@ -5438,6 +7438,7 @@ 11 ], "id": 268, + "nodesOccupying": [], "occupied": false, "position": [ 576.0, @@ -5456,7 +7457,8 @@ 11 ], "id": 269, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 704.0, 1472.0 @@ -5474,7 +7476,8 @@ 11 ], "id": 270, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 832.0, 1472.0 @@ -5492,7 +7495,8 @@ 11 ], "id": 271, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 960.0, 1472.0 @@ -5510,7 +7514,8 @@ 11 ], "id": 272, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 1088.0, 1472.0 @@ -5528,7 +7533,8 @@ 11 ], "id": 273, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 1216.0, 1472.0 @@ -5546,6 +7552,11 @@ 11 ], "id": 274, + "nodesOccupying": [ + 12884901895, + 12884901895, + 12884901899 + ], "occupied": true, "position": [ 1344.0, @@ -5564,6 +7575,9 @@ 11 ], "id": 275, + "nodesOccupying": [ + 12884901895 + ], "occupied": true, "position": [ 1472.0, @@ -5582,7 +7596,11 @@ 11 ], "id": 276, - "occupied": false, + "nodesOccupying": [ + 12884901895, + 12884901895 + ], + "occupied": true, "position": [ 1600.0, 1472.0 @@ -5600,6 +7618,7 @@ 11 ], "id": 277, + "nodesOccupying": [], "occupied": false, "position": [ 1728.0, @@ -5618,6 +7637,7 @@ 11 ], "id": 278, + "nodesOccupying": [], "occupied": false, "position": [ 1856.0, @@ -5636,6 +7656,7 @@ 11 ], "id": 279, + "nodesOccupying": [], "occupied": false, "position": [ 1984.0, @@ -5654,6 +7675,7 @@ 11 ], "id": 280, + "nodesOccupying": [], "occupied": false, "position": [ 2112.0, @@ -5672,7 +7694,10 @@ 11 ], "id": 281, - "occupied": false, + "nodesOccupying": [ + 12884901899 + ], + "occupied": true, "position": [ 2240.0, 1472.0 @@ -5690,6 +7715,7 @@ 11 ], "id": 282, + "nodesOccupying": [], "occupied": false, "position": [ 2368.0, @@ -5708,6 +7734,7 @@ 11 ], "id": 283, + "nodesOccupying": [], "occupied": false, "position": [ 2496.0, @@ -5726,6 +7753,7 @@ 11 ], "id": 284, + "nodesOccupying": [], "occupied": false, "position": [ 2624.0, @@ -5744,6 +7772,7 @@ 11 ], "id": 285, + "nodesOccupying": [], "occupied": false, "position": [ 2752.0, @@ -5762,6 +7791,7 @@ 11 ], "id": 286, + "nodesOccupying": [], "occupied": false, "position": [ 2880.0, @@ -5779,6 +7809,7 @@ 11 ], "id": 287, + "nodesOccupying": [], "occupied": false, "position": [ 3008.0, @@ -5796,7 +7827,11 @@ 12 ], "id": 288, - "occupied": false, + "nodesOccupying": [ + 12884901901, + 12884901893 + ], + "occupied": true, "position": [ 64.0, 1600.0 @@ -5814,7 +7849,11 @@ 12 ], "id": 289, - "occupied": false, + "nodesOccupying": [ + 12884901901, + 12884901893 + ], + "occupied": true, "position": [ 192.0, 1600.0 @@ -5832,7 +7871,11 @@ 12 ], "id": 290, - "occupied": false, + "nodesOccupying": [ + 12884901901, + 12884901893 + ], + "occupied": true, "position": [ 320.0, 1600.0 @@ -5850,6 +7893,10 @@ 12 ], "id": 291, + "nodesOccupying": [ + 12884901893, + 12884901893 + ], "occupied": true, "position": [ 448.0, @@ -5868,7 +7915,8 @@ 12 ], "id": 292, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 576.0, 1600.0 @@ -5886,7 +7934,8 @@ 12 ], "id": 293, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 704.0, 1600.0 @@ -5904,7 +7953,8 @@ 12 ], "id": 294, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 832.0, 1600.0 @@ -5922,7 +7972,8 @@ 12 ], "id": 295, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 960.0, 1600.0 @@ -5940,6 +7991,7 @@ 12 ], "id": 296, + "nodesOccupying": [], "occupied": false, "position": [ 1088.0, @@ -5958,6 +8010,9 @@ 12 ], "id": 297, + "nodesOccupying": [ + 12884901899 + ], "occupied": true, "position": [ 1216.0, @@ -5976,6 +8031,10 @@ 12 ], "id": 298, + "nodesOccupying": [ + 12884901895, + 12884901899 + ], "occupied": true, "position": [ 1344.0, @@ -5994,7 +8053,8 @@ 12 ], "id": 299, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 1472.0, 1600.0 @@ -6012,7 +8072,10 @@ 12 ], "id": 300, - "occupied": false, + "nodesOccupying": [ + 12884901895 + ], + "occupied": true, "position": [ 1600.0, 1600.0 @@ -6030,6 +8093,7 @@ 12 ], "id": 301, + "nodesOccupying": [], "occupied": false, "position": [ 1728.0, @@ -6048,6 +8112,7 @@ 12 ], "id": 302, + "nodesOccupying": [], "occupied": false, "position": [ 1856.0, @@ -6066,6 +8131,7 @@ 12 ], "id": 303, + "nodesOccupying": [], "occupied": false, "position": [ 1984.0, @@ -6084,6 +8150,7 @@ 12 ], "id": 304, + "nodesOccupying": [], "occupied": false, "position": [ 2112.0, @@ -6102,7 +8169,10 @@ 12 ], "id": 305, - "occupied": false, + "nodesOccupying": [ + 12884901899 + ], + "occupied": true, "position": [ 2240.0, 1600.0 @@ -6120,6 +8190,7 @@ 12 ], "id": 306, + "nodesOccupying": [], "occupied": false, "position": [ 2368.0, @@ -6138,6 +8209,7 @@ 12 ], "id": 307, + "nodesOccupying": [], "occupied": false, "position": [ 2496.0, @@ -6156,6 +8228,7 @@ 12 ], "id": 308, + "nodesOccupying": [], "occupied": false, "position": [ 2624.0, @@ -6174,6 +8247,7 @@ 12 ], "id": 309, + "nodesOccupying": [], "occupied": false, "position": [ 2752.0, @@ -6192,6 +8266,7 @@ 12 ], "id": 310, + "nodesOccupying": [], "occupied": false, "position": [ 2880.0, @@ -6209,6 +8284,7 @@ 12 ], "id": 311, + "nodesOccupying": [], "occupied": false, "position": [ 3008.0, @@ -6226,6 +8302,7 @@ 13 ], "id": 312, + "nodesOccupying": [], "occupied": false, "position": [ 64.0, @@ -6244,6 +8321,7 @@ 13 ], "id": 313, + "nodesOccupying": [], "occupied": false, "position": [ 192.0, @@ -6262,7 +8340,10 @@ 13 ], "id": 314, - "occupied": false, + "nodesOccupying": [ + 12884901901 + ], + "occupied": true, "position": [ 320.0, 1728.0 @@ -6280,7 +8361,12 @@ 13 ], "id": 315, - "occupied": false, + "nodesOccupying": [ + 12884901901, + 12884901893, + 12884901893 + ], + "occupied": true, "position": [ 448.0, 1728.0 @@ -6298,6 +8384,7 @@ 13 ], "id": 316, + "nodesOccupying": [], "occupied": false, "position": [ 576.0, @@ -6316,7 +8403,8 @@ 13 ], "id": 317, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 704.0, 1728.0 @@ -6334,6 +8422,7 @@ 13 ], "id": 318, + "nodesOccupying": [], "occupied": false, "position": [ 832.0, @@ -6352,7 +8441,8 @@ 13 ], "id": 319, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 960.0, 1728.0 @@ -6370,7 +8460,8 @@ 13 ], "id": 320, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 1088.0, 1728.0 @@ -6388,6 +8479,9 @@ 13 ], "id": 321, + "nodesOccupying": [ + 12884901899 + ], "occupied": true, "position": [ 1216.0, @@ -6406,6 +8500,9 @@ 13 ], "id": 322, + "nodesOccupying": [ + 12884901895 + ], "occupied": true, "position": [ 1344.0, @@ -6424,6 +8521,7 @@ 13 ], "id": 323, + "nodesOccupying": [], "occupied": false, "position": [ 1472.0, @@ -6442,7 +8540,10 @@ 13 ], "id": 324, - "occupied": false, + "nodesOccupying": [ + 12884901895 + ], + "occupied": true, "position": [ 1600.0, 1728.0 @@ -6460,6 +8561,7 @@ 13 ], "id": 325, + "nodesOccupying": [], "occupied": false, "position": [ 1728.0, @@ -6478,6 +8580,7 @@ 13 ], "id": 326, + "nodesOccupying": [], "occupied": false, "position": [ 1856.0, @@ -6496,6 +8599,7 @@ 13 ], "id": 327, + "nodesOccupying": [], "occupied": false, "position": [ 1984.0, @@ -6514,6 +8618,7 @@ 13 ], "id": 328, + "nodesOccupying": [], "occupied": false, "position": [ 2112.0, @@ -6532,7 +8637,10 @@ 13 ], "id": 329, - "occupied": false, + "nodesOccupying": [ + 12884901899 + ], + "occupied": true, "position": [ 2240.0, 1728.0 @@ -6550,6 +8658,7 @@ 13 ], "id": 330, + "nodesOccupying": [], "occupied": false, "position": [ 2368.0, @@ -6568,6 +8677,7 @@ 13 ], "id": 331, + "nodesOccupying": [], "occupied": false, "position": [ 2496.0, @@ -6586,6 +8696,7 @@ 13 ], "id": 332, + "nodesOccupying": [], "occupied": false, "position": [ 2624.0, @@ -6604,6 +8715,7 @@ 13 ], "id": 333, + "nodesOccupying": [], "occupied": false, "position": [ 2752.0, @@ -6622,6 +8734,7 @@ 13 ], "id": 334, + "nodesOccupying": [], "occupied": false, "position": [ 2880.0, @@ -6639,6 +8752,7 @@ 13 ], "id": 335, + "nodesOccupying": [], "occupied": false, "position": [ 3008.0, @@ -6656,6 +8770,7 @@ 14 ], "id": 336, + "nodesOccupying": [], "occupied": false, "position": [ 64.0, @@ -6674,6 +8789,7 @@ 14 ], "id": 337, + "nodesOccupying": [], "occupied": false, "position": [ 192.0, @@ -6692,6 +8808,7 @@ 14 ], "id": 338, + "nodesOccupying": [], "occupied": false, "position": [ 320.0, @@ -6710,7 +8827,12 @@ 14 ], "id": 339, - "occupied": false, + "nodesOccupying": [ + 12884901901, + 12884901900, + 12884901900 + ], + "occupied": true, "position": [ 448.0, 1856.0 @@ -6728,7 +8850,10 @@ 14 ], "id": 340, - "occupied": false, + "nodesOccupying": [ + 12884901901 + ], + "occupied": true, "position": [ 576.0, 1856.0 @@ -6746,7 +8871,8 @@ 14 ], "id": 341, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 704.0, 1856.0 @@ -6764,6 +8890,7 @@ 14 ], "id": 342, + "nodesOccupying": [], "occupied": false, "position": [ 832.0, @@ -6782,7 +8909,8 @@ 14 ], "id": 343, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 960.0, 1856.0 @@ -6800,7 +8928,8 @@ 14 ], "id": 344, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 1088.0, 1856.0 @@ -6818,6 +8947,10 @@ 14 ], "id": 345, + "nodesOccupying": [ + 12884901899, + 12884901899 + ], "occupied": true, "position": [ 1216.0, @@ -6836,7 +8969,12 @@ 14 ], "id": 346, - "occupied": false, + "nodesOccupying": [ + 12884901895, + 12884901895, + 12884901899 + ], + "occupied": true, "position": [ 1344.0, 1856.0 @@ -6854,7 +8992,11 @@ 14 ], "id": 347, - "occupied": false, + "nodesOccupying": [ + 12884901895, + 12884901899 + ], + "occupied": true, "position": [ 1472.0, 1856.0 @@ -6872,7 +9014,12 @@ 14 ], "id": 348, - "occupied": false, + "nodesOccupying": [ + 12884901895, + 12884901895, + 12884901899 + ], + "occupied": true, "position": [ 1600.0, 1856.0 @@ -6890,7 +9037,10 @@ 14 ], "id": 349, - "occupied": false, + "nodesOccupying": [ + 12884901899 + ], + "occupied": true, "position": [ 1728.0, 1856.0 @@ -6908,7 +9058,10 @@ 14 ], "id": 350, - "occupied": false, + "nodesOccupying": [ + 12884901899 + ], + "occupied": true, "position": [ 1856.0, 1856.0 @@ -6926,7 +9079,10 @@ 14 ], "id": 351, - "occupied": false, + "nodesOccupying": [ + 12884901899 + ], + "occupied": true, "position": [ 1984.0, 1856.0 @@ -6944,7 +9100,10 @@ 14 ], "id": 352, - "occupied": false, + "nodesOccupying": [ + 12884901899 + ], + "occupied": true, "position": [ 2112.0, 1856.0 @@ -6962,7 +9121,11 @@ 14 ], "id": 353, - "occupied": false, + "nodesOccupying": [ + 12884901899, + 12884901899 + ], + "occupied": true, "position": [ 2240.0, 1856.0 @@ -6980,6 +9143,7 @@ 14 ], "id": 354, + "nodesOccupying": [], "occupied": false, "position": [ 2368.0, @@ -6998,6 +9162,7 @@ 14 ], "id": 355, + "nodesOccupying": [], "occupied": false, "position": [ 2496.0, @@ -7016,6 +9181,7 @@ 14 ], "id": 356, + "nodesOccupying": [], "occupied": false, "position": [ 2624.0, @@ -7034,6 +9200,7 @@ 14 ], "id": 357, + "nodesOccupying": [], "occupied": false, "position": [ 2752.0, @@ -7052,6 +9219,7 @@ 14 ], "id": 358, + "nodesOccupying": [], "occupied": false, "position": [ 2880.0, @@ -7069,6 +9237,7 @@ 14 ], "id": 359, + "nodesOccupying": [], "occupied": false, "position": [ 3008.0, @@ -7086,6 +9255,7 @@ 15 ], "id": 360, + "nodesOccupying": [], "occupied": false, "position": [ 64.0, @@ -7104,6 +9274,7 @@ 15 ], "id": 361, + "nodesOccupying": [], "occupied": false, "position": [ 192.0, @@ -7122,7 +9293,10 @@ 15 ], "id": 362, - "occupied": false, + "nodesOccupying": [ + 12884901900 + ], + "occupied": true, "position": [ 320.0, 1984.0 @@ -7140,7 +9314,11 @@ 15 ], "id": 363, - "occupied": false, + "nodesOccupying": [ + 12884901900, + 12884901900 + ], + "occupied": true, "position": [ 448.0, 1984.0 @@ -7158,7 +9336,12 @@ 15 ], "id": 364, - "occupied": false, + "nodesOccupying": [ + 12884901901, + 12884901901, + 12884901900 + ], + "occupied": true, "position": [ 576.0, 1984.0 @@ -7176,7 +9359,8 @@ 15 ], "id": 365, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 704.0, 1984.0 @@ -7194,7 +9378,8 @@ 15 ], "id": 366, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 832.0, 1984.0 @@ -7212,7 +9397,8 @@ 15 ], "id": 367, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 960.0, 1984.0 @@ -7230,7 +9416,8 @@ 15 ], "id": 368, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 1088.0, 1984.0 @@ -7248,7 +9435,8 @@ 15 ], "id": 369, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 1216.0, 1984.0 @@ -7266,6 +9454,7 @@ 15 ], "id": 370, + "nodesOccupying": [], "occupied": false, "position": [ 1344.0, @@ -7284,6 +9473,7 @@ 15 ], "id": 371, + "nodesOccupying": [], "occupied": false, "position": [ 1472.0, @@ -7302,6 +9492,7 @@ 15 ], "id": 372, + "nodesOccupying": [], "occupied": false, "position": [ 1600.0, @@ -7320,6 +9511,7 @@ 15 ], "id": 373, + "nodesOccupying": [], "occupied": false, "position": [ 1728.0, @@ -7338,6 +9530,7 @@ 15 ], "id": 374, + "nodesOccupying": [], "occupied": false, "position": [ 1856.0, @@ -7356,6 +9549,7 @@ 15 ], "id": 375, + "nodesOccupying": [], "occupied": false, "position": [ 1984.0, @@ -7374,6 +9568,7 @@ 15 ], "id": 376, + "nodesOccupying": [], "occupied": false, "position": [ 2112.0, @@ -7392,6 +9587,7 @@ 15 ], "id": 377, + "nodesOccupying": [], "occupied": false, "position": [ 2240.0, @@ -7410,6 +9606,7 @@ 15 ], "id": 378, + "nodesOccupying": [], "occupied": false, "position": [ 2368.0, @@ -7428,6 +9625,7 @@ 15 ], "id": 379, + "nodesOccupying": [], "occupied": false, "position": [ 2496.0, @@ -7446,6 +9644,7 @@ 15 ], "id": 380, + "nodesOccupying": [], "occupied": false, "position": [ 2624.0, @@ -7464,6 +9663,7 @@ 15 ], "id": 381, + "nodesOccupying": [], "occupied": false, "position": [ 2752.0, @@ -7482,6 +9682,7 @@ 15 ], "id": 382, + "nodesOccupying": [], "occupied": false, "position": [ 2880.0, @@ -7499,6 +9700,7 @@ 15 ], "id": 383, + "nodesOccupying": [], "occupied": false, "position": [ 3008.0, @@ -7516,7 +9718,11 @@ 16 ], "id": 384, - "occupied": false, + "nodesOccupying": [ + 12884901901, + 12884901900 + ], + "occupied": true, "position": [ 64.0, 2112.0 @@ -7534,7 +9740,10 @@ 16 ], "id": 385, - "occupied": false, + "nodesOccupying": [ + 12884901900 + ], + "occupied": true, "position": [ 192.0, 2112.0 @@ -7552,7 +9761,10 @@ 16 ], "id": 386, - "occupied": false, + "nodesOccupying": [ + 12884901900 + ], + "occupied": true, "position": [ 320.0, 2112.0 @@ -7570,7 +9782,10 @@ 16 ], "id": 387, - "occupied": false, + "nodesOccupying": [ + 12884901901 + ], + "occupied": true, "position": [ 448.0, 2112.0 @@ -7588,7 +9803,11 @@ 16 ], "id": 388, - "occupied": false, + "nodesOccupying": [ + 12884901901, + 12884901900 + ], + "occupied": true, "position": [ 576.0, 2112.0 @@ -7606,7 +9825,10 @@ 16 ], "id": 389, - "occupied": false, + "nodesOccupying": [ + 12884901900 + ], + "occupied": true, "position": [ 704.0, 2112.0 @@ -7624,7 +9846,8 @@ 16 ], "id": 390, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 832.0, 2112.0 @@ -7642,6 +9865,7 @@ 16 ], "id": 391, + "nodesOccupying": [], "occupied": false, "position": [ 960.0, @@ -7660,6 +9884,7 @@ 16 ], "id": 392, + "nodesOccupying": [], "occupied": false, "position": [ 1088.0, @@ -7678,7 +9903,8 @@ 16 ], "id": 393, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 1216.0, 2112.0 @@ -7696,6 +9922,7 @@ 16 ], "id": 394, + "nodesOccupying": [], "occupied": false, "position": [ 1344.0, @@ -7714,6 +9941,7 @@ 16 ], "id": 395, + "nodesOccupying": [], "occupied": false, "position": [ 1472.0, @@ -7732,6 +9960,7 @@ 16 ], "id": 396, + "nodesOccupying": [], "occupied": false, "position": [ 1600.0, @@ -7750,6 +9979,7 @@ 16 ], "id": 397, + "nodesOccupying": [], "occupied": false, "position": [ 1728.0, @@ -7768,6 +9998,7 @@ 16 ], "id": 398, + "nodesOccupying": [], "occupied": false, "position": [ 1856.0, @@ -7786,6 +10017,7 @@ 16 ], "id": 399, + "nodesOccupying": [], "occupied": false, "position": [ 1984.0, @@ -7804,6 +10036,7 @@ 16 ], "id": 400, + "nodesOccupying": [], "occupied": false, "position": [ 2112.0, @@ -7822,6 +10055,7 @@ 16 ], "id": 401, + "nodesOccupying": [], "occupied": false, "position": [ 2240.0, @@ -7840,6 +10074,7 @@ 16 ], "id": 402, + "nodesOccupying": [], "occupied": false, "position": [ 2368.0, @@ -7858,6 +10093,7 @@ 16 ], "id": 403, + "nodesOccupying": [], "occupied": false, "position": [ 2496.0, @@ -7876,6 +10112,7 @@ 16 ], "id": 404, + "nodesOccupying": [], "occupied": false, "position": [ 2624.0, @@ -7894,6 +10131,7 @@ 16 ], "id": 405, + "nodesOccupying": [], "occupied": false, "position": [ 2752.0, @@ -7912,6 +10150,7 @@ 16 ], "id": 406, + "nodesOccupying": [], "occupied": false, "position": [ 2880.0, @@ -7929,6 +10168,7 @@ 16 ], "id": 407, + "nodesOccupying": [], "occupied": false, "position": [ 3008.0, @@ -7946,7 +10186,11 @@ 17 ], "id": 408, - "occupied": false, + "nodesOccupying": [ + 12884901901, + 12884901900 + ], + "occupied": true, "position": [ 64.0, 2240.0 @@ -7964,7 +10208,10 @@ 17 ], "id": 409, - "occupied": false, + "nodesOccupying": [ + 12884901901 + ], + "occupied": true, "position": [ 192.0, 2240.0 @@ -7982,7 +10229,11 @@ 17 ], "id": 410, - "occupied": false, + "nodesOccupying": [ + 12884901901, + 12884901901 + ], + "occupied": true, "position": [ 320.0, 2240.0 @@ -8000,7 +10251,10 @@ 17 ], "id": 411, - "occupied": false, + "nodesOccupying": [ + 12884901901 + ], + "occupied": true, "position": [ 448.0, 2240.0 @@ -8018,6 +10272,7 @@ 17 ], "id": 412, + "nodesOccupying": [], "occupied": false, "position": [ 576.0, @@ -8036,7 +10291,10 @@ 17 ], "id": 413, - "occupied": false, + "nodesOccupying": [ + 12884901900 + ], + "occupied": true, "position": [ 704.0, 2240.0 @@ -8054,6 +10312,9 @@ 17 ], "id": 414, + "nodesOccupying": [ + 12884901900 + ], "occupied": true, "position": [ 832.0, @@ -8072,7 +10333,8 @@ 17 ], "id": 415, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 960.0, 2240.0 @@ -8090,7 +10352,8 @@ 17 ], "id": 416, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 1088.0, 2240.0 @@ -8108,7 +10371,8 @@ 17 ], "id": 417, - "occupied": true, + "nodesOccupying": [], + "occupied": false, "position": [ 1216.0, 2240.0 @@ -8126,6 +10390,7 @@ 17 ], "id": 418, + "nodesOccupying": [], "occupied": false, "position": [ 1344.0, @@ -8144,6 +10409,7 @@ 17 ], "id": 419, + "nodesOccupying": [], "occupied": false, "position": [ 1472.0, @@ -8162,6 +10428,7 @@ 17 ], "id": 420, + "nodesOccupying": [], "occupied": false, "position": [ 1600.0, @@ -8180,6 +10447,7 @@ 17 ], "id": 421, + "nodesOccupying": [], "occupied": false, "position": [ 1728.0, @@ -8198,6 +10466,7 @@ 17 ], "id": 422, + "nodesOccupying": [], "occupied": false, "position": [ 1856.0, @@ -8216,6 +10485,7 @@ 17 ], "id": 423, + "nodesOccupying": [], "occupied": false, "position": [ 1984.0, @@ -8234,6 +10504,7 @@ 17 ], "id": 424, + "nodesOccupying": [], "occupied": false, "position": [ 2112.0, @@ -8252,6 +10523,7 @@ 17 ], "id": 425, + "nodesOccupying": [], "occupied": false, "position": [ 2240.0, @@ -8270,6 +10542,7 @@ 17 ], "id": 426, + "nodesOccupying": [], "occupied": false, "position": [ 2368.0, @@ -8288,6 +10561,7 @@ 17 ], "id": 427, + "nodesOccupying": [], "occupied": false, "position": [ 2496.0, @@ -8306,6 +10580,7 @@ 17 ], "id": 428, + "nodesOccupying": [], "occupied": false, "position": [ 2624.0, @@ -8324,6 +10599,7 @@ 17 ], "id": 429, + "nodesOccupying": [], "occupied": false, "position": [ 2752.0, @@ -8342,6 +10618,7 @@ 17 ], "id": 430, + "nodesOccupying": [], "occupied": false, "position": [ 2880.0, @@ -8359,6 +10636,7 @@ 17 ], "id": 431, + "nodesOccupying": [], "occupied": false, "position": [ 3008.0, @@ -8376,6 +10654,7 @@ 18 ], "id": 432, + "nodesOccupying": [], "occupied": false, "position": [ 64.0, @@ -8394,6 +10673,7 @@ 18 ], "id": 433, + "nodesOccupying": [], "occupied": false, "position": [ 192.0, @@ -8412,7 +10692,11 @@ 18 ], "id": 434, - "occupied": false, + "nodesOccupying": [ + 12884901901, + 12884901901 + ], + "occupied": true, "position": [ 320.0, 2368.0 @@ -8430,6 +10714,7 @@ 18 ], "id": 435, + "nodesOccupying": [], "occupied": false, "position": [ 448.0, @@ -8448,6 +10733,7 @@ 18 ], "id": 436, + "nodesOccupying": [], "occupied": false, "position": [ 576.0, @@ -8466,6 +10752,7 @@ 18 ], "id": 437, + "nodesOccupying": [], "occupied": false, "position": [ 704.0, @@ -8484,7 +10771,12 @@ 18 ], "id": 438, - "occupied": false, + "nodesOccupying": [ + 12884901900, + 12884901898, + 12884901898 + ], + "occupied": true, "position": [ 832.0, 2368.0 @@ -8502,7 +10794,10 @@ 18 ], "id": 439, - "occupied": false, + "nodesOccupying": [ + 12884901898 + ], + "occupied": true, "position": [ 960.0, 2368.0 @@ -8520,6 +10815,7 @@ 18 ], "id": 440, + "nodesOccupying": [], "occupied": false, "position": [ 1088.0, @@ -8538,6 +10834,7 @@ 18 ], "id": 441, + "nodesOccupying": [], "occupied": false, "position": [ 1216.0, @@ -8556,6 +10853,7 @@ 18 ], "id": 442, + "nodesOccupying": [], "occupied": false, "position": [ 1344.0, @@ -8574,6 +10872,7 @@ 18 ], "id": 443, + "nodesOccupying": [], "occupied": false, "position": [ 1472.0, @@ -8592,6 +10891,7 @@ 18 ], "id": 444, + "nodesOccupying": [], "occupied": false, "position": [ 1600.0, @@ -8610,6 +10910,7 @@ 18 ], "id": 445, + "nodesOccupying": [], "occupied": false, "position": [ 1728.0, @@ -8628,6 +10929,7 @@ 18 ], "id": 446, + "nodesOccupying": [], "occupied": false, "position": [ 1856.0, @@ -8646,6 +10948,7 @@ 18 ], "id": 447, + "nodesOccupying": [], "occupied": false, "position": [ 1984.0, @@ -8664,6 +10967,7 @@ 18 ], "id": 448, + "nodesOccupying": [], "occupied": false, "position": [ 2112.0, @@ -8682,6 +10986,7 @@ 18 ], "id": 449, + "nodesOccupying": [], "occupied": false, "position": [ 2240.0, @@ -8700,6 +11005,7 @@ 18 ], "id": 450, + "nodesOccupying": [], "occupied": false, "position": [ 2368.0, @@ -8718,6 +11024,7 @@ 18 ], "id": 451, + "nodesOccupying": [], "occupied": false, "position": [ 2496.0, @@ -8736,6 +11043,7 @@ 18 ], "id": 452, + "nodesOccupying": [], "occupied": false, "position": [ 2624.0, @@ -8754,6 +11062,7 @@ 18 ], "id": 453, + "nodesOccupying": [], "occupied": false, "position": [ 2752.0, @@ -8772,6 +11081,7 @@ 18 ], "id": 454, + "nodesOccupying": [], "occupied": false, "position": [ 2880.0, @@ -8789,6 +11099,7 @@ 18 ], "id": 455, + "nodesOccupying": [], "occupied": false, "position": [ 3008.0, @@ -8806,6 +11117,7 @@ 19 ], "id": 456, + "nodesOccupying": [], "occupied": false, "position": [ 64.0, @@ -8824,6 +11136,7 @@ 19 ], "id": 457, + "nodesOccupying": [], "occupied": false, "position": [ 192.0, @@ -8842,6 +11155,7 @@ 19 ], "id": 458, + "nodesOccupying": [], "occupied": false, "position": [ 320.0, @@ -8860,6 +11174,7 @@ 19 ], "id": 459, + "nodesOccupying": [], "occupied": false, "position": [ 448.0, @@ -8878,6 +11193,7 @@ 19 ], "id": 460, + "nodesOccupying": [], "occupied": false, "position": [ 576.0, @@ -8896,7 +11212,10 @@ 19 ], "id": 461, - "occupied": false, + "nodesOccupying": [ + 12884901898 + ], + "occupied": true, "position": [ 704.0, 2496.0 @@ -8914,7 +11233,11 @@ 19 ], "id": 462, - "occupied": false, + "nodesOccupying": [ + 12884901900, + 12884901898 + ], + "occupied": true, "position": [ 832.0, 2496.0 @@ -8932,7 +11255,11 @@ 19 ], "id": 463, - "occupied": false, + "nodesOccupying": [ + 12884901900, + 12884901898 + ], + "occupied": true, "position": [ 960.0, 2496.0 @@ -8950,7 +11277,10 @@ 19 ], "id": 464, - "occupied": false, + "nodesOccupying": [ + 12884901898 + ], + "occupied": true, "position": [ 1088.0, 2496.0 @@ -8968,7 +11298,10 @@ 19 ], "id": 465, - "occupied": false, + "nodesOccupying": [ + 12884901898 + ], + "occupied": true, "position": [ 1216.0, 2496.0 @@ -8986,6 +11319,7 @@ 19 ], "id": 466, + "nodesOccupying": [], "occupied": false, "position": [ 1344.0, @@ -9004,6 +11338,7 @@ 19 ], "id": 467, + "nodesOccupying": [], "occupied": false, "position": [ 1472.0, @@ -9022,6 +11357,7 @@ 19 ], "id": 468, + "nodesOccupying": [], "occupied": false, "position": [ 1600.0, @@ -9040,6 +11376,7 @@ 19 ], "id": 469, + "nodesOccupying": [], "occupied": false, "position": [ 1728.0, @@ -9058,6 +11395,7 @@ 19 ], "id": 470, + "nodesOccupying": [], "occupied": false, "position": [ 1856.0, @@ -9076,7 +11414,10 @@ 19 ], "id": 471, - "occupied": false, + "nodesOccupying": [ + 12884901902 + ], + "occupied": true, "position": [ 1984.0, 2496.0 @@ -9094,7 +11435,11 @@ 19 ], "id": 472, - "occupied": false, + "nodesOccupying": [ + 12884901902, + 12884901902 + ], + "occupied": true, "position": [ 2112.0, 2496.0 @@ -9112,6 +11457,7 @@ 19 ], "id": 473, + "nodesOccupying": [], "occupied": false, "position": [ 2240.0, @@ -9130,6 +11476,7 @@ 19 ], "id": 474, + "nodesOccupying": [], "occupied": false, "position": [ 2368.0, @@ -9148,6 +11495,7 @@ 19 ], "id": 475, + "nodesOccupying": [], "occupied": false, "position": [ 2496.0, @@ -9166,6 +11514,7 @@ 19 ], "id": 476, + "nodesOccupying": [], "occupied": false, "position": [ 2624.0, @@ -9184,6 +11533,7 @@ 19 ], "id": 477, + "nodesOccupying": [], "occupied": false, "position": [ 2752.0, @@ -9202,6 +11552,7 @@ 19 ], "id": 478, + "nodesOccupying": [], "occupied": false, "position": [ 2880.0, @@ -9219,6 +11570,7 @@ 19 ], "id": 479, + "nodesOccupying": [], "occupied": false, "position": [ 3008.0, @@ -9236,6 +11588,7 @@ 20 ], "id": 480, + "nodesOccupying": [], "occupied": false, "position": [ 64.0, @@ -9254,6 +11607,7 @@ 20 ], "id": 481, + "nodesOccupying": [], "occupied": false, "position": [ 192.0, @@ -9272,6 +11626,7 @@ 20 ], "id": 482, + "nodesOccupying": [], "occupied": false, "position": [ 320.0, @@ -9290,6 +11645,7 @@ 20 ], "id": 483, + "nodesOccupying": [], "occupied": false, "position": [ 448.0, @@ -9308,6 +11664,7 @@ 20 ], "id": 484, + "nodesOccupying": [], "occupied": false, "position": [ 576.0, @@ -9326,7 +11683,10 @@ 20 ], "id": 485, - "occupied": false, + "nodesOccupying": [ + 12884901898 + ], + "occupied": true, "position": [ 704.0, 2624.0 @@ -9344,6 +11704,7 @@ 20 ], "id": 486, + "nodesOccupying": [], "occupied": false, "position": [ 832.0, @@ -9362,7 +11723,10 @@ 20 ], "id": 487, - "occupied": false, + "nodesOccupying": [ + 12884901900 + ], + "occupied": true, "position": [ 960.0, 2624.0 @@ -9380,7 +11744,10 @@ 20 ], "id": 488, - "occupied": false, + "nodesOccupying": [ + 12884901900 + ], + "occupied": true, "position": [ 1088.0, 2624.0 @@ -9398,7 +11765,10 @@ 20 ], "id": 489, - "occupied": false, + "nodesOccupying": [ + 12884901898 + ], + "occupied": true, "position": [ 1216.0, 2624.0 @@ -9416,7 +11786,10 @@ 20 ], "id": 490, - "occupied": false, + "nodesOccupying": [ + 12884901898 + ], + "occupied": true, "position": [ 1344.0, 2624.0 @@ -9434,6 +11807,7 @@ 20 ], "id": 491, + "nodesOccupying": [], "occupied": false, "position": [ 1472.0, @@ -9452,7 +11826,11 @@ 20 ], "id": 492, - "occupied": false, + "nodesOccupying": [ + 12884901902, + 12884901902 + ], + "occupied": true, "position": [ 1600.0, 2624.0 @@ -9470,7 +11848,10 @@ 20 ], "id": 493, - "occupied": false, + "nodesOccupying": [ + 12884901902 + ], + "occupied": true, "position": [ 1728.0, 2624.0 @@ -9488,7 +11869,10 @@ 20 ], "id": 494, - "occupied": false, + "nodesOccupying": [ + 12884901902 + ], + "occupied": true, "position": [ 1856.0, 2624.0 @@ -9506,7 +11890,10 @@ 20 ], "id": 495, - "occupied": false, + "nodesOccupying": [ + 12884901902 + ], + "occupied": true, "position": [ 1984.0, 2624.0 @@ -9524,7 +11911,10 @@ 20 ], "id": 496, - "occupied": false, + "nodesOccupying": [ + 12884901902 + ], + "occupied": true, "position": [ 2112.0, 2624.0 @@ -9542,6 +11932,7 @@ 20 ], "id": 497, + "nodesOccupying": [], "occupied": false, "position": [ 2240.0, @@ -9560,6 +11951,7 @@ 20 ], "id": 498, + "nodesOccupying": [], "occupied": false, "position": [ 2368.0, @@ -9578,6 +11970,7 @@ 20 ], "id": 499, + "nodesOccupying": [], "occupied": false, "position": [ 2496.0, @@ -9596,6 +11989,7 @@ 20 ], "id": 500, + "nodesOccupying": [], "occupied": false, "position": [ 2624.0, @@ -9614,6 +12008,7 @@ 20 ], "id": 501, + "nodesOccupying": [], "occupied": false, "position": [ 2752.0, @@ -9632,6 +12027,7 @@ 20 ], "id": 502, + "nodesOccupying": [], "occupied": false, "position": [ 2880.0, @@ -9649,6 +12045,7 @@ 20 ], "id": 503, + "nodesOccupying": [], "occupied": false, "position": [ 3008.0, @@ -9666,6 +12063,7 @@ 21 ], "id": 504, + "nodesOccupying": [], "occupied": false, "position": [ 64.0, @@ -9684,6 +12082,7 @@ 21 ], "id": 505, + "nodesOccupying": [], "occupied": false, "position": [ 192.0, @@ -9702,6 +12101,7 @@ 21 ], "id": 506, + "nodesOccupying": [], "occupied": false, "position": [ 320.0, @@ -9720,6 +12120,7 @@ 21 ], "id": 507, + "nodesOccupying": [], "occupied": false, "position": [ 448.0, @@ -9738,7 +12139,11 @@ 21 ], "id": 508, - "occupied": false, + "nodesOccupying": [ + 12884901898, + 12884901898 + ], + "occupied": true, "position": [ 576.0, 2752.0 @@ -9756,7 +12161,10 @@ 21 ], "id": 509, - "occupied": false, + "nodesOccupying": [ + 12884901898 + ], + "occupied": true, "position": [ 704.0, 2752.0 @@ -9774,6 +12182,7 @@ 21 ], "id": 510, + "nodesOccupying": [], "occupied": false, "position": [ 832.0, @@ -9792,7 +12201,10 @@ 21 ], "id": 511, - "occupied": false, + "nodesOccupying": [ + 12884901900 + ], + "occupied": true, "position": [ 960.0, 2752.0 @@ -9810,7 +12222,11 @@ 21 ], "id": 512, - "occupied": false, + "nodesOccupying": [ + 12884901900, + 12884901900 + ], + "occupied": true, "position": [ 1088.0, 2752.0 @@ -9828,6 +12244,7 @@ 21 ], "id": 513, + "nodesOccupying": [], "occupied": false, "position": [ 1216.0, @@ -9846,7 +12263,10 @@ 21 ], "id": 514, - "occupied": false, + "nodesOccupying": [ + 12884901898 + ], + "occupied": true, "position": [ 1344.0, 2752.0 @@ -9864,7 +12284,10 @@ 21 ], "id": 515, - "occupied": false, + "nodesOccupying": [ + 12884901898 + ], + "occupied": true, "position": [ 1472.0, 2752.0 @@ -9882,7 +12305,11 @@ 21 ], "id": 516, - "occupied": false, + "nodesOccupying": [ + 12884901898, + 12884901902 + ], + "occupied": true, "position": [ 1600.0, 2752.0 @@ -9900,6 +12327,7 @@ 21 ], "id": 517, + "nodesOccupying": [], "occupied": false, "position": [ 1728.0, @@ -9918,6 +12346,7 @@ 21 ], "id": 518, + "nodesOccupying": [], "occupied": false, "position": [ 1856.0, @@ -9936,6 +12365,7 @@ 21 ], "id": 519, + "nodesOccupying": [], "occupied": false, "position": [ 1984.0, @@ -9954,7 +12384,10 @@ 21 ], "id": 520, - "occupied": false, + "nodesOccupying": [ + 12884901902 + ], + "occupied": true, "position": [ 2112.0, 2752.0 @@ -9972,6 +12405,7 @@ 21 ], "id": 521, + "nodesOccupying": [], "occupied": false, "position": [ 2240.0, @@ -9990,6 +12424,7 @@ 21 ], "id": 522, + "nodesOccupying": [], "occupied": false, "position": [ 2368.0, @@ -10008,6 +12443,7 @@ 21 ], "id": 523, + "nodesOccupying": [], "occupied": false, "position": [ 2496.0, @@ -10026,6 +12462,7 @@ 21 ], "id": 524, + "nodesOccupying": [], "occupied": false, "position": [ 2624.0, @@ -10044,6 +12481,7 @@ 21 ], "id": 525, + "nodesOccupying": [], "occupied": false, "position": [ 2752.0, @@ -10062,6 +12500,7 @@ 21 ], "id": 526, + "nodesOccupying": [], "occupied": false, "position": [ 2880.0, @@ -10079,6 +12518,7 @@ 21 ], "id": 527, + "nodesOccupying": [], "occupied": false, "position": [ 3008.0, @@ -10096,7 +12536,10 @@ 22 ], "id": 528, - "occupied": false, + "nodesOccupying": [ + 12884901900 + ], + "occupied": true, "position": [ 64.0, 2880.0 @@ -10114,6 +12557,7 @@ 22 ], "id": 529, + "nodesOccupying": [], "occupied": false, "position": [ 192.0, @@ -10132,6 +12576,7 @@ 22 ], "id": 530, + "nodesOccupying": [], "occupied": false, "position": [ 320.0, @@ -10150,6 +12595,7 @@ 22 ], "id": 531, + "nodesOccupying": [], "occupied": false, "position": [ 448.0, @@ -10168,7 +12614,10 @@ 22 ], "id": 532, - "occupied": false, + "nodesOccupying": [ + 12884901898 + ], + "occupied": true, "position": [ 576.0, 2880.0 @@ -10186,7 +12635,10 @@ 22 ], "id": 533, - "occupied": false, + "nodesOccupying": [ + 12884901898 + ], + "occupied": true, "position": [ 704.0, 2880.0 @@ -10204,7 +12656,11 @@ 22 ], "id": 534, - "occupied": false, + "nodesOccupying": [ + 12884901900, + 12884901898 + ], + "occupied": true, "position": [ 832.0, 2880.0 @@ -10222,7 +12678,10 @@ 22 ], "id": 535, - "occupied": false, + "nodesOccupying": [ + 12884901900 + ], + "occupied": true, "position": [ 960.0, 2880.0 @@ -10240,6 +12699,7 @@ 22 ], "id": 536, + "nodesOccupying": [], "occupied": false, "position": [ 1088.0, @@ -10258,6 +12718,7 @@ 22 ], "id": 537, + "nodesOccupying": [], "occupied": false, "position": [ 1216.0, @@ -10276,6 +12737,7 @@ 22 ], "id": 538, + "nodesOccupying": [], "occupied": false, "position": [ 1344.0, @@ -10294,6 +12756,7 @@ 22 ], "id": 539, + "nodesOccupying": [], "occupied": false, "position": [ 1472.0, @@ -10312,7 +12775,12 @@ 22 ], "id": 540, - "occupied": false, + "nodesOccupying": [ + 12884901898, + 12884901898, + 12884901902 + ], + "occupied": true, "position": [ 1600.0, 2880.0 @@ -10330,7 +12798,11 @@ 22 ], "id": 541, - "occupied": false, + "nodesOccupying": [ + 12884901898, + 12884901898 + ], + "occupied": true, "position": [ 1728.0, 2880.0 @@ -10348,6 +12820,7 @@ 22 ], "id": 542, + "nodesOccupying": [], "occupied": false, "position": [ 1856.0, @@ -10366,6 +12839,7 @@ 22 ], "id": 543, + "nodesOccupying": [], "occupied": false, "position": [ 1984.0, @@ -10384,7 +12858,10 @@ 22 ], "id": 544, - "occupied": false, + "nodesOccupying": [ + 12884901902 + ], + "occupied": true, "position": [ 2112.0, 2880.0 @@ -10402,6 +12879,7 @@ 22 ], "id": 545, + "nodesOccupying": [], "occupied": false, "position": [ 2240.0, @@ -10420,6 +12898,7 @@ 22 ], "id": 546, + "nodesOccupying": [], "occupied": false, "position": [ 2368.0, @@ -10438,6 +12917,7 @@ 22 ], "id": 547, + "nodesOccupying": [], "occupied": false, "position": [ 2496.0, @@ -10456,6 +12936,7 @@ 22 ], "id": 548, + "nodesOccupying": [], "occupied": false, "position": [ 2624.0, @@ -10474,6 +12955,7 @@ 22 ], "id": 549, + "nodesOccupying": [], "occupied": false, "position": [ 2752.0, @@ -10492,6 +12974,7 @@ 22 ], "id": 550, + "nodesOccupying": [], "occupied": false, "position": [ 2880.0, @@ -10509,6 +12992,7 @@ 22 ], "id": 551, + "nodesOccupying": [], "occupied": false, "position": [ 3008.0, @@ -10525,7 +13009,10 @@ 23 ], "id": 552, - "occupied": false, + "nodesOccupying": [ + 12884901900 + ], + "occupied": true, "position": [ 64.0, 3008.0 @@ -10542,6 +13029,7 @@ 23 ], "id": 553, + "nodesOccupying": [], "occupied": false, "position": [ 192.0, @@ -10559,6 +13047,7 @@ 23 ], "id": 554, + "nodesOccupying": [], "occupied": false, "position": [ 320.0, @@ -10576,6 +13065,7 @@ 23 ], "id": 555, + "nodesOccupying": [], "occupied": false, "position": [ 448.0, @@ -10593,7 +13083,10 @@ 23 ], "id": 556, - "occupied": false, + "nodesOccupying": [ + 12884901900 + ], + "occupied": true, "position": [ 576.0, 3008.0 @@ -10610,7 +13103,10 @@ 23 ], "id": 557, - "occupied": false, + "nodesOccupying": [ + 12884901900 + ], + "occupied": true, "position": [ 704.0, 3008.0 @@ -10627,7 +13123,10 @@ 23 ], "id": 558, - "occupied": false, + "nodesOccupying": [ + 12884901898 + ], + "occupied": true, "position": [ 832.0, 3008.0 @@ -10644,7 +13143,10 @@ 23 ], "id": 559, - "occupied": false, + "nodesOccupying": [ + 12884901898 + ], + "occupied": true, "position": [ 960.0, 3008.0 @@ -10661,7 +13163,10 @@ 23 ], "id": 560, - "occupied": false, + "nodesOccupying": [ + 12884901898 + ], + "occupied": true, "position": [ 1088.0, 3008.0 @@ -10678,6 +13183,7 @@ 23 ], "id": 561, + "nodesOccupying": [], "occupied": false, "position": [ 1216.0, @@ -10695,6 +13201,7 @@ 23 ], "id": 562, + "nodesOccupying": [], "occupied": false, "position": [ 1344.0, @@ -10712,6 +13219,7 @@ 23 ], "id": 563, + "nodesOccupying": [], "occupied": false, "position": [ 1472.0, @@ -10729,7 +13237,11 @@ 23 ], "id": 564, - "occupied": false, + "nodesOccupying": [ + 12884901898, + 12884901902 + ], + "occupied": true, "position": [ 1600.0, 3008.0 @@ -10746,6 +13258,7 @@ 23 ], "id": 565, + "nodesOccupying": [], "occupied": false, "position": [ 1728.0, @@ -10763,7 +13276,10 @@ 23 ], "id": 566, - "occupied": false, + "nodesOccupying": [ + 12884901902 + ], + "occupied": true, "position": [ 1856.0, 3008.0 @@ -10780,7 +13296,10 @@ 23 ], "id": 567, - "occupied": false, + "nodesOccupying": [ + 12884901902 + ], + "occupied": true, "position": [ 1984.0, 3008.0 @@ -10797,7 +13316,11 @@ 23 ], "id": 568, - "occupied": false, + "nodesOccupying": [ + 12884901902, + 12884901902 + ], + "occupied": true, "position": [ 2112.0, 3008.0 @@ -10814,6 +13337,7 @@ 23 ], "id": 569, + "nodesOccupying": [], "occupied": false, "position": [ 2240.0, @@ -10831,6 +13355,7 @@ 23 ], "id": 570, + "nodesOccupying": [], "occupied": false, "position": [ 2368.0, @@ -10848,6 +13373,7 @@ 23 ], "id": 571, + "nodesOccupying": [], "occupied": false, "position": [ 2496.0, @@ -10865,6 +13391,7 @@ 23 ], "id": 572, + "nodesOccupying": [], "occupied": false, "position": [ 2624.0, @@ -10882,6 +13409,7 @@ 23 ], "id": 573, + "nodesOccupying": [], "occupied": false, "position": [ 2752.0, @@ -10899,6 +13427,7 @@ 23 ], "id": 574, + "nodesOccupying": [], "occupied": false, "position": [ 2880.0, @@ -10915,6 +13444,7 @@ 23 ], "id": 575, + "nodesOccupying": [], "occupied": false, "position": [ 3008.0, @@ -10924,10 +13454,10 @@ ] }, "PLAYER": { - "name": "Anonymous", + "name": "Player", "position": [ - 434, - 1890 + 1011.9598388671875, + 1243.1861572265625 ], "rotation": 0.0, "scale": [ @@ -10938,7 +13468,7 @@ 128.0, 128.0 ], - "texture": "D:\\Projects\\DGame\\Assets\\Levels\\TestLevel\\Level1_Char.png", + "texture": "Level1_Char.png", "weapons": [ "sniper rifle", "glock" diff --git a/Assets/Levels/TestLevel/test123.dgl b/assets/levels/TestLevel/test123.dgl similarity index 100% rename from Assets/Levels/TestLevel/test123.dgl rename to assets/levels/TestLevel/test123.dgl diff --git a/Assets/Shaders/AfterEffects_fs.glsl b/assets/shaders/AfterEffects_fs.glsl similarity index 100% rename from Assets/Shaders/AfterEffects_fs.glsl rename to assets/shaders/AfterEffects_fs.glsl diff --git a/Assets/Shaders/AfterEffects_vs.glsl b/assets/shaders/AfterEffects_vs.glsl similarity index 100% rename from Assets/Shaders/AfterEffects_vs.glsl rename to assets/shaders/AfterEffects_vs.glsl diff --git a/Assets/Shaders/DefaultShader_fs.glsl b/assets/shaders/DefaultShader_fs.glsl similarity index 100% rename from Assets/Shaders/DefaultShader_fs.glsl rename to assets/shaders/DefaultShader_fs.glsl diff --git a/Assets/Shaders/DefaultShader_vs.glsl b/assets/shaders/DefaultShader_vs.glsl similarity index 100% rename from Assets/Shaders/DefaultShader_vs.glsl rename to assets/shaders/DefaultShader_vs.glsl diff --git a/Assets/Shaders/Editor_fs.glsl b/assets/shaders/Editor_fs.glsl similarity index 100% rename from Assets/Shaders/Editor_fs.glsl rename to assets/shaders/Editor_fs.glsl diff --git a/Assets/Shaders/Editor_vs.glsl b/assets/shaders/Editor_vs.glsl similarity index 100% rename from Assets/Shaders/Editor_vs.glsl rename to assets/shaders/Editor_vs.glsl diff --git a/Assets/Shaders/Font_fs.glsl b/assets/shaders/Font_fs.glsl similarity index 100% rename from Assets/Shaders/Font_fs.glsl rename to assets/shaders/Font_fs.glsl diff --git a/Assets/Shaders/Font_vs.glsl b/assets/shaders/Font_vs.glsl similarity index 100% rename from Assets/Shaders/Font_vs.glsl rename to assets/shaders/Font_vs.glsl diff --git a/Assets/Shaders/LineShader_fs.glsl b/assets/shaders/LineShader_fs.glsl similarity index 100% rename from Assets/Shaders/LineShader_fs.glsl rename to assets/shaders/LineShader_fs.glsl diff --git a/Assets/Shaders/LineShader_vs.glsl b/assets/shaders/LineShader_vs.glsl similarity index 100% rename from Assets/Shaders/LineShader_vs.glsl rename to assets/shaders/LineShader_vs.glsl diff --git a/dependencies/CMakeLists.txt b/dependencies/CMakeLists.txt index e60c215a..a219c747 100644 --- a/dependencies/CMakeLists.txt +++ b/dependencies/CMakeLists.txt @@ -30,12 +30,12 @@ function(FIND_AND_DOWNLOAD_ZIP_RESOURCE ResourceURL ResourceName Version) endif() endfunction() -add_subdirectory(Glad) +add_subdirectory(glad) add_subdirectory(glfw) -add_subdirectory(Imgui) -add_subdirectory(Freetype) -add_subdirectory(STB_IMAGE) -add_subdirectory(GLM) -add_subdirectory(JSON) -add_subdirectory(FMT) +add_subdirectory(imgui) +add_subdirectory(freetype) +add_subdirectory(stb_image) +add_subdirectory(glm) +add_subdirectory(json) +add_subdirectory(fmt) diff --git a/dependencies/FMT/CMakeLists.txt b/dependencies/FMT/CMakeLists.txt deleted file mode 100644 index b7dad223..00000000 --- a/dependencies/FMT/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -FIND_AND_DOWNLOAD_GIT_RESOURCE(FMT https://github.com/fmtlib/fmt.git) -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/FMT) diff --git a/dependencies/Imgui/CMakeLists.txt b/dependencies/Imgui/CMakeLists.txt deleted file mode 100644 index 72f39747..00000000 --- a/dependencies/Imgui/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -FIND_AND_DOWNLOAD_GIT_RESOURCE(IMGUI https://github.com/ocornut/imgui.git) - -set(HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/IMGUI/imconfig.h" "${CMAKE_CURRENT_SOURCE_DIR}/IMGUI/imgui.h" "${CMAKE_CURRENT_SOURCE_DIR}/IMGUI/imgui_internal.h" - "${CMAKE_CURRENT_SOURCE_DIR}/IMGUI/imstb_rectpack.h" "${CMAKE_CURRENT_SOURCE_DIR}/IMGUI/imstb_textedit.h" "${CMAKE_CURRENT_SOURCE_DIR}/IMGUI/imstb_truetype.h" - "${CMAKE_CURRENT_SOURCE_DIR}/IMGUI/backends/imgui_impl_glfw.h" "${CMAKE_CURRENT_SOURCE_DIR}/IMGUI/backends/imgui_impl_opengl3.h") - -set(SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/IMGUI/imgui.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/IMGUI/imgui_demo.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/IMGUI/imgui_draw.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/IMGUI/imgui_tables.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/IMGUI/backends/imgui_impl_opengl3.cpp" - "${CMAKE_CURRENT_SOURCE_DIR}/IMGUI/backends/imgui_impl_glfw.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/IMGUI/imgui_widgets.cpp") - -add_library(IMGUI STATIC ${HEADERS} ${SOURCES}) -target_include_directories(IMGUI SYSTEM PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/IMGUI/" "${CMAKE_CURRENT_SOURCE_DIR}/IMGUI/backends") - -# Needed for backend code -target_link_libraries(IMGUI PRIVATE glfw GLAD) diff --git a/dependencies/JSON/CMakeLists.txt b/dependencies/JSON/CMakeLists.txt deleted file mode 100644 index 621d6b31..00000000 --- a/dependencies/JSON/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -#JSON -FIND_AND_DOWNLOAD_GIT_RESOURCE(JSON https://github.com/nlohmann/json.git) - -set(JSON_BuildTests OFF CACHE INTERNAL "") -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/JSON) - diff --git a/dependencies/STB_IMAGE/CMakeLists.txt b/dependencies/STB_IMAGE/CMakeLists.txt deleted file mode 100644 index b706305e..00000000 --- a/dependencies/STB_IMAGE/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -FIND_AND_DOWNLOAD_GIT_RESOURCE(STB_IMAGE https://github.com/nothings/stb.git) -add_library(STB_IMAGE INTERFACE IMPORTED GLOBAL) -target_include_directories(STB_IMAGE INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/STB_IMAGE") diff --git a/dependencies/fmt/CMakeLists.txt b/dependencies/fmt/CMakeLists.txt new file mode 100644 index 00000000..1ea717a0 --- /dev/null +++ b/dependencies/fmt/CMakeLists.txt @@ -0,0 +1,2 @@ +FIND_AND_DOWNLOAD_GIT_RESOURCE(fmt https://github.com/fmtlib/fmt.git) +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/fmt) diff --git a/dependencies/Freetype/CMakeLists.txt b/dependencies/freetype/CMakeLists.txt similarity index 100% rename from dependencies/Freetype/CMakeLists.txt rename to dependencies/freetype/CMakeLists.txt diff --git a/dependencies/Glad/CMakeLists.txt b/dependencies/glad/CMakeLists.txt similarity index 71% rename from dependencies/Glad/CMakeLists.txt rename to dependencies/glad/CMakeLists.txt index 4502f7a1..b33c039a 100644 --- a/dependencies/Glad/CMakeLists.txt +++ b/dependencies/glad/CMakeLists.txt @@ -1,8 +1,8 @@ file(GLOB HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/glad/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/include/KHR/*.h") file(GLOB SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c") -add_library(GLAD STATIC ${HEADERS} ${SOURCES} ) +add_library(glad STATIC ${HEADERS} ${SOURCES} ) #target_sources(GLAD PUBLIC ) -target_include_directories(GLAD SYSTEM PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include/") +target_include_directories(glad SYSTEM PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include/") # For linux we may need to add -ldl #target_link_libraries (GLAD INTERFACE opengl32) diff --git a/dependencies/Glad/include/KHR/khrplatform.h b/dependencies/glad/include/KHR/khrplatform.h similarity index 100% rename from dependencies/Glad/include/KHR/khrplatform.h rename to dependencies/glad/include/KHR/khrplatform.h diff --git a/dependencies/Glad/include/glad/glad.h b/dependencies/glad/include/glad/glad.h similarity index 100% rename from dependencies/Glad/include/glad/glad.h rename to dependencies/glad/include/glad/glad.h diff --git a/dependencies/Glad/src/glad.c b/dependencies/glad/src/glad.c similarity index 100% rename from dependencies/Glad/src/glad.c rename to dependencies/glad/src/glad.c diff --git a/dependencies/GLM/CMakeLists.txt b/dependencies/glm/CMakeLists.txt similarity index 100% rename from dependencies/GLM/CMakeLists.txt rename to dependencies/glm/CMakeLists.txt diff --git a/dependencies/imgui/CMakeLists.txt b/dependencies/imgui/CMakeLists.txt new file mode 100644 index 00000000..db7b139b --- /dev/null +++ b/dependencies/imgui/CMakeLists.txt @@ -0,0 +1,15 @@ +FIND_AND_DOWNLOAD_GIT_RESOURCE(imgui https://github.com/ocornut/imgui.git) + +set(HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/imgui/imconfig.h" "${CMAKE_CURRENT_SOURCE_DIR}/imgui/imgui.h" "${CMAKE_CURRENT_SOURCE_DIR}/imgui/imgui_internal.h" + "${CMAKE_CURRENT_SOURCE_DIR}/imgui/imstb_rectpack.h" "${CMAKE_CURRENT_SOURCE_DIR}/imgui/imstb_textedit.h" "${CMAKE_CURRENT_SOURCE_DIR}/imgui/imstb_truetype.h" + "${CMAKE_CURRENT_SOURCE_DIR}/imgui/backends/imgui_impl_glfw.h" "${CMAKE_CURRENT_SOURCE_DIR}/imgui/backends/imgui_impl_opengl3.h") + +set(SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/imgui/imgui.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/imgui/imgui_demo.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/imgui/imgui_draw.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/imgui/imgui_tables.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/imgui/backends/imgui_impl_opengl3.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/imgui/backends/imgui_impl_glfw.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/imgui/imgui_widgets.cpp") + +add_library(imgui STATIC ${HEADERS} ${SOURCES}) +target_include_directories(imgui SYSTEM PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/imgui/" "${CMAKE_CURRENT_SOURCE_DIR}/imgui/backends") + +# Needed for backend code +target_link_libraries(imgui PRIVATE glfw glad) diff --git a/dependencies/json/CMakeLists.txt b/dependencies/json/CMakeLists.txt new file mode 100644 index 00000000..4df3b6a4 --- /dev/null +++ b/dependencies/json/CMakeLists.txt @@ -0,0 +1,5 @@ +FIND_AND_DOWNLOAD_GIT_RESOURCE(json https://github.com/nlohmann/json.git) + +set(JSON_BuildTests OFF CACHE INTERNAL "") +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/json) + diff --git a/dependencies/stb_image/CMakeLists.txt b/dependencies/stb_image/CMakeLists.txt new file mode 100644 index 00000000..ba4fe0a8 --- /dev/null +++ b/dependencies/stb_image/CMakeLists.txt @@ -0,0 +1,3 @@ +FIND_AND_DOWNLOAD_GIT_RESOURCE(stb_image https://github.com/nothings/stb.git) +add_library(stb_image INTERFACE IMPORTED GLOBAL) +target_include_directories(stb_image INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/stb_image") diff --git a/editor/Editor.cpp b/editor/Editor.cpp index 79d4ea0c..1579b333 100644 --- a/editor/Editor.cpp +++ b/editor/Editor.cpp @@ -1,4 +1,5 @@ #include "Editor.hpp" +#include "EditorGUI.hpp" #include "Enemy.hpp" #include "Game.hpp" #include "InputManager.hpp" @@ -16,7 +17,7 @@ namespace dgame { Editor::Editor(const glm::ivec2& screenSize) : m_gui(*this) { - Logger::SetLogType(Logger::TYPE::DEBUG); + Logger::SetLogType(Logger::Type::DEBUG); m_logger.Init("Editor"); m_window = std::make_unique< Window >(screenSize.x, screenSize.y, "Editor"); @@ -48,7 +49,7 @@ Editor::HandleCamera() auto cameraMoveBy = glm::vec2(); - if (!m_gui.IsBlockingEvents() && m_levelLoaded) + if (!EditorGUI::IsBlockingEvents() && m_levelLoaded) { if (InputManager::CheckKeyPressed(GLFW_KEY_W)) { @@ -90,12 +91,26 @@ Editor::KeyCallback(const KeyEvent& event) ActionOnObject(ACTION::REMOVE); } } + else if (event.m_action == GLFW_RELEASE) + { + + if (m_gameObjectSelected && event.m_key == GLFW_KEY_C) + { + m_logger.Log(Logger::Type::INFO, "Copy object!"); + m_copiedGameObject = m_currentSelectedGameObject; + } + if (m_copiedGameObject && event.m_key == GLFW_KEY_V) + { + m_logger.Log(Logger::Type::INFO, "Paste object!"); + CopyGameObject(m_copiedGameObject); + } + } } void Editor::MouseScrollCallback(const MouseScrollEvent& event) { - if (!m_playGame && !m_gui.IsBlockingEvents() && m_levelLoaded) + if (!m_playGame && !EditorGUI::IsBlockingEvents() && m_levelLoaded) { m_camera.Zoom(static_cast< float >(event.m_xOffset + event.m_yOffset)); } @@ -104,7 +119,7 @@ Editor::MouseScrollCallback(const MouseScrollEvent& event) void Editor::MouseButtonCallback(const MouseButtonEvent& event) { - if (!m_playGame && !m_gui.IsBlockingEvents() && m_levelLoaded) + if (!m_playGame && !EditorGUI::IsBlockingEvents() && m_levelLoaded) { const auto mousePressed = event.m_action == GLFW_PRESS; m_mousePressedLastUpdate = mousePressed; @@ -129,7 +144,7 @@ Editor::MouseButtonCallback(const MouseButtonEvent& event) void Editor::CursorPositionCallback(const CursorPositionEvent& event) { - if (!m_playGame && !m_gui.IsBlockingEvents() && m_levelLoaded) + if (!m_playGame && !EditorGUI::IsBlockingEvents() && m_levelLoaded) { const auto currentCursorPosition = glm::vec2(event.m_xPos, event.m_yPos); @@ -187,13 +202,6 @@ Editor::HandleMouseDrag(const glm::vec2& currentCursorPos, const glm::vec2& axis // Move camera (or currently selected Object) else { - auto mouseMovementLength = glm::length(axis); - - constexpr auto minCameraMovement = 1.0f; - constexpr auto maxCameraMovement = 2.0f; - - mouseMovementLength = glm::clamp(mouseMovementLength, minCameraMovement, maxCameraMovement); - const auto& moveBy = glm::vec3(axis.x, axis.y, 0.0f); if (m_movementOnEditorObject || m_movementOnGameObject) @@ -214,8 +222,7 @@ Editor::HandleMouseDrag(const glm::vec2& currentCursorPos, const glm::vec2& axis auto animatable = std::dynamic_pointer_cast< Animatable >(m_currentSelectedGameObject); if (animatable) { - animatable->SetAnimationStartLocation( - m_currentSelectedGameObject->GetPosition()); + animatable->SetAnimationStartLocation(m_currentSelectedGameObject->GetPosition()); UpdateAnimationData(); } } @@ -246,7 +253,7 @@ Editor::SetMouseOnObject() } void -Editor::HandleGameObjectSelected(std::shared_ptr< GameObject > newSelectedGameObject, bool fromGUI) +Editor::HandleGameObjectSelected(const std::shared_ptr< GameObject >& newSelectedGameObject, bool fromGUI) { if (m_currentSelectedGameObject != newSelectedGameObject) { @@ -307,7 +314,7 @@ Editor::UnselectGameObject() } void -Editor::HandleEditorObjectSelected(std::shared_ptr< EditorObject > newSelectedEditorObject, +Editor::HandleEditorObjectSelected(const std::shared_ptr< EditorObject >& newSelectedEditorObject, bool fromGUI) { if (m_editorObjectSelected && (newSelectedEditorObject != m_currentEditorObjectSelected)) @@ -476,8 +483,7 @@ Editor::DrawAnimationPoints() object->GetLinkedObjectID()); if (it != animaltionPointIDs.end()) { - Renderer::DrawLine(lineStart, object->GetPosition(), - {1.0f, 0.0f, 1.0f, 1.0f}); + Renderer::DrawLine(lineStart, object->GetPosition(), {1.0f, 0.0f, 1.0f, 1.0f}); lineStart = object->GetCenteredPosition(); object->Render(); @@ -566,6 +572,23 @@ Editor::CreateLevel(const glm::ivec2& size) m_currentLevel->Create(this, size); m_currentLevel->LoadShaders("Editor"); + // Populate editor objects + const auto& pathfinderNodes = m_currentLevel->GetPathfinder().GetAllNodes(); + std::transform(pathfinderNodes.begin(), pathfinderNodes.end(), + std::back_inserter(m_editorObjects), [this](const auto& node) { + const auto tileSize = m_currentLevel->GetTileSize(); + + auto pathfinderNode = std::make_shared< EditorObject >( + *this, node.m_position, glm::ivec2(tileSize, tileSize), "white.png", + node.GetID()); + + pathfinderNode->SetIsBackground(true); + pathfinderNode->SetVisible(m_renderPathfinderNodes); + pathfinderNode->SetColor(glm::vec3{1.0f, 1.0f, 1.0f}); + + return pathfinderNode; + }); + m_camera.Create(glm::vec3(m_currentLevel->GetLevelPosition(), 0.0f), m_window->GetSize()); m_camera.SetLevelSize(m_currentLevel->GetSize()); @@ -617,7 +640,7 @@ Editor::LoadLevel(const std::string& levelPath) for (const auto& point : animationPoints) { auto editorObject = std::make_shared< EditorObject >( - *this, point.m_end, glm::ivec2(20, 20), "Default128.png", point.GetID()); + *this, point.m_end, glm::ivec2(20, 20), "NodeSprite.png", point.GetID()); editorObject->SetName("Animationpoint" + object->GetName()); m_editorObjects.push_back(editorObject); @@ -646,30 +669,40 @@ Editor::AddGameObject(GameObject::TYPE objectType) HandleGameObjectSelected(m_currentLevel->AddGameObject(objectType)); } +void +Editor::CopyGameObject(const std::shared_ptr& objectToCopy) +{ + // For now we only copy type/size/collision/sprite + + auto newObject = m_currentLevel->AddGameObject(objectToCopy->GetType()); + newObject->SetSize(objectToCopy->GetSize()); + newObject->SetHasCollision(objectToCopy->GetHasCollision()); + newObject->GetSprite().SetTextureFromFile(objectToCopy->GetSprite().GetTextureName()); + + HandleGameObjectSelected(newObject); +} + void Editor::AddObject(Object::TYPE objectType) { std::shared_ptr< EditorObject > newObject; - switch (objectType) + if (objectType == Object::TYPE::ANIMATION_POINT) { - case Object::TYPE::ANIMATION_POINT: { - if (!m_currentSelectedGameObject) - { - m_logger.Log(Logger::TYPE::WARNING, - "Added new Animation point without currently selected object!"); - } - auto animatablePtr = std::dynamic_pointer_cast< Animatable >(m_currentSelectedGameObject); - auto newNode = animatablePtr->CreateAnimationNode(m_currentSelectedGameObject->GetID()); - newObject = std::make_shared< EditorObject >(*this, newNode.m_end, glm::ivec2(20, 20), - "Default128.png", newNode.GetID()); - - m_editorObjects.push_back(newObject); - animatablePtr->ResetAnimation(); + if (!m_currentSelectedGameObject) + { + m_logger.Log(Logger::Type::WARNING, + "Added new Animation point without currently selected object!"); } - break; + auto animatablePtr = std::dynamic_pointer_cast< Animatable >(m_currentSelectedGameObject); + auto newNode = animatablePtr->CreateAnimationNode( + m_currentSelectedGameObject->GetID(), + m_currentSelectedGameObject->GetPosition() + + static_cast< glm::vec2 >(m_currentSelectedGameObject->GetSize())); + newObject = std::make_shared< EditorObject >(*this, newNode.m_end, glm::ivec2(20, 20), + "NodeSprite.png", newNode.GetID()); - default: - break; + m_editorObjects.push_back(newObject); + animatablePtr->ResetAnimation(); } HandleEditorObjectSelected(newObject); @@ -691,7 +724,7 @@ Editor::ToggleAnimateObject() } bool -Editor::IsObjectAnimated() +Editor::IsObjectAnimated() const { return m_animateGameObject; } @@ -707,7 +740,7 @@ Editor::LaunchGameLoop() { // Clear rednerer data Renderer::Shutdown(); - m_gui.Shutdown(); + EditorGUI::Shutdown(); m_game = std::make_unique< Game >(); m_game->Init("GameInit.txt"); @@ -729,11 +762,11 @@ std::shared_ptr< EditorObject > Editor::GetEditorObjectByID(Object::ID ID) { auto editorObject = - std::find_if(m_editorObjects.begin(), m_editorObjects.end(), [ID](const auto& editorObject) { - return editorObject->GetLinkedObjectID() == ID; + std::find_if(m_editorObjects.begin(), m_editorObjects.end(), [ID](const auto& object) { + return object->GetLinkedObjectID() == ID; }); - assert(editorObject != m_editorObjects.end()); + assert(editorObject != m_editorObjects.end()); // NOLINT return *editorObject; } @@ -857,13 +890,13 @@ Editor::GetViewMatrix() const } float -Editor::GetZoomLevel() +Editor::GetZoomLevel() const { return m_camera.GetZoomLevel(); } bool -Editor::IsRunning() +Editor::IsRunning() const { return m_isRunning; } diff --git a/editor/Editor.hpp b/editor/Editor.hpp index 44b6355b..1bfed5c8 100644 --- a/editor/Editor.hpp +++ b/editor/Editor.hpp @@ -21,8 +21,7 @@ class Window; class Editor : public Application { public: - Editor(const glm::ivec2& screenSize); - ~Editor() override = default; + explicit Editor(const glm::ivec2& screenSize); // APPLICATION OVERRIDES void @@ -38,7 +37,7 @@ class Editor : public Application GetViewMatrix() const override; float - GetZoomLevel() override; + GetZoomLevel() const override; void KeyCallback(const KeyEvent& event) override; @@ -60,14 +59,17 @@ class Editor : public Application CreateLevel(const glm::ivec2& size); void - LoadLevel(const std::string& levelName); + LoadLevel(const std::string& levelPath); void - SaveLevel(const std::string& levelName); + SaveLevel(const std::string& levelPath); void AddGameObject(GameObject::TYPE objectType); + void + CopyGameObject(const std::shared_ptr& objectToCopy); + void AddObject(Object::TYPE objectType); @@ -75,7 +77,7 @@ class Editor : public Application ToggleAnimateObject(); bool - IsObjectAnimated(); + IsObjectAnimated() const; void PlayLevel(); @@ -90,7 +92,7 @@ class Editor : public Application SetRenderAnimationPoints(bool render); void - SetLockAnimationPoints(bool render); + SetLockAnimationPoints(bool lock); void Update(); @@ -111,14 +113,14 @@ class Editor : public Application GetGridData() const; void - HandleGameObjectSelected(std::shared_ptr< GameObject > newSelectedGameObject, + HandleGameObjectSelected(const std::shared_ptr< GameObject >& newSelectedGameObject, bool fromGUI = false); void HandleObjectSelected(Object::ID objectID, bool fromGUI); void - HandleEditorObjectSelected(std::shared_ptr< EditorObject > newSelectedObject, + HandleEditorObjectSelected(const std::shared_ptr< EditorObject >& newSelectedEditorObject, bool fromGUI = false); private: @@ -128,7 +130,6 @@ class Editor : public Application REMOVE }; - private: std::shared_ptr< EditorObject > GetEditorObjectByID(Object::ID ID); @@ -148,7 +149,7 @@ class Editor : public Application DrawBoundingBoxes(); bool - IsRunning() override; + IsRunning() const override; void HandleCamera(); @@ -184,7 +185,7 @@ class Editor : public Application bool m_mousePressedLastUpdate = false; bool m_mouseDrag = false; - glm::vec2 m_lastCursorPosition; + glm::vec2 m_lastCursorPosition = {}; std::unique_ptr< byte_vec4 > m_collision = nullptr; @@ -194,6 +195,8 @@ class Editor : public Application bool m_gameObjectSelected = false; std::shared_ptr< GameObject > m_currentSelectedGameObject; + std::shared_ptr< GameObject > m_copiedGameObject; + // Handling of editor objects (drawable objects linked to object in game) bool m_movementOnEditorObject = false; bool m_editorObjectSelected = false; diff --git a/editor/EditorObject.cpp b/editor/EditorObject.cpp index a626db93..fbfb3f85 100644 --- a/editor/EditorObject.cpp +++ b/editor/EditorObject.cpp @@ -7,16 +7,13 @@ namespace dgame { EditorObject::EditorObject(Editor& editor, const glm::vec2& positionOnMap, const glm::ivec2& size, const std::string& sprite, Object::ID linkedObject) - : m_editor(editor) + : m_editor(editor), + m_position(positionOnMap), + m_centeredPosition(positionOnMap), + m_objectID(linkedObject), + m_hasLinkedObject(true) { - m_position = m_editor.GetLevel().GetGlobalVec(positionOnMap); - m_position = positionOnMap; m_sprite.SetSpriteTextured(m_position, size, sprite); - m_centeredPosition = m_sprite.GetPosition(); - - m_centeredPosition = m_editor.GetLevel().GetLocalVec(m_centeredPosition); - m_objectID = linkedObject; - m_hasLinkedObject = true; } bool @@ -169,7 +166,7 @@ EditorObject::GetName() const } Object::ID -EditorObject::GetLinkedObjectID() +EditorObject::GetLinkedObjectID() const { return m_objectID; } @@ -290,6 +287,11 @@ EditorObject::Render() } break; + case Object::TYPE::ANIMATION_POINT: { + m_sprite.Render(); + } + break; + default: { } } @@ -303,7 +305,7 @@ EditorObject::SetVisible(bool visible) } bool -EditorObject::IsVisible() +EditorObject::IsVisible() const { return m_visible; } diff --git a/editor/EditorObject.hpp b/editor/EditorObject.hpp index 3483c764..7198e2f3 100644 --- a/editor/EditorObject.hpp +++ b/editor/EditorObject.hpp @@ -18,7 +18,7 @@ class EditorObject EditorObject(Editor& editor, const glm::vec2& positionOnMap, const glm::ivec2& size, const std::string& sprite, Object::ID linkedObject); - bool + [[nodiscard]] bool Visible() const; // SETERS @@ -28,7 +28,7 @@ class EditorObject void SetIsBackground(bool isBackground); - bool + [[nodiscard]] bool GetIsBackground() const; void @@ -43,39 +43,39 @@ class EditorObject void SetVisible(bool visible); - bool - IsVisible(); + [[nodiscard]] bool + IsVisible() const; // Get size of object - glm::ivec2 + [[nodiscard]] glm::ivec2 GetSize() const; // Get centered position in global(OpenGL) coords - glm::vec2 + [[nodiscard]] glm::vec2 GetCenteredPosition() const; // Get position in global (OpenGL) coords - glm::vec2 + [[nodiscard]] glm::vec2 GetPosition() const; - bool + [[nodiscard]] bool CheckIfCollidedScreenPosion(const glm::vec2& screenPosition) const; // Get position in (0,0) to (WIDTH, HEIGHT) screen coords (0,0 BEING TOP LEFT CORNER) - glm::vec2 + [[nodiscard]] glm::vec2 GetScreenPositionPixels() const; - const Sprite& + [[nodiscard]] const Sprite& GetSprite() const; Sprite& GetSprite(); - std::string + [[nodiscard]] std::string GetName() const; - Object::ID - GetLinkedObjectID(); + [[nodiscard]] Object::ID + GetLinkedObjectID() const; void DeleteLinkedObject(); @@ -116,6 +116,8 @@ class EditorObject SetObjectUnselected(); private: + Editor& m_editor; + // global position (in OpenGL coords) glm::vec2 m_position; @@ -130,7 +132,7 @@ class EditorObject // Linked object's ID Object::ID m_objectID = Object::INVALID_ID; bool m_hasLinkedObject = false; - Editor& m_editor; + bool m_selected = false; bool m_isBackground = false; diff --git a/editor/GUI/EditorGUI.cpp b/editor/GUI/EditorGUI.cpp index 5887c0c2..288053fc 100644 --- a/editor/GUI/EditorGUI.cpp +++ b/editor/GUI/EditorGUI.cpp @@ -2,12 +2,13 @@ #include "Animatable.hpp" #include "Editor.hpp" #include "GameObject.hpp" -#include "Utils.hpp" #include #include +#include #include #include +#include namespace dgame { @@ -15,7 +16,7 @@ static inline void SetStyle() { ImGuiStyle& style = ImGui::GetStyle(); - auto* colors = style.Colors; + auto* colors = style.Colors; // NOLINT /// 0 = FLAT APPEARENCE /// 1 = MORE "3D" LOOK @@ -115,7 +116,7 @@ EditorGUI::Init() IMGUI_CHECKVERSION(); ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); - io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls + io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls NOLINT // Setup Dear ImGui style ImGui::StyleColorsDark(); @@ -128,38 +129,27 @@ EditorGUI::Init() void EditorGUI::Shutdown() { - ImGui_ImplOpenGL3_Shutdown(); ImGui_ImplGlfw_Shutdown(); + ImGui_ImplOpenGL3_Shutdown(); ImGui::DestroyContext(); } bool EditorGUI::IsBlockingEvents() { - ImGuiIO& io = ImGui::GetIO(); + const ImGuiIO& io = ImGui::GetIO(); return io.WantCaptureMouse || io.WantTextInput; } void -EditorGUI::Render() +EditorGUI::RenderMainPanel() { - ImGui_ImplOpenGL3_NewFrame(); - ImGui_ImplGlfw_NewFrame(); - ImGui::NewFrame(); - - const auto size = m_parent.GetWindowSize(); - - m_windowWidth = size.x / 7; - const auto toolsWindowHeight = 60; - const auto levelWindowHeight = size.y - toolsWindowHeight; - const auto gameObjectWindowHeight = size.y; - const auto debugWindowWidth = size.x - 2 * m_windowWidth; - const auto debugWindowHeight = 100; - ImGui::SetNextWindowPos({0, 0}); - ImGui::SetNextWindowSize(ImVec2(m_windowWidth, toolsWindowHeight)); + ImGui::SetNextWindowSize(ImVec2(m_windowWidth, m_toolsWindowHeight)); ImGui::Begin("Tools"); - ImGui::PushStyleColor(ImGuiCol_Button, {0.45f, 0.0f, 0.2f, 0.8f}); + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{0.45f, 0.0f, 0.2f, 0.8f}); + ImGui::BeginDisabled(m_currentLevel == nullptr); + if (ImGui::Button("Play")) { m_parent.PlayLevel(); @@ -169,16 +159,18 @@ EditorGUI::Render() ImGui::SameLine(); if (ImGui::Button("Save")) { - auto levelName = file_dialog({{"dgl", "DGame Level"}}, true); + auto levelName = FileManager::FileDialog(LEVELS_DIR, {{"DGame Level file", "dgl"}}, true); if (!levelName.empty()) { m_parent.SaveLevel(levelName); } } + ImGui::EndDisabled(); + ImGui::SameLine(); if (ImGui::Button("Load")) { - auto levelName = file_dialog({{"dgl", "DGame Level"}}, false); + auto levelName = FileManager::FileDialog(LEVELS_DIR, {{"DGame Level file", "dgl"}}, false); if (!levelName.empty()) { m_parent.LoadLevel(levelName); @@ -190,272 +182,303 @@ EditorGUI::Render() m_parent.CreateLevel({3072, 3072}); } ImGui::End(); +} - if (m_currentLevel) - { - ImGui::SetNextWindowPos({0, toolsWindowHeight}); - ImGui::SetNextWindowSize(ImVec2(m_windowWidth, levelWindowHeight)); - ImGui::Begin("Level"); +void +EditorGUI::RenderLevelMenu() // NOLINT +{ + ImGui::SetNextWindowPos({0, m_toolsWindowHeight}); + ImGui::SetNextWindowSize(ImVec2(m_windowWidth, m_levelWindowHeight)); + ImGui::Begin("Level"); - ImGui::SetNextTreeNodeOpen(true); - if (ImGui::CollapsingHeader("General")) + ImGui::SetNextItemOpen(true); + if (ImGui::CollapsingHeader("General")) + { + auto sprite_size = m_currentLevel->GetSprite().GetSize(); + if (ImGui::InputInt2("Size", &sprite_size.x)) { - auto sprite_size = m_currentLevel->GetSprite().GetSize(); - if (ImGui::InputInt2("Size", &sprite_size.x)) - { - m_currentLevel->SetSize(sprite_size); - } - - auto [drawGrid, gridSize] = m_parent.GetGridData(); - if (ImGui::InputInt("cell size", &gridSize) || ImGui::Checkbox("Draw grid", &drawGrid)) - { - m_parent.SetGridData(drawGrid, gridSize); - } + m_currentLevel->SetSize(sprite_size); } - ImGui::SetNextTreeNodeOpen(true); - if (ImGui::CollapsingHeader("Pathfinder")) + auto [drawGrid, gridSize] = m_parent.GetGridData(); + if (ImGui::InputInt("cell size", &gridSize) || ImGui::Checkbox("Draw grid", &drawGrid)) { - static bool renderPathfinderNodes = m_parent.GetRenderNodes(); - if (ImGui::Checkbox("Render nodes", &renderPathfinderNodes)) - { - m_parent.RenderNodes(renderPathfinderNodes); - } + m_parent.SetGridData(drawGrid, gridSize); } + } - ImGui::SetNextTreeNodeOpen(true); - if (ImGui::CollapsingHeader("Shader")) + ImGui::SetNextItemOpen(true); + if (ImGui::CollapsingHeader("Pathfinder")) + { + static bool renderPathfinderNodes = m_parent.GetRenderNodes(); + if (ImGui::Checkbox("Render nodes", &renderPathfinderNodes)) { + m_parent.RenderNodes(renderPathfinderNodes); } + } - ImGui::SetNextTreeNodeOpen(true); - if (ImGui::CollapsingHeader("Objects")) - { - const auto& gameObjects = m_currentLevel->GetObjects(); + ImGui::SetNextItemOpen(true); + if (ImGui::CollapsingHeader("Shader")) + { + } + + ImGui::SetNextItemOpen(true); + if (ImGui::CollapsingHeader("Objects")) + { + const auto& gameObjects = m_currentLevel->GetObjects(); - const auto items = std::to_array< std::string >({"Enemy", "Player", "Object"}); - ImGui::SetNextItemWidth(m_windowWidth * 0.95f); + const auto items = std::to_array< std::string >({"Enemy", "Player", "Object"}); + ImGui::SetNextItemWidth(m_windowWidth * 0.95f); - // The second parameter is the label previewed before opening the combo. - if (ImGui::BeginCombo("##combo", "Add")) + // The second parameter is the label previewed before opening the combo. + if (ImGui::BeginCombo("##combo", "Add")) + { + for (const auto& item : items) { - for (uint32_t n = 0; n < items.size(); n++) + if (ImGui::Selectable(item.c_str())) { - if (ImGui::Selectable(items[n].c_str())) - { - m_parent.AddGameObject(Object::GetTypeFromString(items[n])); - } + m_parent.AddGameObject(Object::GetTypeFromString(item)); } - ImGui::EndCombo(); } + ImGui::EndCombo(); + } - ImGui::BeginChild("Loaded Objects", {0, 200}, true); + ImGui::BeginChild("Loaded Objects", {0, 200}, true); - for (auto& object : gameObjects) - { - auto label = fmt::format("[{}] {} ({}, {})", object->GetTypeString().c_str(), - object->GetName().c_str(), object->GetPosition().x, - object->GetPosition().y); + for (const auto& object : gameObjects) + { + auto label = fmt::format("[{}] {} ({}, {})", object->GetTypeString().c_str(), + object->GetName().c_str(), object->GetPosition().x, + object->GetPosition().y); - if (ImGui::Selectable(label.c_str())) - { - m_parent.GetCamera().SetCameraAtPosition(object->GetPosition()); - m_parent.HandleGameObjectSelected(object, true); - } + if (ImGui::Selectable(label.c_str())) + { + m_parent.GetCamera().SetCameraAtPosition(object->GetPosition()); + m_parent.HandleGameObjectSelected(object, true); } - - ImGui::EndChild(); } + ImGui::EndChild(); + } - ImGui::End(); - - ImGui::SetNextWindowPos({m_windowWidth, size.y - debugWindowHeight}); - ImGui::SetNextWindowSize(ImVec2(debugWindowWidth, debugWindowHeight)); - ImGui::Begin("Debug"); - const auto cameraPos = m_parent.GetCamera().GetPosition(); - ImGui::Text("Camera Position %f, %f", static_cast< double >(cameraPos.x), - static_cast< double >(cameraPos.y)); - const auto cameraZoom = m_parent.GetCamera().GetZoomLevel(); - ImGui::Text("Camera Zoom %f", static_cast< double >(cameraZoom)); + ImGui::End(); - const auto cursorOpengGLPos = m_parent.ScreenToGlobal(InputManager::GetMousePos()); - ImGui::Text("Cursor Position %f, %f", static_cast< double >(cursorOpengGLPos.x), - static_cast< double >(cursorOpengGLPos.y)); + ImGui::SetNextWindowPos({m_windowWidth, m_windowSize.y - m_debugWindowHeight}); + ImGui::SetNextWindowSize(ImVec2(m_debugWindowWidth, m_debugWindowHeight)); + ImGui::Begin("Debug"); + const auto cameraPos = m_parent.GetCamera().GetPosition(); + ImGui::Text("Camera Position %f, %f", static_cast< double >(cameraPos.x), + static_cast< double >(cameraPos.y)); - auto& pathfinder = m_parent.GetLevel().GetPathfinder(); - const auto nodeID = pathfinder.GetNodeIDFromPosition(cursorOpengGLPos); - Node curNode{}; + const auto cameraZoom = m_parent.GetCamera().GetZoomLevel(); + ImGui::Text("Camera Zoom %f", static_cast< double >(cameraZoom)); - if (nodeID != -1) - { - curNode = pathfinder.GetNodeFromID(nodeID); - } + const auto cursorOpengGLPos = m_parent.ScreenToGlobal(InputManager::GetMousePos()); + ImGui::Text("Cursor Position %f, %f", static_cast< double >(cursorOpengGLPos.x), + static_cast< double >(cursorOpengGLPos.y)); - ImGui::Text("Cursor on tile ID = %d Coords(%d, %d)", curNode.m_ID, curNode.m_xPos, - curNode.m_yPos); + auto& pathfinder = m_parent.GetLevel().GetPathfinder(); + const auto nodeID = pathfinder.GetNodeIDFromPosition(cursorOpengGLPos); + Node curNode{}; - ImGui::End(); + if (nodeID != -1) + { + curNode = pathfinder.GetNodeFromID(nodeID); } - if (m_currentlySelectedGameObject) - { - ImGui::SetNextWindowPos({size.x - m_windowWidth, 0}); - ImGui::SetNextWindowSize(ImVec2(m_windowWidth, gameObjectWindowHeight)); - ImGui::Begin("Game Object"); - ImGui::SetNextTreeNodeOpen(true); + ImGui::Text("Cursor on tile ID = %d Coords(%d, %d)", curNode.m_ID, curNode.m_xPos, + curNode.m_yPos); - if (ImGui::CollapsingHeader("General")) - { - auto name = m_currentlySelectedGameObject->GetName(); - const auto nameLength = 20; - name.resize(nameLength); + ImGui::End(); +} - auto type = m_currentlySelectedGameObject->GetTypeString(); +void +EditorGUI::RenderGameObjectMenu() // NOLINT +{ + ImGui::SetNextWindowPos({m_windowSize.x - m_windowWidth, 0}); + ImGui::SetNextWindowSize(ImVec2(m_windowWidth, m_gameObjectWindowHeight)); + ImGui::Begin("Game Object"); + ImGui::SetNextItemOpen(true); - ImGui::InputText("Type", &type[0], type.size(), ImGuiInputTextFlags_ReadOnly); + if (ImGui::CollapsingHeader("General")) + { + auto name = m_currentlySelectedGameObject->GetName(); + const auto nameLength = 20; + name.resize(nameLength); - if (ImGui::InputText("Name", &name[0], nameLength)) - { - m_currentlySelectedGameObject->SetName(name); - } + auto type = m_currentlySelectedGameObject->GetTypeString(); - auto collision = m_currentlySelectedGameObject->GetHasCollision(); - if (ImGui::Checkbox("Has Collision", &collision)) - { - m_currentlySelectedGameObject->SetHasCollision(collision); - } + ImGui::InputText("Type", type.data(), type.size(), ImGuiInputTextFlags_ReadOnly); + + if (ImGui::InputText("Name", name.data(), nameLength)) + { + m_currentlySelectedGameObject->SetName(name); } - ImGui::SetNextTreeNodeOpen(true); - if (ImGui::CollapsingHeader("Transform")) + auto collision = m_currentlySelectedGameObject->GetHasCollision(); + if (ImGui::Checkbox("Has Collision", &collision)) { - auto objectPosition = m_currentlySelectedGameObject->GetPosition(); - auto sprite_size = m_currentlySelectedGameObject->GetSprite().GetSize(); - auto rotation = - m_currentlySelectedGameObject->GetSprite().GetRotation(Sprite::RotationType::DEGREES); + m_currentlySelectedGameObject->SetHasCollision(collision); + } + } - ImGui::InputFloat2("Position", &objectPosition.x); + ImGui::SetNextItemOpen(true); + if (ImGui::CollapsingHeader("Transform")) + { + auto objectPosition = m_currentlySelectedGameObject->GetPosition(); + auto sprite_size = m_currentlySelectedGameObject->GetSprite().GetSize(); + auto rotation = + m_currentlySelectedGameObject->GetSprite().GetRotation(Sprite::RotationType::DEGREES); - if (ImGui::SliderInt2("Size", &sprite_size.x, 10, 1000)) - { - m_currentlySelectedGameObject->SetSize(sprite_size); - } + ImGui::InputFloat2("Position", &objectPosition.x); - if (ImGui::SliderFloat("Rotate", &rotation, glm::degrees(Sprite::s_ROTATIONRANGE.first), - glm::degrees(Sprite::s_ROTATIONRANGE.second))) - { - m_currentlySelectedGameObject->Rotate(glm::radians(rotation)); - } + if (ImGui::SliderInt2("Size", &sprite_size.x, 10, 1000)) + { + m_currentlySelectedGameObject->SetSize(sprite_size); } - ImGui::SetNextTreeNodeOpen(true); - if (ImGui::CollapsingHeader("Shader")) + if (ImGui::SliderFloat("Rotate", &rotation, glm::degrees(Sprite::s_ROTATIONRANGE.first), + glm::degrees(Sprite::s_ROTATIONRANGE.second))) + { + m_currentlySelectedGameObject->Rotate(glm::radians(rotation)); + } + } + + ImGui::SetNextItemOpen(true); + if (ImGui::CollapsingHeader("Shader")) + { + if (m_currentLevel) { - if (m_currentLevel) + auto& sprite = m_currentlySelectedGameObject->GetSprite(); + ImGui::Image(reinterpret_cast< void* >( // NOLINT + static_cast< size_t >(sprite.GetTexture().GetTextureHandle())), + {150, 150}); + ImGui::InputText("FileName", sprite.GetTextureName().data(), sprite.GetTextureName().size(), + ImGuiInputTextFlags_ReadOnly); + if (ImGui::Button("Change Texture")) { - auto& sprite = m_currentlySelectedGameObject->GetSprite(); - ImGui::Image(reinterpret_cast< void* >( - static_cast< size_t >(sprite.GetTexture().GetTextureHandle())), - {150, 150}); - ImGui::InputText("FileName", &sprite.GetTextureName()[0], - sprite.GetTextureName().size(), ImGuiInputTextFlags_ReadOnly); - if (ImGui::Button("Change Texture")) + auto textureName = FileManager::FileDialog( + IMAGES_DIR, {{"PNG texture", "png"}, {"JPEG texture", "jpg"}}, false); + if (!textureName.empty()) { - auto textureName = file_dialog({{"png", "jpg"}}, false); - if (!textureName.empty()) - { - sprite.SetTextureFromFile(textureName); - } + sprite.SetTextureFromFile(textureName); } } } + } + + if (m_currentlySelectedGameObject->GetType() == GameObject::TYPE::ENEMY) + { + const auto animatablePtr = + std::dynamic_pointer_cast< Animatable >(m_currentlySelectedGameObject); - if (m_currentlySelectedGameObject->GetType() == GameObject::TYPE::ENEMY) + ImGui::SetNextItemOpen(true); + if (ImGui::CollapsingHeader("Animation")) { - const auto animatablePtr = - std::dynamic_pointer_cast< Animatable >(m_currentlySelectedGameObject); + ImGui::Text("Type"); // NOLINT + ImGui::SameLine(); - ImGui::SetNextTreeNodeOpen(true); - if (ImGui::CollapsingHeader("Animation")) + if (ImGui::RadioButton("Loop", animatablePtr->GetAnimationType() + == Animatable::ANIMATION_TYPE::LOOP)) { - ImGui::Text("Type"); - ImGui::SameLine(); + animatablePtr->SetAnimationType(Animatable::ANIMATION_TYPE::LOOP); + } - if (ImGui::RadioButton("Loop", animatablePtr->GetAnimationType() - == Animatable::ANIMATION_TYPE::LOOP)) - { - animatablePtr->SetAnimationType(Animatable::ANIMATION_TYPE::LOOP); - } + ImGui::SameLine(); + if (ImGui::RadioButton("Reversal", animatablePtr->GetAnimationType() + == Animatable::ANIMATION_TYPE::REVERSABLE)) + { + animatablePtr->SetAnimationType(Animatable::ANIMATION_TYPE::REVERSABLE); + } - ImGui::SameLine(); - if (ImGui::RadioButton("Reversal", animatablePtr->GetAnimationType() - == Animatable::ANIMATION_TYPE::REVERSABLE)) - { - animatablePtr->SetAnimationType(Animatable::ANIMATION_TYPE::REVERSABLE); - } + bool animationVisible = animatablePtr->GetRenderAnimationSteps(); + if (ImGui::Checkbox("Animation points visible", &animationVisible)) + { + m_parent.SetRenderAnimationPoints(animationVisible); + } - bool animationVisible = animatablePtr->GetRenderAnimationSteps(); - if (ImGui::Checkbox("Animation points visible", &animationVisible)) - { - m_parent.SetRenderAnimationPoints(animationVisible); - } + if (ImGui::Button("Animate")) + { + m_parent.ToggleAnimateObject(); + } - if (ImGui::Button("Animate")) - { - m_parent.ToggleAnimateObject(); - } + static float timer = 0.0f; + const auto animationDuration = + static_cast< float >(Timer::ConvertToMs(animatablePtr->GetAnimationDuration()).count()); + if (m_parent.IsObjectAnimated()) + { + timer += static_cast< float >(m_parent.GetDeltaTime().count()); + timer = glm::min(animationDuration, timer); + } - static float timer = 0.0f; - const auto animationDuration = static_cast< float >( - Timer::ConvertToMs(animatablePtr->GetAnimationDuration()).count()); - if (m_parent.IsObjectAnimated()) - { - timer += static_cast< float >(m_parent.GetDeltaTime().count()); - timer = glm::min(animationDuration, timer); - } + ImGui::SameLine(); + if (ImGui::SliderFloat("", &timer, 0.0f, animationDuration, "%.3f ms")) + { + m_currentlySelectedGameObject->GetSprite().SetTranslateValue( + animatablePtr->SetAnimation(Timer::milliseconds(static_cast< uint64_t >(timer)))); + } - ImGui::SameLine(); - if (ImGui::SliderFloat("", &timer, 0.0f, animationDuration, "%.3f ms")) + // static int selected = 0; + auto animationPoints = animatablePtr->GetAnimationKeypoints(); + auto newNodePosition = m_currentlySelectedGameObject->GetPosition(); + ImGui::BeginChild("Animation Points", {0, 100}, true); + for (uint32_t i = 0; i < animationPoints.size(); ++i) + { + const auto& node = animationPoints[i]; + auto label = fmt::format("[{}] Pos({:.{}f},{:.{}f}) Time={}s", i, node.m_end.x, 1, + node.m_end.y, 1, node.m_timeDuration.count()); + if (ImGui::Selectable(label.c_str())) { - m_currentlySelectedGameObject->GetSprite().SetTranslateValue( - animatablePtr->SetAnimation(Timer::milliseconds(static_cast< uint64_t >(timer)))); + m_parent.GetCamera().SetCameraAtPosition(node.m_end); + m_parent.HandleObjectSelected(node.GetID(), true); + m_parent.SetRenderAnimationPoints(true); } - // static int selected = 0; - auto animationPoints = animatablePtr->GetAnimationKeypoints(); - auto newNodePosition = m_currentlySelectedGameObject->GetPosition(); - ImGui::BeginChild("Animation Points", {0, 100}, true); - for (uint32_t i = 0; i < animationPoints.size(); ++i) - { - const auto& node = animationPoints[i]; - auto label = fmt::format("[{}] Pos({:.{}f},{:.{}f}) Time={}s", i, node.m_end.x, 1, - node.m_end.y, 1, node.m_timeDuration.count()); - if (ImGui::Selectable(label.c_str())) - { - m_parent.GetCamera().SetCameraAtPosition(node.m_end); - m_parent.HandleObjectSelected(node.GetID(), true); - m_parent.SetRenderAnimationPoints(true); - } - - newNodePosition = node.m_end; - } + newNodePosition = node.m_end; + } - if (ImGui::Button("New")) - { - m_parent.GetCamera().SetCameraAtPosition(newNodePosition); - m_parent.AddObject(Object::TYPE::ANIMATION_POINT); - m_parent.SetRenderAnimationPoints(true); - } - ImGui::EndChild(); + if (ImGui::Button("New")) + { + m_parent.GetCamera().SetCameraAtPosition(newNodePosition); + m_parent.AddObject(Object::TYPE::ANIMATION_POINT); + m_parent.SetRenderAnimationPoints(true); } + ImGui::EndChild(); } + } + + ImGui::End(); +} - ImGui::End(); +void +EditorGUI::Render() +{ + ImGui_ImplOpenGL3_NewFrame(); + ImGui_ImplGlfw_NewFrame(); + ImGui::NewFrame(); + + m_windowSize = m_parent.GetWindowSize(); + + m_windowWidth = m_windowSize.x / 7; + m_toolsWindowHeight = 60; + m_levelWindowHeight = m_windowSize.y - m_toolsWindowHeight; + m_gameObjectWindowHeight = m_windowSize.y; + m_debugWindowWidth = m_windowSize.x - 2 * m_windowWidth; + m_debugWindowHeight = 100; + + RenderMainPanel(); + + if (m_currentLevel) + { + RenderLevelMenu(); } + if (m_currentlySelectedGameObject) + { + RenderGameObjectMenu(); + } ImGuiIO& io = ImGui::GetIO(); io.DisplaySize = ImVec2(m_parent.GetWindowSize().x, m_parent.GetWindowSize().y); @@ -464,7 +487,7 @@ EditorGUI::Render() } void -EditorGUI::GameObjectSelected(std::shared_ptr< GameObject > selectedGameObject) +EditorGUI::GameObjectSelected(const std::shared_ptr< GameObject >& selectedGameObject) { m_currentlySelectedGameObject = selectedGameObject; } @@ -475,7 +498,8 @@ EditorGUI::GameObjectUnselected() m_currentlySelectedGameObject = nullptr; } -void EditorGUI::EditorObjectSelected(std::shared_ptr< EditorObject > /*object*/) +void +EditorGUI::EditorObjectSelected(const std::shared_ptr< EditorObject >& /*object*/) { // m_currentlySelectedEditorObject = object; } @@ -487,16 +511,18 @@ EditorGUI::EditorObjectUnselected() } void -EditorGUI::LevelLoaded(std::shared_ptr< Level > levelLoaded) +EditorGUI::LevelLoaded(const std::shared_ptr< Level >& loadedLevel) { - m_currentLevel = levelLoaded; + m_currentLevel = loadedLevel; } -void EditorGUI::ObjectUpdated(Object::ID /*ID*/) +void +EditorGUI::ObjectUpdated(Object::ID /*ID*/) { } -void EditorGUI::ObjectDeleted(Object::ID /*ID*/) +void +EditorGUI::ObjectDeleted(Object::ID /*ID*/) { } diff --git a/editor/GUI/EditorGUI.hpp b/editor/GUI/EditorGUI.hpp index 37f6b701..b2cedb5b 100644 --- a/editor/GUI/EditorGUI.hpp +++ b/editor/GUI/EditorGUI.hpp @@ -2,10 +2,12 @@ #include "Object.hpp" +#include #include #include #include + namespace dgame { class Editor; @@ -19,32 +21,31 @@ class Level; class EditorGUI { public: - EditorGUI(Editor& parent); - ~EditorGUI() = default; + explicit EditorGUI(Editor& parent); void Init(); - void + static void Shutdown(); void Render(); void - GameObjectSelected(std::shared_ptr< GameObject > selectedGameObject); + GameObjectSelected(const std::shared_ptr< GameObject >& selectedGameObject); void GameObjectUnselected(); void - EditorObjectSelected(std::shared_ptr< EditorObject > object); + EditorObjectSelected(const std::shared_ptr< EditorObject >& object); void EditorObjectUnselected(); void - LevelLoaded(std::shared_ptr< Level > loadedLevel); + LevelLoaded(const std::shared_ptr< Level >& loadedLevel); void ObjectUpdated(Object::ID ID); @@ -52,17 +53,30 @@ class EditorGUI void ObjectDeleted(Object::ID ID); - bool + static bool IsBlockingEvents(); private: + void + RenderMainPanel(); + void + RenderLevelMenu(); + void + RenderGameObjectMenu(); + Editor& m_parent; // EditorObjectWindow m_editorObjectWindow; std::shared_ptr< GameObject > m_currentlySelectedGameObject; std::shared_ptr< Level > m_currentLevel; + glm::vec2 m_windowSize = glm::vec2{}; float m_windowWidth = 0.0f; + float m_toolsWindowHeight = 0.0f; + float m_gameObjectWindowHeight = 0.0f; + float m_levelWindowHeight = 0.0f; + float m_debugWindowHeight = 0.0f; + float m_debugWindowWidth = 0.0f; }; } // namespace dgame \ No newline at end of file diff --git a/engine/CMakeLists.txt b/engine/CMakeLists.txt index e91adb88..bccb2fa8 100644 --- a/engine/CMakeLists.txt +++ b/engine/CMakeLists.txt @@ -11,7 +11,7 @@ target_include_directories(${MODULE_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}" " "${CMAKE_CURRENT_SOURCE_DIR}/Logger" "${CMAKE_CURRENT_SOURCE_DIR}/Render" "${CMAKE_CURRENT_SOURCE_DIR}/Time" "${CMAKE_CURRENT_SOURCE_DIR}/Window") -target_link_libraries_system (${MODULE_NAME} PUBLIC glm glfw GLAD STB_IMAGE freetype nlohmann_json::nlohmann_json fmt IMGUI) +target_link_libraries_system (${MODULE_NAME} PUBLIC glm glfw glad stb_image freetype nlohmann_json::nlohmann_json fmt imgui) target_link_libraries(${MODULE_NAME} PUBLIC project_warnings project_options) target_compile_features(${MODULE_NAME} PRIVATE cxx_std_20) diff --git a/engine/Common/Utils.cpp b/engine/Common/Utils.cpp deleted file mode 100644 index dbad4019..00000000 --- a/engine/Common/Utils.cpp +++ /dev/null @@ -1,215 +0,0 @@ -#include "Utils.hpp" - -#include -#include -#include - -#if defined(_WIN32) -#include -#endif // WIN - -namespace dgame { - -std::string -CustomFloatToStr(float value, int precision) -{ - std::stringstream stream; - stream << std::fixed << std::setprecision(precision) << value; - - return stream.str(); -} - -bool -IsPositionClose(const glm::vec2& targetPos, const glm::vec2& startPos, const glm::vec2& currentPos, - float mariginValue) -{ - bool xCheck = false; - bool yCheck = false; - - const auto targetPosWithPositiveMarigin = targetPos + mariginValue; - const auto targetPosWithNegativeMarigin = targetPos - mariginValue; - - // calculate the direction - const auto direction = targetPos - startPos; - if (direction.x >= 0) - { - xCheck = currentPos.x >= targetPosWithNegativeMarigin.x; - } - else - { - xCheck = currentPos.x <= targetPosWithPositiveMarigin.x; - } - - if (direction.y >= 0) - { - yCheck = currentPos.y >= targetPosWithNegativeMarigin.y; - } - else - { - yCheck = currentPos.y <= targetPosWithPositiveMarigin.y; - } - - return xCheck && yCheck; -} - -#if !defined(__APPLE__) -static std::vector< std::string > -file_dialog_internal(const std::vector< std::pair< std::string, std::string > >& filetypes, - bool save, bool multiple) -{ - static const int FILE_DIALOG_MAX_BUFFER = 16384; - if (save && multiple) - { - throw std::invalid_argument("save and multiple must not both be true."); - } - -#if defined(_WIN32) - OPENFILENAMEW ofn; - ZeroMemory(&ofn, sizeof(OPENFILENAMEW)); - ofn.lStructSize = sizeof(OPENFILENAMEW); - wchar_t* tmp = new wchar_t[FILE_DIALOG_MAX_BUFFER]; - ofn.lpstrFile = tmp; - ZeroMemory(tmp, sizeof(tmp)); - ofn.nMaxFile = FILE_DIALOG_MAX_BUFFER; - ofn.nFilterIndex = 1; - - std::string filter; - - if (!save && filetypes.size() > 1) - { - filter.append("Supported file types ("); - for (size_t i = 0; i < filetypes.size(); ++i) - { - filter.append("*."); - filter.append(filetypes[i].first); - if (i + 1 < filetypes.size()) - filter.append(";"); - } - filter.append(")"); - filter.push_back('\0'); - for (size_t i = 0; i < filetypes.size(); ++i) - { - filter.append("*."); - filter.append(filetypes[i].first); - if (i + 1 < filetypes.size()) - filter.append(";"); - } - filter.push_back('\0'); - } - for (auto pair : filetypes) - { - filter.append(pair.second); - filter.append(" (*."); - filter.append(pair.first); - filter.append(")"); - filter.push_back('\0'); - filter.append("*."); - filter.append(pair.first); - filter.push_back('\0'); - } - filter.push_back('\0'); - - int size = MultiByteToWideChar(CP_UTF8, 0, &filter[0], (int)filter.size(), NULL, 0); - std::wstring wfilter(size, 0); - MultiByteToWideChar(CP_UTF8, 0, &filter[0], (int)filter.size(), &wfilter[0], size); - - ofn.lpstrFilter = wfilter.data(); - - if (save) - { - ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT; - if (GetSaveFileNameW(&ofn) == FALSE) - return {}; - } - else - { - ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; - if (multiple) - ofn.Flags |= OFN_ALLOWMULTISELECT; - if (GetOpenFileNameW(&ofn) == FALSE) - return {}; - } - - size_t i = 0; - std::vector< std::string > result; - while (tmp[i] != '\0') - { - std::string filename; - int tmpSize = (int)wcslen(&tmp[i]); - if (tmpSize > 0) - { - int filenameSize = WideCharToMultiByte(CP_UTF8, 0, &tmp[i], tmpSize, NULL, 0, NULL, NULL); - filename.resize(filenameSize, 0); - WideCharToMultiByte(CP_UTF8, 0, &tmp[i], tmpSize, &filename[0], filenameSize, NULL, NULL); - } - - result.emplace_back(filename); - i += tmpSize; - } - - if (result.size() > 1) - { - for (i = 1; i < result.size(); ++i) - { - result[i] = result[0] + "\\" + result[i]; - } - result.erase(begin(result)); - } - - delete[] tmp; - return result; -#else - char buffer[FILE_DIALOG_MAX_BUFFER]; - buffer[0] = '\0'; - - std::string cmd = "zenity --file-selection "; - // The safest separator for multiple selected paths is /, since / can never occur - // in file names. Only where two paths are concatenated will there be two / following - // each other. - if (multiple) - cmd += "--multiple --separator=\"/\" "; - if (save) - cmd += "--save "; - cmd += "--file-filter=\""; - for (auto pair : filetypes) - cmd += "\"*." + pair.first + "\" "; - cmd += "\""; - FILE* output = popen(cmd.c_str(), "r"); - if (output == nullptr) - throw std::runtime_error("popen() failed -- could not launch zenity!"); - while (fgets(buffer, FILE_DIALOG_MAX_BUFFER, output) != NULL) - ; - pclose(output); - std::string paths(buffer); - paths.erase(std::remove(paths.begin(), paths.end(), '\n'), paths.end()); - - std::vector< std::string > result; - while (!paths.empty()) - { - size_t end = paths.find("//"); - if (end == std::string::npos) - { - result.emplace_back(paths); - paths = ""; - } - else - { - result.emplace_back(paths.substr(0, end)); - paths = paths.substr(end + 1); - } - } - - return result; -#endif -} -#endif - -std::string -file_dialog(const std::vector< std::pair< std::string, std::string > >& filetypes, bool save) -{ - auto result = file_dialog_internal(filetypes, save, false); - return result.empty() ? "" : result.front(); -} - - -} // namespace dgame \ No newline at end of file diff --git a/engine/Common/Utils.hpp b/engine/Common/Utils.hpp deleted file mode 100644 index a0d7a67e..00000000 --- a/engine/Common/Utils.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include -#include -#include - -namespace dgame { - -std::string -CustomFloatToStr(float value, int precision = 2); - -bool -IsPositionClose(const glm::vec2& targetPos, const glm::vec2& startPos, const glm::vec2& currentPos, - float mariginValue = 0.1f); - -std::string -file_dialog(const std::vector< std::pair< std::string, std::string > >& filetypes, bool save); - -} // namespace dgame \ No newline at end of file diff --git a/engine/Core/Application.cpp b/engine/Core/Application.cpp index df01bfa3..1e57a075 100644 --- a/engine/Core/Application.cpp +++ b/engine/Core/Application.cpp @@ -36,25 +36,26 @@ Application::GetCamera() } Timer::milliseconds -Application::GetDeltaTime() +Application::GetDeltaTime() const { return m_deltaTime; } bool -Application::IsGame() +Application::IsGame() const { return m_isGame; } void -Application::Log(Logger::TYPE t, const std::string& log) +Application::Log(Logger::Type t, const std::string& log) const { m_logger.Log(t, log); } void -Application::RenderText(std::string, const glm::vec2&, float, const glm::vec3&) +Application::RenderText(const std::string& /*text*/, const glm::vec2& /*position*/, float /*scale*/, + const glm::vec3& /*color*/) { // m_font.RenderText(GetProjection(), text, position, scale, color); } @@ -86,7 +87,7 @@ Application::GlobalToScreen(const glm::vec2& globalPos) const } glm::vec2 -Application::ScreenToGlobal(const glm::vec2& screenPos) +Application::ScreenToGlobal(const glm::vec2& screenPos) const { const auto windowCenterScreen = GetWindowSize() / 2.0f; const auto zoomRatio = (GetWindowSize() / (2.0f + GetZoomLevel())) / windowCenterScreen; diff --git a/engine/Core/Application.hpp b/engine/Core/Application.hpp index 51d4d380..b8b92421 100644 --- a/engine/Core/Application.hpp +++ b/engine/Core/Application.hpp @@ -20,7 +20,14 @@ class Application : public InputListener { public: Application() = default; - virtual ~Application(); + ~Application() override; + Application& + operator=(Application&) = delete; + Application& + operator=(Application&&) = delete; + Application(Application&) = delete; + Application(Application&&) = delete; + std::shared_ptr< Player > GetPlayer(); @@ -35,16 +42,16 @@ class Application : public InputListener GetCamera(); Timer::milliseconds - GetDeltaTime(); + GetDeltaTime() const; bool - IsGame(); + IsGame() const; void - Log(Logger::TYPE t, const std::string& log); + Log(Logger::Type t, const std::string& log) const; void - RenderText(std::string text, const glm::vec2& position, float scale, + RenderText(const std::string& text, const glm::vec2& position, float scale, const glm::vec3& color = glm::vec3(1.0f, 1.0f, 1.0f)); // convert from global position (OpenGL) to screen position (in pixels) @@ -53,7 +60,7 @@ class Application : public InputListener // convert from screen position (in pixels) to global position (OpenGL) glm::vec2 - ScreenToGlobal(const glm::vec2& screenPos); + ScreenToGlobal(const glm::vec2& screenPos) const; void CenterCameraOnPlayer(); @@ -71,12 +78,13 @@ class Application : public InputListener GetViewMatrix() const = 0; virtual float - GetZoomLevel() = 0; + GetZoomLevel() const = 0; protected: virtual bool - IsRunning() = 0; + IsRunning() const = 0; + // NOLINTBEGIN (cppcoreguidelines-non-private-member-variables-in-classes) Logger m_logger; bool m_isGame = false; std::shared_ptr< Player > m_player = nullptr; @@ -86,7 +94,8 @@ class Application : public InputListener std::unique_ptr< Window > m_window; Camera m_camera; Timer m_timer; - Timer::milliseconds m_deltaTime; + Timer::milliseconds m_deltaTime = {}; + // NOLINTEND }; diff --git a/engine/FileManager/FileManager.cpp b/engine/FileManager/FileManager.cpp index 7805e152..36b0f9a6 100644 --- a/engine/FileManager/FileManager.cpp +++ b/engine/FileManager/FileManager.cpp @@ -6,17 +6,21 @@ #include #include +#if defined(_WIN32) +#include +#endif // WIN + namespace dgame { std::string -FileManager::ReadFile(const std::string& fileName, FileType) +FileManager::ReadFile(const std::string& fileName, FileType /*type*/) { std::ifstream fileHandle; fileHandle.open(fileName, std::ifstream::in); if (!fileHandle.is_open()) { - m_logger.Log(Logger::TYPE::FATAL, + m_logger.Log(Logger::Type::FATAL, "FileManager::ReadFile -> " + fileName + " can't be opened!"); } @@ -26,67 +30,33 @@ FileManager::ReadFile(const std::string& fileName, FileType) if (returnVal.empty()) { - m_logger.Log(Logger::TYPE::FATAL, "FileManager::ReadFile -> " + fileName + " is empty!"); + m_logger.Log(Logger::Type::FATAL, "FileManager::ReadFile -> " + fileName + " is empty!"); } return returnVal; } FileManager::ImageSmart -FileManager::LoadImageData(const std::string& imageName) +FileManager::LoadImageData(const std::string& fileName) { - const auto pathToImage = std::filesystem::path(IMAGES_DIR / imageName).string(); + const auto pathToImage = std::filesystem::path(IMAGES_DIR / fileName).string(); int force_channels = 0; - int w, h, n; + int w = 0; + int h = 0; + int n = 0; ImageHandleType textureData(stbi_load(pathToImage.c_str(), &w, &h, &n, force_channels), stbi_image_free); if (!textureData) { - m_logger.Log(Logger::TYPE::FATAL, + m_logger.Log(Logger::Type::FATAL, fmt::format("FileManager::LoadImage -> {} can't be opened!", pathToImage)); } return {std::move(textureData), {w, h}, n}; } -uint8_t* -FileManager::LoadImageRawBytes(const std::string& fileName) -{ - const auto pathToImage = std::filesystem::path(IMAGES_DIR / fileName).string(); - int force_channels = 0; - int w, h, n; - - uint8_t* textureData = stbi_load(pathToImage.c_str(), &w, &h, &n, force_channels); - - if (!textureData) - { - m_logger.Log(Logger::TYPE::FATAL, - "FileManager::LoadImageRawBytes -> " + pathToImage + " can't be opened!"); - } - - return textureData; -} - -FileManager::ImageRaw -FileManager::LoadImageRawData(const std::string& fileName) -{ - const auto pathToImage = std::filesystem::path(IMAGES_DIR / fileName).string(); - int force_channels = 0; - int w, h, n; - - uint8_t* textureData = stbi_load(pathToImage.c_str(), &w, &h, &n, force_channels); - - if (!textureData) - { - m_logger.Log(Logger::TYPE::FATAL, - "FileManager::LoadImageRawData -> " + pathToImage + " can't be opened!"); - } - - return {textureData, {w, h}, n}; -} - nlohmann::json FileManager::LoadJsonFile(const std::string& pathToFile) { @@ -94,7 +64,7 @@ FileManager::LoadJsonFile(const std::string& pathToFile) if (!jsonFile.is_open()) { - m_logger.Log(Logger::TYPE::FATAL, + m_logger.Log(Logger::Type::FATAL, "FileManager::LoadJsonFile -> " + pathToFile + " can't be opened!"); } @@ -103,7 +73,7 @@ FileManager::LoadJsonFile(const std::string& pathToFile) if (json.is_null()) { - m_logger.Log(Logger::TYPE::FATAL, + m_logger.Log(Logger::Type::FATAL, "FileManager::LoadJsonFile -> " + pathToFile + " is empty!"); } @@ -111,11 +81,146 @@ FileManager::LoadJsonFile(const std::string& pathToFile) } void -FileManager::SaveJsonFile(const std::string& pathToFile, nlohmann::json json) +FileManager::SaveJsonFile(const std::string& pathToFile, const nlohmann::json& json) { std::ofstream jsonFile(pathToFile); jsonFile << json; } +std::string +FileManager::FileDialog(const std::filesystem::path& defaultPath, + const std::vector< std::pair< std::string, std::string > >& fileTypes, + bool save) +{ + constexpr auto FILE_DIALOG_MAX_BUFFER = 16384; + +#if defined(_WIN32) + ////////////////////////////////////////////// + /////// Generate file filter /////// + ////////////////////////////////////////////// + std::string filter; + + if (!save && fileTypes.size() > 1) + { + auto generateFormats = [](const auto& filterTypes) { + std::string buffer; + for (size_t i = 0; i < filterTypes.size(); ++i) + { + buffer.append( + fmt::format("*.{}{}", filterTypes[i].second, i < filterTypes.size() - 1 ? ";" : "")); + } + + return buffer; + }; + + // There could be a simpler way to insert \0 mid string + // Doesn't seem to work with fmt::format sadly + const auto formats = generateFormats(fileTypes); + filter.append(fmt::format("Supported file types ({})", formats)); + filter.push_back('\0'); + filter.append(fmt::format("{}", formats)); + filter.push_back('\0'); + } + + for (const auto& [description, extension] : fileTypes) + { + // Same as above, need to explicitly push_back \0 + filter.append(fmt::format("{} (*.{})", description, extension)); + filter.push_back('\0'); + filter.append(fmt::format("*.{}", extension)); + filter.push_back('\0'); + } + + + filter.push_back('\0'); + + const auto size = + MultiByteToWideChar(CP_UTF8, 0, filter.c_str(), static_cast< int >(filter.size()), NULL, 0); + std::wstring wfilter(size, 0); + MultiByteToWideChar(CP_UTF8, 0, filter.c_str(), static_cast< int >(filter.size()), + wfilter.data(), size); + + + ////////////////////////////////////////////// + /////// Open file dialog /////// + ////////////////////////////////////////////// + + std::wstring fileDialogBuffer(FILE_DIALOG_MAX_BUFFER, 0); + const auto directoryWstring = defaultPath.wstring(); + + OPENFILENAMEW ofn = {0}; + ofn.lStructSize = sizeof(OPENFILENAMEW); + ofn.lpstrInitialDir = directoryWstring.c_str(); + ofn.lpstrFile = fileDialogBuffer.data(); + ofn.nMaxFile = FILE_DIALOG_MAX_BUFFER; + ofn.nFilterIndex = 1; + ofn.lpstrFilter = wfilter.c_str(); + + if (save) + { + ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT; + + if (!GetSaveFileNameW(&ofn)) + { + return {}; + } + } + else + { + ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; + + if (!GetOpenFileNameW(&ofn)) + { + return {}; + } + } + + std::string result; + + const auto tmpSize = static_cast< int >(wcslen(fileDialogBuffer.c_str())); + assert(tmpSize > 0); + + auto filenameSize = + WideCharToMultiByte(CP_UTF8, 0, fileDialogBuffer.c_str(), tmpSize, NULL, 0, NULL, NULL); + result.resize(filenameSize, 0); + + WideCharToMultiByte(CP_UTF8, 0, fileDialogBuffer.c_str(), tmpSize, result.data(), filenameSize, + NULL, NULL); + + return result; +#else + + + const auto cmd = fmt::format("zenity --file-selection --filename={} {} --file-filter=\"{}\"", + defaultPath.string(), save ? "--save " : "", [&fileTypes] { + std::string types; + for ([[maybe_unused]] const auto& [_, extension] : fileTypes) + { + types.append(fmt::format("\"*.{}\" ", extension)); + } + return types; + }()); + + // NOLINTNEXTLINE + auto* output = popen(cmd.c_str(), "r"); + assert(output); // NOLINT + + std::string buffer(FILE_DIALOG_MAX_BUFFER, 0); + if (fgets(buffer.data(), FILE_DIALOG_MAX_BUFFER, output)) + { + // fgets includes \n character at the end, remove it + buffer[strcspn(buffer.c_str(), "\n")] = 0; + } + else + { + buffer = ""; + } + + pclose(output); + + return buffer; +#endif +} + } // namespace dgame diff --git a/engine/FileManager/FileManager.hpp b/engine/FileManager/FileManager.hpp index 2118bab9..37875716 100644 --- a/engine/FileManager/FileManager.hpp +++ b/engine/FileManager/FileManager.hpp @@ -9,13 +9,14 @@ namespace dgame { +// NOLINTBEGIN const std::filesystem::path ROOT_DIR = std::filesystem::path(std::string(CMAKE_ROOT_DIR)); -const std::filesystem::path ASSETS_DIR = ROOT_DIR / "Assets"; -const std::filesystem::path LEVELS_DIR = ASSETS_DIR / "Levels"; -const std::filesystem::path FONTS_DIR = ASSETS_DIR / "Fonts"; -const std::filesystem::path SHADERS_DIR = ASSETS_DIR / "Shaders"; -const std::filesystem::path IMAGES_DIR = ASSETS_DIR / "Images"; - +const std::filesystem::path ASSETS_DIR = ROOT_DIR / "assets" / ""; +const std::filesystem::path LEVELS_DIR = ASSETS_DIR / "levels" / ""; +const std::filesystem::path FONTS_DIR = ASSETS_DIR / "fonts" / ""; +const std::filesystem::path SHADERS_DIR = ASSETS_DIR / "shaders" / ""; +const std::filesystem::path IMAGES_DIR = ASSETS_DIR / "images" / ""; +// NOLINTEND class FileManager { public: @@ -26,9 +27,9 @@ class FileManager int32_t m_format; }; + // NOLINTNEXTLINE using ImageHandleType = std::unique_ptr< uint8_t[], std::function< void(uint8_t*) > >; using ImageSmart = ImageData< ImageHandleType >; - using ImageRaw = ImageData< uint8_t* >; enum class FileType { @@ -39,32 +40,33 @@ class FileManager static std::string ReadFile(const std::string& fileName, FileType type = FileType::TEXT); - static void - WriteToFile(const std::string& fileName, FileType type = FileType::TEXT); - - // NOTE! - // image data is not freed - // TODO: Handle freeing the data - static uint8_t* - LoadImageRawBytes(const std::string& fileName); - static ImageSmart LoadImageData(const std::string& fileName); - // NOTE! - // image data is not freed - // TODO: Handle freeing the data - static ImageRaw - LoadImageRawData(const std::string& fileName); - static nlohmann::json - LoadJsonFile(const std::string& fileName); + LoadJsonFile(const std::string& pathToFile); static void - SaveJsonFile(const std::string& fileName, nlohmann::json json); + SaveJsonFile(const std::string& pathToFile, const nlohmann::json& json); + + /** + * \brief Return file path to selected file + * + * \param[in] defaultPath Where to open FileDialog + * \param[in] fileTypes List of file types that we're looking for + * Example: {{"PNG texture", ".png"}, {"PNG texture", ".jpg"}} + * + * \param[in] save Whether to save given file + * + * \return Path to selected file + */ + static std::string + FileDialog(const std::filesystem::path& defaultPath, + const std::vector< std::pair< std::string, std::string > >& fileTypes, bool save); private: - static inline Logger m_logger = Logger("FileManager"); + // NOLINTNEXTLINE + static inline const Logger m_logger = Logger("FileManager"); }; } // namespace dgame diff --git a/engine/Game/Animatable.cpp b/engine/Game/Animatable.cpp index 01160309..cf0454af 100644 --- a/engine/Game/Animatable.cpp +++ b/engine/Game/Animatable.cpp @@ -1,15 +1,12 @@ #include "Animatable.hpp" #include "Common.hpp" -#include "Utils.hpp" #include namespace dgame { -Animatable::Animatable(ANIMATION_TYPE type) +Animatable::Animatable(ANIMATION_TYPE type) : m_type(type) { - m_type = type; - ResetAnimation(); } @@ -20,7 +17,7 @@ Animatable::SetAnimationType(ANIMATION_TYPE type) } Animatable::ANIMATION_TYPE -Animatable::GetAnimationType() +Animatable::GetAnimationType() const { return m_type; } @@ -109,7 +106,7 @@ Animatable::SetCorrectAnimationPoint(Timer::milliseconds& updateTime) } glm::vec2 -Animatable::CalculateNextStep(Timer::milliseconds updateTime) +Animatable::CalculateNextStep(Timer::milliseconds updateTime) const { const auto startPosition = m_currentAnimationState.m_currentAnimationBegin; const auto destination = m_currentAnimationState.m_currentAnimationEnd; @@ -194,19 +191,17 @@ Animatable::SingleAnimate(Timer::milliseconds updateTime) m_currentAnimationState.m_animationFinished = false; return glm::vec2{}; } - else - { - return Animate(updateTime); - } + + return Animate(updateTime); } AnimationPoint -Animatable::CreateAnimationNode(Object::ID parentID) +Animatable::CreateAnimationNode(Object::ID parentID, const glm::vec2& position) { - const auto position = m_animationPoints.empty() - ? glm::vec2(0.0f, 0.0f) - : m_animationPoints.back().m_end + glm::vec2(10.0f, 10.0f); - auto newNode = AnimationPoint(parentID, position, Timer::seconds(2)); + const auto nodePosition = m_animationPoints.empty() + ? position + : m_animationPoints.back().m_end + glm::vec2(20.0f, 20.0f); + auto newNode = AnimationPoint(parentID, nodePosition, Timer::seconds(2)); AddAnimationNode(newNode); return newNode; @@ -223,7 +218,7 @@ Animatable::UpdateAnimationNode(const AnimationPoint& updatedAnimationPoint) { auto updatedPointIt = std::find_if(m_animationPoints.begin(), m_animationPoints.end(), - [updatedAnimationPoint](const auto animationPoint) { + [&updatedAnimationPoint](const auto animationPoint) { return animationPoint.GetID() == updatedAnimationPoint.GetID(); }); @@ -250,15 +245,15 @@ Animatable::DeleteAnimationNode(Object::ID animationID) } else { - m_logger.Log(Logger::TYPE::WARNING, "Attempting to remove non existing node with ID={}", + m_logger.Log(Logger::Type::WARNING, "Attempting to remove non existing node with ID={}", animationID); } } void -Animatable::SetAnimationKeypoints(const std::vector< AnimationPoint >& keypoints) +Animatable::SetAnimationKeypoints(std::vector< AnimationPoint >&& keypoints) { - m_animationPoints = keypoints; + m_animationPoints = std::move(keypoints); ResetAnimation(); } @@ -279,7 +274,7 @@ Animatable::GetAnimationDuration() const { auto totalDuration = Timer::seconds(0); - for (auto& animationPoint : m_animationPoints) + for (const auto& animationPoint : m_animationPoints) { totalDuration += animationPoint.m_timeDuration; totalDuration += animationPoint.m_pauseDuration; @@ -294,15 +289,15 @@ Animatable::Update(bool isReverse) { if (isReverse) { - m_currentAnimationState = m_statesQueue.back(); - m_statesQueue.pop_back(); + m_currentAnimationState = m_animationStatesQueue.back(); + m_animationStatesQueue.pop_back(); } else { - m_statesQueue.push_back(m_currentAnimationState); - if (m_statesQueue.size() >= NUM_FRAMES_TO_SAVE) + m_animationStatesQueue.push_back(m_currentAnimationState); + if (m_animationStatesQueue.size() >= NUM_FRAMES_TO_SAVE) { - m_statesQueue.pop_front(); + m_animationStatesQueue.pop_front(); } } } @@ -371,7 +366,7 @@ Animatable::RenderAnimationSteps(bool choice) } bool -Animatable::GetRenderAnimationSteps() +Animatable::GetRenderAnimationSteps() const { return m_renderAnimationSteps; } @@ -383,7 +378,7 @@ Animatable::LockAnimationSteps(bool lock) } bool -Animatable::GetLockAnimationSteps() +Animatable::GetLockAnimationSteps() const { return m_lockAnimationSteps; } diff --git a/engine/Game/Animatable.hpp b/engine/Game/Animatable.hpp index 32b212d8..6b747127 100644 --- a/engine/Game/Animatable.hpp +++ b/engine/Game/Animatable.hpp @@ -13,7 +13,7 @@ namespace dgame { struct AnimationPoint : public Object { - AnimationPoint(ID parentID) : Object(Object::TYPE::ANIMATION_POINT), m_parent(parentID) + explicit AnimationPoint(ID parentID) : Object(Object::TYPE::ANIMATION_POINT), m_parent(parentID) { } @@ -47,13 +47,12 @@ class Animatable REVERSABLE }; - public: - Animatable(ANIMATION_TYPE type); + explicit Animatable(ANIMATION_TYPE type); void SetAnimationType(ANIMATION_TYPE); - ANIMATION_TYPE - GetAnimationType(); + [[nodiscard]] ANIMATION_TYPE + GetAnimationType() const; glm::vec2 SetAnimation(Timer::milliseconds updateTime); @@ -69,45 +68,45 @@ class Animatable SingleAnimate(Timer::milliseconds updateTime); AnimationPoint - CreateAnimationNode(Object::ID parentID); + CreateAnimationNode(Object::ID parentID, const glm::vec2& position = glm::vec2{}); void - AddAnimationNode(const AnimationPoint& pathNodeMapPosition); + AddAnimationNode(const AnimationPoint& newAnimationPoint); void - UpdateAnimationNode(const AnimationPoint& pathNodeMapPosition); + UpdateAnimationNode(const AnimationPoint& updatedAnimationPoint); void DeleteAnimationNode(Object::ID animationID); void - SetAnimationKeypoints(const std::vector< AnimationPoint >& keypoints); + SetAnimationKeypoints(std::vector< AnimationPoint >&& keypoints); std::vector< AnimationPoint >& GetAnimationKeypoints(); - const std::vector< AnimationPoint >& + [[nodiscard]] const std::vector< AnimationPoint >& GetAnimationKeypoints() const; - Timer::seconds + [[nodiscard]] Timer::seconds GetAnimationDuration() const; void RenderAnimationSteps(bool choice); - bool - GetRenderAnimationSteps(); + [[nodiscard]] bool + GetRenderAnimationSteps() const; void LockAnimationSteps(bool lock); - bool - GetLockAnimationSteps(); + [[nodiscard]] bool + GetLockAnimationSteps() const; void SetAnimationStartLocation(const glm::vec2& position); - glm::vec2 + [[nodiscard]] glm::vec2 GetAnimationStartLocation() const; void @@ -141,12 +140,12 @@ class Animatable Timer::milliseconds m_totalTimeElapsed = Timer::milliseconds(0); }; - std::deque< AnimationState > m_statesQueue; + std::deque< AnimationState > m_animationStatesQueue; AnimationState m_currentAnimationState; std::vector< AnimationPoint > m_animationPoints; ANIMATION_TYPE m_type = ANIMATION_TYPE::LOOP; - glm::vec2 m_animationStartPosition; + glm::vec2 m_animationStartPosition = {}; bool m_renderAnimationSteps = false; bool m_lockAnimationSteps = false; @@ -183,10 +182,9 @@ class Animatable UpdateAnimationPoint(); // Calculate next animation step based on current animation point and 'updateTime' - glm::vec2 - CalculateNextStep(Timer::milliseconds updateTime); + [[nodiscard]] glm::vec2 + CalculateNextStep(Timer::milliseconds updateTime) const; - private: Logger m_logger = Logger("Animatable"); }; diff --git a/engine/Game/Enemy.cpp b/engine/Game/Enemy.cpp index 61c1d53f..fcf2aecb 100644 --- a/engine/Game/Enemy.cpp +++ b/engine/Game/Enemy.cpp @@ -5,21 +5,25 @@ #include #include +#include + namespace dgame { Enemy::Enemy(Application& context, const glm::vec2& pos, const glm::ivec2& size, - const std::string& sprite, const std::vector< AnimationPoint >& keypoints, + const std::string& textureName, const std::vector< AnimationPoint >& keypoints, Animatable::ANIMATION_TYPE animationType) - : GameObject(context, pos, size, sprite, TYPE::ENEMY), Animatable(animationType) + : GameObject(context, pos, size, textureName, TYPE::ENEMY), + Animatable(animationType), + m_weapon(std::make_unique< Glock >()), + m_initialPosition(m_currentGameObjectState.m_position) { m_currentState.m_currentHP = m_maxHP; m_currentState.m_visionRange = 1000.0f; - m_weapon = std::make_unique< Glock >(); + m_currentState.m_combatStarted = false; m_animationPoints = keypoints; m_timer.ToggleTimer(); - m_initialPosition = GameObject::m_currentState.m_position; m_animationStartPosition = m_initialPosition; ResetAnimation(); @@ -28,11 +32,11 @@ Enemy::Enemy(Application& context, const glm::vec2& pos, const glm::ivec2& size, void Enemy::DealWithPlayer() { - auto gameHandle = ConvertToGameHandle(); + auto* gameHandle = ConvertToGameHandle(); const auto playerPosition = gameHandle->GetPlayer()->GetCenteredPosition(); const auto playerInVision = gameHandle->GetLevel().CheckCollisionAlongTheLine( - GameObject::m_currentState.m_centeredPosition, playerPosition); + m_currentGameObjectState.m_centeredPosition, playerPosition); m_timer.ToggleTimer(); @@ -87,7 +91,8 @@ Enemy::DealWithPlayer() } } -void Enemy::Hit(int32_t /*dmg*/) +void +Enemy::Hit(int32_t /*dmg*/) { // currentHP -= dmg; SetColor({1.0f, 0.0f, 0.0f}); @@ -118,15 +123,19 @@ Enemy::Visible() const } void -Enemy::SetTargetShootPosition(const glm::vec2& playerPos) +Enemy::SetTargetShootPosition(const glm::vec2& targetPosition) { auto playerSize = m_appHandle.GetPlayer()->GetSize(); + std::random_device rd; + std::mt19937 mt(rd()); + std::uniform_real_distribution< double > dist(1.0, 10.0); + // compute small offset value which simulates the 'aim wiggle' - auto xOffset = fmod(rand(), playerSize.x) + (-playerSize.x / 2); - auto yOffset = fmod(rand(), playerSize.y) + (-playerSize.y / 2); + auto xOffset = fmod(dist(mt), playerSize.x) + (-playerSize.x / 2.0); + auto yOffset = fmod(dist(mt), playerSize.y) + (-playerSize.y / 2.0); - m_currentState.m_targetShootPosition = (playerPos + glm::vec2(xOffset, yOffset)); + m_currentState.m_targetShootPosition = (targetPosition + glm::vec2(xOffset, yOffset)); m_currentState.m_combatStarted = true; } @@ -135,9 +144,9 @@ Enemy::Shoot() { m_currentState.m_timeSinceLastShot += m_timer.GetFloatDeltaTime(); - if (glm::length(static_cast< glm::vec2 >(m_appHandle.GetPlayer()->GetCenteredPosition() - - GameObject::m_currentState.m_centeredPosition)) - <= static_cast< float >(m_weapon->GetRange())) + if (glm::length(m_appHandle.GetPlayer()->GetCenteredPosition() + - m_currentGameObjectState.m_centeredPosition) + <= (m_weapon->GetRange())) { if (m_currentState.m_timeSinceLastShot >= m_weapon->GetReloadTime()) { @@ -163,10 +172,10 @@ Enemy::MoveToPosition(const glm::vec2& targetPosition, bool exactPosition) auto& pathFinder = gameHandle->GetLevel().GetPathfinder(); - const auto curPosition = GameObject::m_currentState.m_centeredPosition; + const auto curPosition = m_currentGameObjectState.m_centeredPosition; const auto tiles = pathFinder.GetPath(curPosition, targetPosition); - if (tiles.size() > 0) + if (!tiles.empty()) { const auto moveVal = moveBy * glm::normalize(pathFinder.GetNodeFromID(tiles.back()).m_position - curPosition); @@ -178,8 +187,7 @@ Enemy::MoveToPosition(const glm::vec2& targetPosition, bool exactPosition) Move(moveVal); constexpr auto errorTreshold = 3.0f; - const auto distanceToDest = - targetPosition - GameObject::m_currentState.m_centeredPosition; + const auto distanceToDest = targetPosition - m_currentGameObjectState.m_centeredPosition; // If Enemy is really close to target destination, just put it there if (glm::length(distanceToDest) < errorTreshold) diff --git a/engine/Game/Enemy.hpp b/engine/Game/Enemy.hpp index ea37d802..41071d7d 100644 --- a/engine/Game/Enemy.hpp +++ b/engine/Game/Enemy.hpp @@ -20,9 +20,8 @@ class Enemy : public GameObject, public Animatable Enemy(Application& context, const glm::vec2& pos, const glm::ivec2& size, const std::string& textureName, const std::vector< AnimationPoint >& keypoints = {}, Animatable::ANIMATION_TYPE animationType = Animatable::ANIMATION_TYPE::REVERSABLE); - ~Enemy() override = default; - bool + [[nodiscard]] bool Visible() const override; void @@ -31,13 +30,13 @@ class Enemy : public GameObject, public Animatable void DealWithPlayer(); - std::string + [[nodiscard]] std::string GetWeapon() const; - int32_t + [[nodiscard]] int32_t GetDmg() const; - glm::ivec2 + [[nodiscard]] glm::ivec2 GetInitialPosition() const; private: @@ -49,7 +48,6 @@ class Enemy : public GameObject, public Animatable RETURNING }; - private: void UpdateInternal(bool isReverse) override; @@ -77,9 +75,8 @@ class Enemy : public GameObject, public Animatable ClearPositions(); void - SetTargetShootPosition(const glm::vec2& pos); + SetTargetShootPosition(const glm::vec2& targetPosition); - private: struct EnemyState { ACTION m_action = ACTION::IDLE; @@ -114,7 +111,7 @@ class Enemy : public GameObject, public Animatable // current weapon std::unique_ptr< Weapon > m_weapon; - glm::vec2 m_initialPosition; + glm::vec2 m_initialPosition = {}; }; } // namespace dgame \ No newline at end of file diff --git a/engine/Game/Game.cpp b/engine/Game/Game.cpp index 737dffbb..f2645f5e 100644 --- a/engine/Game/Game.cpp +++ b/engine/Game/Game.cpp @@ -14,7 +14,7 @@ namespace dgame { void Game::MainLoop() { - Logger::SetLogType(Logger::TYPE::DEBUG); + Logger::SetLogType(Logger::Type::DEBUG); auto singleFrameTimer = 0.0f; @@ -27,8 +27,8 @@ Game::MainLoop() { m_window->Clear(); Renderer::BeginScene(m_camera); - const auto dt = Timer::milliseconds( - static_cast< long >(TARGET_TIME * 1000 * Timer::AreTimersRunning())); + const auto dt = Timer::milliseconds(static_cast< long >( + TARGET_TIME * 1000.0f * static_cast< float >(Timer::AreTimersRunning()))); ProcessInput(dt); Render(); @@ -55,7 +55,7 @@ Game::MainLoop() } void -Game::Init(const std::string configFile) +Game::Init(const std::string& configFile) { m_logger.Init("Game"); m_isGame = true; @@ -64,7 +64,7 @@ Game::Init(const std::string configFile) if (!initFile) { - m_logger.Log(Logger::TYPE::FATAL, "Can't open" + (ASSETS_DIR / configFile).string()); + m_logger.Log(Logger::Type::FATAL, "Can't open" + (ASSETS_DIR / configFile).string()); } m_window = std::make_unique< Window >(WIDTH, HEIGHT, "WindowTitle"); @@ -78,7 +78,7 @@ Game::Init(const std::string configFile) while (!initFile.eof()) { - std::string tmp = ""; + std::string tmp; initFile >> tmp; if (tmp == "Levels:") { @@ -124,7 +124,7 @@ Game::MoveGameObject(GameObject* gameObject, const glm::vec2& moveBy) const } void -Game::KeyEvents() +Game::KeyEvents() // NOLINT { const auto floatDeltaTime = static_cast< float >(m_deltaTime.count()); // Camera movement is disabled @@ -313,7 +313,7 @@ Game::GetViewMatrix() const } float -Game::GetZoomLevel() +Game::GetZoomLevel() const { return m_camera.GetZoomLevel(); } @@ -337,7 +337,7 @@ Game::SwapBuffers() } bool -Game::IsRunning() +Game::IsRunning() const { return m_window->IsRunning(); } diff --git a/engine/Game/Game.hpp b/engine/Game/Game.hpp index 1eeb0b7b..71ad7f94 100644 --- a/engine/Game/Game.hpp +++ b/engine/Game/Game.hpp @@ -25,7 +25,7 @@ class Game : public Application // Initialize Game using 'configFile' void - Init(std::string configFile); + Init(const std::string& configFile); bool IsReverse() const; @@ -45,11 +45,11 @@ class Game : public Application void SwapBuffers(); - void + static void RegisterForKeyInput(InputListener* listener); void - LoadLevel(const std::string& levelName); + LoadLevel(const std::string& pathToLevel); glm::vec2 GetWindowSize() const override; @@ -61,7 +61,7 @@ class Game : public Application GetViewMatrix() const override; float - GetZoomLevel() override; + GetZoomLevel() const override; private: enum class GameState : uint8_t @@ -70,9 +70,6 @@ class Game : public Application GAME }; - void - RenderLine(const glm::ivec2& collided, const glm::vec3& color); - /** * \brief Check bullet collision along the line, starting from \c position * with length of \c range @@ -113,9 +110,8 @@ class Game : public Application HandleReverseLogic(); bool - IsRunning() override; + IsRunning() const override; - private: bool m_initialized = false; int32_t m_frames = 0; diff --git a/engine/Game/GameObject.cpp b/engine/Game/GameObject.cpp index 7f4cd6bb..e2e1446e 100644 --- a/engine/Game/GameObject.cpp +++ b/engine/Game/GameObject.cpp @@ -5,15 +5,15 @@ namespace dgame { -GameObject::GameObject(Application& contextHandle, const glm::vec2& positionOnMap, - const glm::ivec2& size, const std::string& sprite, Object::TYPE type) - : Object(type), m_appHandle(contextHandle) +GameObject::GameObject(Application& application, const glm::vec2& position, const glm::ivec2& size, + const std::string& sprite, Object::TYPE type) + : Object(type), + m_appHandle(application), + m_collision(m_sprite.SetSpriteTextured(position, size, sprite)) { - m_currentState.m_position = m_appHandle.GetLevel().GetGlobalVec(positionOnMap); - m_currentState.m_visible = true; - m_collision = m_sprite.SetSpriteTextured(m_currentState.m_position, size, sprite); - m_currentState.m_centeredPosition = m_sprite.GetPosition(); - m_type = type; + m_currentGameObjectState.m_position = position; + m_currentGameObjectState.m_visible = true; + m_currentGameObjectState.m_centeredPosition = m_sprite.GetPosition(); UpdateCollision(); } @@ -55,13 +55,13 @@ GameObject::CheckIfCollidedScreenPosion(const glm::vec2& screenPosition) const glm::vec2 GameObject::GetScreenPositionPixels() const { - return m_appHandle.GlobalToScreen(m_currentState.m_centeredPosition); + return m_appHandle.GlobalToScreen(m_currentGameObjectState.m_centeredPosition); } bool GameObject::Visible() const { - return m_currentState.m_visible; + return m_currentGameObjectState.m_visible; } void @@ -69,8 +69,8 @@ GameObject::SetSize(const glm::vec2& newSize) { m_sprite.SetSize(newSize); - m_currentState.m_occupiedNodes = m_appHandle.GetLevel().GameObjectMoved( - m_sprite.GetTransformedRectangle(), m_currentState.m_occupiedNodes); + m_currentGameObjectState.m_occupiedNodes = m_appHandle.GetLevel().GameObjectMoved( + m_sprite.GetTransformedRectangle(), m_currentGameObjectState.m_occupiedNodes, m_id); } void @@ -88,20 +88,20 @@ GameObject::GetSize() const void GameObject::SetPosition(const glm::vec2& position) { - m_currentState.m_position = position; + m_currentGameObjectState.m_position = position; } glm::vec2 GameObject::GetPosition() const { - return m_currentState.m_position; + return m_currentGameObjectState.m_position; } glm::vec2 GameObject::GetCenteredPosition() const { - return m_currentState.m_position; - // return m_currentState.m_centeredPosition; + return m_currentGameObjectState.m_position; + // return m_currentGameObjectState.m_centeredPosition; } const Sprite& @@ -126,7 +126,7 @@ void GameObject::CreateSprite(const glm::vec2& position, const glm::ivec2& size) { m_sprite.SetSprite(position, size); - m_currentState.m_position = m_sprite.GetPosition(); + m_currentGameObjectState.m_position = m_sprite.GetPosition(); } void @@ -134,7 +134,7 @@ GameObject::CreateSpriteTextured(const glm::vec2& position, const glm::ivec2& si const std::string& fileName) { m_collision = m_sprite.SetSpriteTextured(position, size, fileName); - m_currentState.m_position = m_sprite.GetPosition(); + m_currentGameObjectState.m_position = m_sprite.GetPosition(); } void @@ -144,9 +144,9 @@ GameObject::SetHasCollision(bool hasCollision) if (!m_hasCollision) { - for (auto& node : m_currentState.m_occupiedNodes) + for (auto& node : m_currentGameObjectState.m_occupiedNodes) { - m_appHandle.GetLevel().GetPathfinder().SetNodeFreed(node); + m_appHandle.GetLevel().GetPathfinder().SetNodeFreed(node, m_id); } } else @@ -178,23 +178,23 @@ GameObject::UpdateCollision() { if (m_hasCollision) { - m_currentState.m_occupiedNodes = m_appHandle.GetLevel().GameObjectMoved( - m_sprite.GetTransformedRectangle(), m_currentState.m_occupiedNodes); + m_currentGameObjectState.m_occupiedNodes = m_appHandle.GetLevel().GameObjectMoved( + m_sprite.GetTransformedRectangle(), m_currentGameObjectState.m_occupiedNodes, m_id); } } std::vector< Tile_t > GameObject::GetOccupiedNodes() const { - return m_currentState.m_occupiedNodes; + return m_currentGameObjectState.m_occupiedNodes; } void GameObject::Move(const glm::vec2& moveBy) { m_sprite.Translate(moveBy); - m_currentState.m_position += moveBy; - m_currentState.m_centeredPosition += moveBy; + m_currentGameObjectState.m_position += moveBy; + m_currentGameObjectState.m_centeredPosition += moveBy; UpdateCollision(); } @@ -220,15 +220,15 @@ GameObject::Update(bool isReverse) { if (isReverse) { - m_currentState = m_statesQueue.back(); - m_statesQueue.pop_back(); + m_currentGameObjectState = m_gameObjectStatesQueue.back(); + m_gameObjectStatesQueue.pop_back(); } else { - m_statesQueue.push_back(m_currentState); - if (m_statesQueue.size() >= NUM_FRAMES_TO_SAVE) + m_gameObjectStatesQueue.push_back(m_currentGameObjectState); + if (m_gameObjectStatesQueue.size() >= NUM_FRAMES_TO_SAVE) { - m_statesQueue.pop_front(); + m_gameObjectStatesQueue.pop_front(); } } @@ -245,10 +245,10 @@ GameObject::Render() Game* GameObject::ConvertToGameHandle() { - auto gameHandle = static_cast< Game* >(&m_appHandle); + auto* gameHandle = dynamic_cast< Game* >(&m_appHandle); if (gameHandle == nullptr) { - m_appHandle.Log(Logger::TYPE::FATAL, "Game logic called not from Game class"); + m_appHandle.Log(Logger::Type::FATAL, "Game logic called not from Game class"); } return gameHandle; diff --git a/engine/Game/GameObject.hpp b/engine/Game/GameObject.hpp index 4150a491..8f870025 100644 --- a/engine/Game/GameObject.hpp +++ b/engine/Game/GameObject.hpp @@ -19,15 +19,14 @@ class GameObject : public Object { public: // Constructors and destructors - GameObject(Application& game, const glm::vec2& position, const glm::ivec2& size, + GameObject(Application& application, const glm::vec2& position, const glm::ivec2& size, const std::string& sprite, Object::TYPE type); - ~GameObject() override = default; - virtual void Hit(int32_t) + virtual void Hit(int32_t /*dmg*/) { } - virtual bool + [[nodiscard]] virtual bool Visible() const; // SETERS @@ -49,31 +48,31 @@ class GameObject : public Object // GETERS // Get size of object - virtual glm::ivec2 + [[nodiscard]] virtual glm::ivec2 GetSize() const; // Get centered position in global(OpenGL) coords - virtual glm::vec2 + [[nodiscard]] virtual glm::vec2 GetCenteredPosition() const; // Get position in global (OpenGL) coords - virtual glm::vec2 + [[nodiscard]] virtual glm::vec2 GetPosition() const; - virtual bool + [[nodiscard]] virtual bool CheckIfCollidedScreenPosion(const glm::vec2& screenPosition) const; // Get position in (0,0) to (WIDTH, HEIGHT) screen coords (0,0 BEING TOP LEFT CORNER) - virtual glm::vec2 + [[nodiscard]] virtual glm::vec2 GetScreenPositionPixels() const; - virtual const Sprite& + [[nodiscard]] virtual const Sprite& GetSprite() const; virtual Sprite& GetSprite(); - std::string + [[nodiscard]] std::string GetName() const; // Create sprite with default texture @@ -108,10 +107,10 @@ class GameObject : public Object SetHasCollision(bool hasCollision); // Only used by editor when unselected by user - bool + [[nodiscard]] bool GetHasCollision() const; - std::vector< Tile_t > + [[nodiscard]] std::vector< Tile_t > GetOccupiedNodes() const; protected: @@ -148,13 +147,11 @@ class GameObject : public Object std::vector< Tile_t > m_occupiedNodes; }; - std::deque< State > m_statesQueue; - State m_currentState; + std::deque< State > m_gameObjectStatesQueue; + State m_currentGameObjectState; Application& m_appHandle; - TYPE m_type; - bool m_hasCollision = false; // object's sprite diff --git a/engine/Game/Level.cpp b/engine/Game/Level.cpp index 2d9f6a50..1b57d95a 100644 --- a/engine/Game/Level.cpp +++ b/engine/Game/Level.cpp @@ -30,7 +30,7 @@ Level::Load(Application* context, const std::string& pathToLevel) { const auto json = FileManager::LoadJsonFile(pathToLevel); - for (auto& [key, value] : json.items()) + for (const auto& [key, value] : json.items()) { if (key == "BACKGROUND") { @@ -45,14 +45,16 @@ Level::Load(Application* context, const std::string& pathToLevel) { m_pathFinder.InitializeEmpty(m_levelSize, m_tileWidth); - for (auto& nodeJson : json[key]["nodes"]) + for (const auto& nodeJson : json[key]["nodes"]) { m_pathFinder.AddNode(Node(glm::ivec2(nodeJson["coords"][0], nodeJson["coords"][1]), glm::ivec2(nodeJson["position"][0], nodeJson["position"][1]), nodeJson["id"], std::vector< Node::NodeID >(nodeJson["connected to"].begin(), nodeJson["connected to"].end()), - nodeJson["occupied"])); + nodeJson["occupied"], + std::vector< Object::ID >(nodeJson["nodesOccupying"].begin(), + nodeJson["nodesOccupying"].end()))); } m_pathFinder.SetInitialized(); @@ -67,7 +69,7 @@ Level::Load(Application* context, const std::string& pathToLevel) const auto position = json[key]["position"]; const auto size = json[key]["size"]; const auto texture = json[key]["texture"]; - const auto weapons = json[key]["weapons"]; + // const auto weapons = json[key]["weapons"]; const auto name = json[key]["name"]; m_player = std::make_shared< Player >(*context, glm::vec2(position[0], position[1]), @@ -78,13 +80,13 @@ Level::Load(Application* context, const std::string& pathToLevel) } else if (key == "ENEMIES") { - for (auto& enemy : json[key]) + for (const auto& enemy : json[key]) { - const auto position = enemy["position"]; - const auto size = enemy["size"]; - const auto texture = enemy["texture"]; - const auto weapons = enemy["weapons"]; - const auto name = enemy["name"]; + const auto& position = enemy["position"]; + const auto& size = enemy["size"]; + const auto& texture = enemy["texture"]; + // const auto weapons = enemy["weapons"]; + const auto& name = enemy["name"]; auto object = std::make_shared< Enemy >(*context, glm::vec2(position[0], position[1]), glm::ivec2(size[0], size[1]), texture, @@ -96,7 +98,7 @@ Level::Load(Application* context, const std::string& pathToLevel) std::vector< AnimationPoint > keypointsPositions = {}; glm::vec2 beginPoint = glm::vec2(position[0], position[1]); - for (auto& point : enemy["animate positions"]) + for (const auto& point : enemy["animate positions"]) { AnimationPoint animationPoint(object->GetID()); animationPoint.m_end = glm::vec2(point["end position"][0], point["end position"][1]); @@ -107,18 +109,18 @@ Level::Load(Application* context, const std::string& pathToLevel) beginPoint = animationPoint.m_end; } - object->SetAnimationKeypoints(keypointsPositions); + object->SetAnimationKeypoints(std::move(keypointsPositions)); m_objects.emplace_back(object); } } else if (key == "OBJECTS") { - for (auto& object : json[key]) + for (const auto& object : json[key]) { - const auto position = object["position"]; - const auto size = object["size"]; - const auto texture = object["texture"]; - const auto name = object["name"]; + const auto& position = object["position"]; + const auto& size = object["size"]; + const auto& texture = object["texture"]; + const auto& name = object["name"]; auto gameObject = std::make_shared< GameObject >( *context, glm::vec2(position[0], position[1]), glm::ivec2(size[0], size[1]), texture, @@ -133,7 +135,7 @@ Level::Load(Application* context, const std::string& pathToLevel) } else { - m_logger.Log(Logger::TYPE::FATAL, + m_logger.Log(Logger::Type::FATAL, "Level::Load -> Unspecified type " + key + " during level loading"); } } @@ -153,6 +155,7 @@ Level::Save(const std::string& pathToLevel) nodeJson["position"] = {node.m_position.x, node.m_position.y}; nodeJson["connected to"] = node.m_connectedNodes; nodeJson["occupied"] = node.m_occupied; + nodeJson["nodesOccupying"] = node.m_objectsOccupyingThisNode; json["PATHFINDER"]["nodes"].emplace_back(nodeJson); } @@ -171,8 +174,7 @@ Level::Save(const std::string& pathToLevel) { case Object::TYPE::PLAYER: { json["PLAYER"]["name"] = m_player->GetName(); - json["PLAYER"]["position"] = {m_player->GetPosition().x, - m_player->GetPosition().y}; + json["PLAYER"]["position"] = {m_player->GetPosition().x, m_player->GetPosition().y}; json["PLAYER"]["scale"] = {m_player->GetSprite().GetScale().x, m_player->GetSprite().GetScale().y}; json["PLAYER"]["rotation"] = m_player->GetSprite().GetRotation(); @@ -195,7 +197,7 @@ Level::Save(const std::string& pathToLevel) enemyJson["rotation"] = object->GetSprite().GetRotation(); enemyJson["texture"] = object->GetSprite().GetTextureName(); - auto enemyPtr = dynamic_cast< Enemy* >(object.get()); + auto* enemyPtr = dynamic_cast< Enemy* >(object.get()); enemyJson["weapons"] = enemyPtr->GetWeapon(); enemyJson["animation type"] = @@ -223,7 +225,7 @@ Level::Save(const std::string& pathToLevel) objectJson["has collision"] = object->GetHasCollision(); const auto occupiedNodes = object->GetOccupiedNodes(); - for (auto& node : occupiedNodes) + for (const auto& node : occupiedNodes) { nlohmann::json occupiedNode; occupiedNode["tile position"] = {node.first, node.second}; @@ -244,7 +246,7 @@ Level::Save(const std::string& pathToLevel) break; default: { - m_logger.Log(Logger::TYPE::WARNING, + m_logger.Log(Logger::Type::WARNING, "Unhandled Object type {} present in game level file!", object->GetTypeString()); } @@ -264,7 +266,7 @@ Level::Quit() std::shared_ptr< GameObject > Level::AddGameObject(GameObject::TYPE objectType) { - const auto defaultPosition = GetLocalVec(m_contextPointer->GetCamera().GetPosition()); + const auto defaultPosition = m_contextPointer->GetCamera().GetPosition(); const auto defaultSize = glm::ivec2(128, 128); const auto defaultTexture = std::string("Default128.png"); @@ -309,34 +311,9 @@ Level::AddGameObject(GameObject::TYPE objectType) return newObject; } -glm::vec2 -Level::GetLocalVec(const glm::vec2& global) const -{ - // get the vector relative to map's position - // glm::vec2 returnVal{m_background.GetPosition() - global}; - - //// change 'y' to originate in top left - // returnVal.y -= m_levelSize.y; - // returnVal *= -1; - - return global; -} - -glm::vec2 -Level::GetGlobalVec(const glm::vec2& local) const -{ - // glm::vec2 returnVal = local; - - // returnVal *= -1; - // returnVal.y += m_levelSize.y; - // returnVal = m_background.GetPosition() - returnVal; - - return local; -} - std::vector< Tile_t > Level::GameObjectMoved(const std::array< glm::vec2, 4 >& box, - const std::vector< Tile_t >& currentTiles) + const std::vector< Tile_t >& currentTiles, Object::ID objectID) { auto new_tiles = GetTilesFromBoundingBox(box); @@ -344,12 +321,12 @@ Level::GameObjectMoved(const std::array< glm::vec2, 4 >& box, { for (auto tileID : currentTiles) { - m_pathFinder.SetNodeFreed(tileID); + m_pathFinder.SetNodeFreed(tileID, objectID); } for (auto tileID : new_tiles) { - m_pathFinder.SetNodeOccupied(tileID); + m_pathFinder.SetNodeOccupied(tileID, objectID); } } @@ -477,7 +454,7 @@ Level::LoadPremade(const std::string& fileName, const glm::ivec2& size) } void -Level::LoadShaders(const std::string&) +Level::LoadShaders(const std::string& /*shaderName*/) { // m_shaders.LoadShaders(shaderName); } @@ -492,7 +469,7 @@ Level::DeleteObject(Object::ID deletedObject) if (objectIter == m_objects.end()) { - m_logger.Log(Logger::TYPE::FATAL, + m_logger.Log(Logger::Type::FATAL, "Trying to delete an object that doesn't exist! Object type: {}", Object::GetTypeString(deletedObject)); } @@ -561,11 +538,12 @@ Level::GetObjectRef(Object::ID objectID) break; default: { - m_logger.Log(Logger::TYPE::FATAL, "Trying to get Object on unknown type!"); + m_logger.Log(Logger::Type::FATAL, "Trying to get Object on unknown type!"); } } // This should never happen + // NOLINTNEXTLINE assert(requestedObject); return *requestedObject; @@ -619,13 +597,13 @@ Level::MoveObjs(const glm::vec2& moveBy) } const std::vector< std::shared_ptr< GameObject > >& -Level::GetObjects(bool) +Level::GetObjects() const { return m_objects; } void -Level::SetPlayersPosition(const glm::vec2&) +Level::SetPlayersPosition(const glm::vec2& /*position*/) { // m_playerPos = position; // m_playerPos /= m_tileSize; diff --git a/engine/Game/Level.hpp b/engine/Game/Level.hpp index 8b1ef360..7f8c8c55 100644 --- a/engine/Game/Level.hpp +++ b/engine/Game/Level.hpp @@ -19,41 +19,42 @@ class Level public: static constexpr Tile_t invalidTile = Tile_t{-1, -1}; - public: std::shared_ptr< GameObject > AddGameObject(GameObject::TYPE objectType); - // Convert from OpenGL position to map position - glm::vec2 - GetLocalVec(const glm::vec2& local) const; - - // Convert from map position to OpenGL - glm::vec2 - GetGlobalVec(const glm::vec2& local) const; - - std::vector< Tile_t > + [[nodiscard]] std::vector< Tile_t > GetTilesFromBoundingBox(const std::array< glm::vec2, 4 >& box) const; - Tile_t + [[nodiscard]] Tile_t GetTileFromPosition(const glm::vec2& local) const; void MoveObjs(const glm::vec2& moveBy); + /** + * \brief Called whenever an ombject with collision is moved. Generates the vector of + * occupied tiles/nodes, based on \c box + * + * \param[in] box Object's bounding box, needed to calculate collision + * \param[in] currentTiles Tiles occupied by the object, up to this point + * \param[in] objectID ID of the object that was moved + * + * \return Vector of tiles/nodes occupied by given object + */ std::vector< Tile_t > - GameObjectMoved(const std::array< glm::vec2, 4 >& box, - const std::vector< Tile_t >& currentTiles); + GameObjectMoved(const std::array< glm::vec2, 4 >& box, const std::vector< Tile_t >& currentTiles, + Object::ID objectID); void Create(Application* context, const glm::ivec2& size); - // pathToFile - global path to level file (.dgl) + // pathToLevel - global path to level file (.dgl) void - Load(Application* context, const std::string& pathToFile); + Load(Application* context, const std::string& pathToLevel); - // pathToFile - global path to level file (.dgl) + // pathToLevel - global path to level file (.dgl) void - Save(const std::string& pathToFile); + Save(const std::string& pathToLevel); void Quit(); @@ -68,7 +69,7 @@ class Level DeleteObject(Object::ID deletedObject); Object& - GetObjectRef(Object::ID object); + GetObjectRef(Object::ID objectID); void Update(bool isReverse); @@ -89,7 +90,7 @@ class Level * * \return True if it's on the map, false otherwise */ - bool + [[nodiscard]] bool IsInLevelBoundaries(const glm::vec2& position) const; /** @@ -119,7 +120,7 @@ class Level * * \return Vector of tiles */ - std::vector< Tile_t > + [[nodiscard]] std::vector< Tile_t > GetTilesAlongTheLine(const glm::vec2& fromPos, const glm::vec2& toPos) const; void @@ -134,19 +135,19 @@ class Level m_locked = false; } - bool + [[nodiscard]] bool IsCameraLocked() const { return m_locked; } - glm::vec2 + [[nodiscard]] glm::vec2 GetLevelPosition() const { return m_background.GetPosition(); } - glm::ivec2 + [[nodiscard]] glm::ivec2 GetSize() const { return m_levelSize; @@ -167,11 +168,11 @@ class Level return m_player; } - const std::vector< std::shared_ptr< GameObject > >& - GetObjects(bool includePlayer = false); + [[nodiscard]] const std::vector< std::shared_ptr< GameObject > >& + GetObjects() const; - std::string - GetShader() + [[nodiscard]] std::string + GetShader() const { return m_shaderName; } @@ -185,7 +186,7 @@ class Level std::shared_ptr< GameObject > GetGameObjectOnLocation(const glm::vec2& screenPosition); - uint32_t + [[nodiscard]] uint32_t GetTileSize() const { return m_tileWidth; diff --git a/engine/Game/Object.cpp b/engine/Game/Object.cpp index 8d873162..a5d3bc09 100644 --- a/engine/Game/Object.cpp +++ b/engine/Game/Object.cpp @@ -5,7 +5,7 @@ namespace dgame { static std::string TypeToString(Object::TYPE type) { - std::string typeStr = ""; + std::string typeStr; switch (type) { @@ -48,10 +48,8 @@ Object::GetTypeFromString(const std::string& stringType) return s_map[stringType]; } -Object::Object(TYPE type) +Object::Object(TYPE type) : m_type(type) { - m_type = type; - // First 32 bits are for ids, the other are for type storage auto type_val = static_cast< ID >(type) << TYPE_NUM_BITS; m_id = type_val + s_currentID; @@ -88,27 +86,26 @@ Object::GetTypeFromID(ID id) { // Shift 'id' value to its type part const auto type_part = id >> TYPE_NUM_BITS; + Object::TYPE type = TYPE::NONE; if (type_part & static_cast< ID >(TYPE::ENEMY)) { - return TYPE::ENEMY; + type = TYPE::ENEMY; } else if (type_part & static_cast< ID >(TYPE::PLAYER)) { - return TYPE::PLAYER; + type = TYPE::PLAYER; } else if (type_part & static_cast< ID >(TYPE::ANIMATION_POINT)) { - return TYPE::ANIMATION_POINT; + type = TYPE::ANIMATION_POINT; } else if (type_part & static_cast< ID >(TYPE::PATHFINDER_NODE)) { - return TYPE::PATHFINDER_NODE; - } - else - { - return TYPE::NONE; + type = TYPE::PATHFINDER_NODE; } + + return type; } Object::ID diff --git a/engine/Game/Object.hpp b/engine/Game/Object.hpp index 323e57f4..855ece85 100644 --- a/engine/Game/Object.hpp +++ b/engine/Game/Object.hpp @@ -9,16 +9,17 @@ namespace dgame { // Base class for all objects located in the game (player, enemy, light source, particle emitter // etc. +// NOLINTNEXTLINE class Object { public: using ID = uint64_t; using VectorPtr = std::vector< std::shared_ptr< Object > >; + // NOLINTNEXTLINE static constexpr ID INVALID_ID = static_cast< ID >(~0); - static constexpr auto TYPE_NUM_BITS = 32; + static constexpr uint32_t TYPE_NUM_BITS = 32; - public: enum class TYPE { NONE = 0, @@ -29,6 +30,9 @@ class Object PATHFINDER_NODE = 8 }; + explicit Object(TYPE type); + virtual ~Object() = default; + static TYPE GetTypeFromString(const std::string& stringType); @@ -38,18 +42,15 @@ class Object static std::string GetTypeString(ID id); - Object(TYPE type); - virtual ~Object() = default; - void SetType(TYPE); - TYPE + [[nodiscard]] TYPE GetType() const; - std::string + [[nodiscard]] std::string GetTypeString() const; - ID + [[nodiscard]] ID GetID() const; protected: @@ -57,13 +58,14 @@ class Object ID m_id; + // NOLINTNEXTLINE static inline std::unordered_map< std::string, TYPE > s_map = { {"Enemy", Object::TYPE::ENEMY}, {"Player", Object::TYPE::PLAYER}, {"Object", Object::TYPE::OBJECT}, {"Animation Point", Object::TYPE::ANIMATION_POINT}, {"Pathfinder Node", Object::TYPE::PATHFINDER_NODE}}; - static inline ID s_currentID = 0; + static inline ID s_currentID = 0; // NOLINT }; inline bool diff --git a/engine/Game/PathFinder.cpp b/engine/Game/PathFinder.cpp index f3fcb761..d2336f6d 100644 --- a/engine/Game/PathFinder.cpp +++ b/engine/Game/PathFinder.cpp @@ -7,7 +7,7 @@ namespace dgame { PathFinder::PathFinder(const glm::ivec2& levelSize, const uint32_t tileSize, std::vector< Node >&& nodes) - : m_initialized(false), m_nodes(nodes), m_levelSize(levelSize), m_tileSize(tileSize) + : m_nodes(std::move(nodes)), m_levelSize(levelSize), m_tileSize(tileSize) { } @@ -25,8 +25,8 @@ PathFinder::Initialize(const glm::ivec2& levelSize, const uint32_t tileSize) const auto grad = static_cast< int32_t >(tileSize); - const auto w = static_cast< int32_t >(levelSize.x / grad); - const auto h = static_cast< int32_t >(levelSize.y / grad); + const auto w = levelSize.x / grad; + const auto h = levelSize.y / grad; const auto offset = glm::vec2(static_cast< float >(grad) / 2.0f, static_cast< float >(grad) / 2.0f); @@ -68,6 +68,8 @@ PathFinder::Initialize(const glm::ivec2& levelSize, const uint32_t tileSize) AddNode(std::move(node)); } } + + m_initialized = true; } void @@ -113,13 +115,14 @@ PathFinder::GetNodeIDFromPosition(const glm::vec2& position) const const auto w = static_cast< int32_t >(glm::floor(position.x / static_cast< float >(m_tileSize))); const auto h = static_cast< int32_t >(glm::floor(position.y / static_cast< float >(m_tileSize))); - const auto node = std::find_if(m_nodes.begin(), m_nodes.end(), [w, h](const auto& node) { + const auto nodeFound = std::find_if(m_nodes.begin(), m_nodes.end(), [w, h](const auto& node) { return node.m_xPos == w and node.m_yPos == h; }); - assert(node != m_nodes.end()); + // NOLINTNEXTLINE + assert(nodeFound != m_nodes.end()); - return node->m_ID; + return nodeFound->m_ID; } Node& @@ -131,24 +134,26 @@ PathFinder::GetNodeFromPosition(const glm::vec2& position) Node& PathFinder::GetNodeFromID(Node::NodeID ID) { - const auto node = std::find_if(m_nodes.begin(), m_nodes.end(), - [ID](const auto& node) { return node.m_ID == ID; }); + const auto nodeFound = std::find_if(m_nodes.begin(), m_nodes.end(), + [ID](const auto& node) { return node.m_ID == ID; }); - assert(node != m_nodes.end()); + // NOLINTNEXTLINE + assert(nodeFound != m_nodes.end()); - return *node; + return *nodeFound; } Node::NodeID PathFinder::GetNodeIDFromTile(const glm::ivec2& tile) const { - const auto node = std::find_if(m_nodes.begin(), m_nodes.end(), [tile](const auto& node) { + const auto nodeFound = std::find_if(m_nodes.begin(), m_nodes.end(), [tile](const auto& node) { return node.m_xPos == tile.x and node.m_yPos == tile.y; }); - assert(node != m_nodes.end()); + // NOLINTNEXTLINE + assert(nodeFound != m_nodes.end()); - return node->m_ID; + return nodeFound->m_ID; } std::vector< Node::NodeID > @@ -191,11 +196,15 @@ PathFinder::GetPath(const glm::vec2& source, const glm::vec2& destination) // Front of listNotTestedNodes is potentially the lowest distance node. Our // list may also contain nodes that have been visited, so ditch these... while (!listNotTestedNodes.empty() && listNotTestedNodes.front()->m_visited) + { listNotTestedNodes.pop_front(); + } // ...or abort because there are no valid nodes left to test if (listNotTestedNodes.empty()) + { break; + } nodeCurrent = listNotTestedNodes.front(); nodeCurrent->m_visited = true; // We only explore a node once @@ -209,7 +218,9 @@ PathFinder::GetPath(const glm::vec2& source, const glm::vec2& destination) // ... and only if the neighbour is not visited and is // not an obstacle, add it to NotTested List if (!nodeNeighbour.m_visited && !nodeNeighbour.m_occupied) + { listNotTestedNodes.push_back(&nodeNeighbour); + } // Calculate the neighbours potential lowest parent distance float fPossiblyLowerGoal = @@ -257,7 +268,7 @@ PathFinder::GetPath(const glm::vec2& source, const glm::vec2& destination) } void -PathFinder::SetNodeOccupied(const Tile_t& nodeCoords) +PathFinder::SetNodeOccupied(const Tile_t& nodeCoords, Object::ID objectID) { if (nodeCoords != Tile_t{-1, -1}) { @@ -265,14 +276,16 @@ PathFinder::SetNodeOccupied(const Tile_t& nodeCoords) return (node.m_xPos == nodeCoords.first) and (node.m_yPos == nodeCoords.second); }); + // NOLINTNEXTLINE assert(node != m_nodes.end()); node->m_occupied = true; + node->m_objectsOccupyingThisNode.push_back(objectID); } } void -PathFinder::SetNodeFreed(const Tile_t& nodeCoords) +PathFinder::SetNodeFreed(const Tile_t& nodeCoords, Object::ID objectID) { if (nodeCoords != Tile_t{-1, -1}) { @@ -280,9 +293,17 @@ PathFinder::SetNodeFreed(const Tile_t& nodeCoords) return (node.m_xPos == nodeCoords.first) and (node.m_yPos == nodeCoords.second); }); + // NOLINTNEXTLINE assert(node != m_nodes.end()); - node->m_occupied = false; + node->m_objectsOccupyingThisNode.erase(std::find(node->m_objectsOccupyingThisNode.begin(), + node->m_objectsOccupyingThisNode.end(), + objectID)); + + if (node->m_objectsOccupyingThisNode.empty()) + { + node->m_occupied = false; + } } } diff --git a/engine/Game/PathFinder.hpp b/engine/Game/PathFinder.hpp index b76adf03..20a52b88 100644 --- a/engine/Game/PathFinder.hpp +++ b/engine/Game/PathFinder.hpp @@ -17,15 +17,17 @@ struct Node : public Object { } - Node(const glm::ivec2& coords, const glm::vec2& posOnMap, NodeID ID, - const std::vector< NodeID >& connectedTo, bool occupied = false) + Node(const glm::ivec2& coords, const glm::vec2& posOnMap, NodeID nodeID, + std::vector< NodeID > connectedTo = {}, bool occupied = false, + std::vector< Object::ID > objectOccupying = {}) : Object(Object::TYPE::PATHFINDER_NODE), m_xPos(coords.x), m_yPos(coords.y), m_position(posOnMap), m_occupied(occupied), - m_ID(ID), - m_connectedNodes(connectedTo) + m_ID(nodeID), + m_connectedNodes(std::move(connectedTo)), + m_objectsOccupyingThisNode(std::move(objectOccupying)) { } @@ -43,6 +45,7 @@ struct Node : public Object NodeID m_parentNode = -1; std::vector< NodeID > m_connectedNodes = {}; + std::vector< Object::ID > m_objectsOccupyingThisNode = {}; bool m_visited = false; int32_t m_localCost = std::numeric_limits< int32_t >::max(); @@ -59,7 +62,7 @@ class PathFinder { public: PathFinder() = default; - PathFinder(const glm::ivec2& levelSize, const uint32_t tileSize, std::vector< Node >&& nodes); + PathFinder(const glm::ivec2& levelSize, uint32_t tileSize, std::vector< Node >&& nodes); /** * \brief Initialize Pathfinder. This will create nodes for entire Level. @@ -68,7 +71,7 @@ class PathFinder * \param[in] tileSize Size of tile */ void - Initialize(const glm::ivec2& levelSize, const uint32_t tileSize); + Initialize(const glm::ivec2& levelSize, uint32_t tileSize); /** * \brief Initialize Pathfinder. This will not create nodes. @@ -77,7 +80,7 @@ class PathFinder * \param[in] tileSize Size of tile */ void - InitializeEmpty(const glm::ivec2& levelSize, const uint32_t tileSize); + InitializeEmpty(const glm::ivec2& levelSize, uint32_t tileSize); /** * \brief Mark Pathfinder as initialized @@ -90,7 +93,7 @@ class PathFinder * * \return Whether it's initialized */ - bool + [[nodiscard]] bool IsInitialized() const; /** @@ -114,7 +117,7 @@ class PathFinder * * \return Nodes vector */ - const std::vector< Node >& + [[nodiscard]] const std::vector< Node >& GetAllNodes() const; /** @@ -132,7 +135,7 @@ class PathFinder * * \return NodeID */ - Node::NodeID + [[nodiscard]] Node::NodeID GetNodeIDFromPosition(const glm::vec2& position) const; /** @@ -152,7 +155,7 @@ class PathFinder * * \return NodeID */ - Node::NodeID + [[nodiscard]] Node::NodeID GetNodeIDFromTile(const glm::ivec2& tile) const; /** @@ -180,17 +183,19 @@ class PathFinder * \brief Set node (on the given tile) occupied * * \param[in] nodeCoords Tile on the map + * \param[in] objectID Object that occupies this node/tile */ void - SetNodeOccupied(const Tile_t& nodeCoords); + SetNodeOccupied(const Tile_t& nodeCoords, Object::ID objectID); /** * \brief Set node (on the given tile) freed * * \param[in] nodeCoords Tile on the map + * \param[in] objectID Object that no longer occupies this node/tile */ void - SetNodeFreed(const Tile_t& nodeCoords); + SetNodeFreed(const Tile_t& nodeCoords, Object::ID objectID); private: bool m_initialized = false; diff --git a/engine/Game/Player.cpp b/engine/Game/Player.cpp index dfae6e3c..7d8ea8ee 100644 --- a/engine/Game/Player.cpp +++ b/engine/Game/Player.cpp @@ -15,12 +15,13 @@ Player::Player(Application& game, const glm::vec2& position, const glm::ivec2& s m_name = name; m_currentState.m_velocity = {0.0f, 0.0f}; m_currentState.m_speed = 0.0005f; - m_maxHP = 100; + m_currentState.m_currentHP = m_maxHP; - // GameObject::m_currentState.m_position = position; + // m_currentGameObjectState.m_position = position; m_weapons[0] = std::make_unique< SniperRifle >(); m_weapons[1] = std::make_unique< Glock >(); + // NOLINTNEXTLINE m_currentWeapon = m_weapons.at(0).get(); } @@ -29,17 +30,17 @@ Player::Player(Application& game, const glm::vec2& position, const glm::ivec2& s // fileName) //{ // m_collision = m_sprite.SetSpriteTextured(position, size, fileName); -// GameObject::m_currentState.m_centeredPosition = m_sprite.GetPosition(); -// GameObject::m_currentState.m_position = glm::ivec2(position.x, -position.y); +// m_currentGameObjectState.m_centeredPosition = m_sprite.GetPosition(); +// m_currentGameObjectState.m_position = glm::ivec2(position.x, -position.y); //} void -Player::LoadShaders(const std::string&) +Player::LoadShaders(const std::string& /*shaderName*/) { } void -Player::LoadShaders(const Shader&) +Player::LoadShaders(const Shader& /*shaderName*/) { } @@ -47,7 +48,7 @@ bool Player::CheckCollision(const glm::vec2& bulletPosition, Enemy const* enemy, bool enemyShooting) { // if the bullet is inside collision zone then player got hit - if (glm::length(glm::vec2(bulletPosition - GameObject::m_currentState.m_centeredPosition)) + if (glm::length(glm::vec2(bulletPosition - m_currentGameObjectState.m_centeredPosition)) < (static_cast< float >(m_sprite.GetSize().x)) / 2.5f) { if (enemyShooting) @@ -63,10 +64,9 @@ Player::CheckCollision(const glm::vec2& bulletPosition, Enemy const* enemy, bool glm::vec2 Player::GetScreenPosition() const { - glm::vec4 screenPosition = - m_appHandle.GetProjection() - * glm::vec4(GameObject::m_currentState.m_centeredPosition, 0.0f, 1.0f); - return glm::vec2(screenPosition.x, screenPosition.y); + glm::vec4 screenPosition = m_appHandle.GetProjection() + * glm::vec4(m_currentGameObjectState.m_centeredPosition, 0.0f, 1.0f); + return {screenPosition.x, screenPosition.y}; } void @@ -81,15 +81,12 @@ Player::UpdateInternal(bool isReverse) { if (m_appHandle.IsGame()) { - if (!isReverse) - { - const auto gameHandle = ConvertToGameHandle(); - const auto cursorPos = gameHandle->ScreenToGlobal(gameHandle->GetCursor()); - const auto spritePosition = GameObject::m_currentState.m_position; - - m_currentState.m_viewAngle = - glm::atan(spritePosition.y - cursorPos.y, spritePosition.x - cursorPos.x); - } + auto* const gameHandle = ConvertToGameHandle(); + const auto cursorPos = gameHandle->ScreenToGlobal(gameHandle->GetCursor()); + const auto spritePosition = m_currentGameObjectState.m_position; + + m_currentState.m_viewAngle = + glm::atan(spritePosition.y - cursorPos.y, spritePosition.x - cursorPos.x); } m_sprite.Rotate(m_currentState.m_viewAngle); @@ -107,16 +104,16 @@ Player::UpdateInternal(bool isReverse) void Player::Shoot() { - auto gameHandle = ConvertToGameHandle(); + auto* gameHandle = ConvertToGameHandle(); - const auto direction = gameHandle->GetCursor() - GameObject::m_currentState.m_position; + const auto direction = gameHandle->GetCursor() - m_currentGameObjectState.m_position; m_currentWeapon->Shoot(direction); } void -Player::SetPosition(const glm::vec2& pos) +Player::SetPosition(const glm::vec2& position) { - GameObject::m_currentState.m_position = pos; + m_currentGameObjectState.m_position = position; } float diff --git a/engine/Game/Player.hpp b/engine/Game/Player.hpp index 9f30b0cf..ccbdb0e7 100644 --- a/engine/Game/Player.hpp +++ b/engine/Game/Player.hpp @@ -39,11 +39,11 @@ class Player : public GameObject // get centered (center of player's sprite) position on screen // using projection matrix from OpenGL - glm::vec2 + [[nodiscard]] glm::vec2 GetScreenPosition() const; // get reload time of player's current weapon - float + [[nodiscard]] float GetReloadTime() const; // change player's current weapon @@ -51,14 +51,14 @@ class Player : public GameObject ChangeWepon(int32_t idx); // get player's current weapon range - float + [[nodiscard]] float GetWeaponRange() const; // get player's current weapon's damage - int32_t + [[nodiscard]] int32_t GetWeaponDmg() const; - std::vector< std::string > + [[nodiscard]] std::vector< std::string > GetWeapons() const; // shoot with current weapon @@ -68,7 +68,7 @@ class Player : public GameObject /*void CreateSprite(const glm::vec2& position, const glm::ivec2& size, const std::string& fileName);*/ - void Hit(int32_t) override + void Hit(int32_t /*dmg*/) override { } @@ -93,7 +93,7 @@ class Player : public GameObject }; std::deque< State > m_statesQueue; - State m_currentState; + State m_currentState = {}; // array of player's weapons std::array< std::unique_ptr< Weapon >, 3 > m_weapons; diff --git a/engine/Game/Weapon.hpp b/engine/Game/Weapon.hpp index ad4d0ca9..97d04709 100644 --- a/engine/Game/Weapon.hpp +++ b/engine/Game/Weapon.hpp @@ -8,46 +8,51 @@ namespace dgame { class Weapon { -public: - Weapon(float range, int32_t dmg, int32_t ammoNum, bool hasAmmo, const std::string& name, + public: + Weapon(float range, int32_t dmg, int32_t ammoNum, bool hasAmmo, std::string&& name, float reloadTime) : m_range(range), m_dmg(dmg), m_ammoNum(ammoNum), m_hasAmmo(hasAmmo), - m_name(name), + m_name(std::move(name)), m_reloadTime(reloadTime) { } - public: virtual ~Weapon() = default; - - std::string + Weapon& + operator=(Weapon const&) = default; + Weapon& + operator=(Weapon&&) = default; + Weapon(Weapon&) = default; + Weapon(Weapon&&) = default; + + [[nodiscard]] std::string GetName() const { return m_name; } - int32_t + [[nodiscard]] int32_t GetAmmoNum() const { return m_ammoNum; } - float + [[nodiscard]] float GetReloadTime() const { return m_reloadTime; } - float + [[nodiscard]] float GetRange() const { return m_range; } - int32_t + [[nodiscard]] int32_t GetDamage() const { return m_dmg; @@ -71,7 +76,6 @@ class SniperRifle : public Weapon SniperRifle() : Weapon(1000.0f, 80, 10, true, {"sniper rifle"}, 1.0f) { } - ~SniperRifle() override = default; void Shoot(const glm::vec2& /*direction*/) override @@ -85,7 +89,6 @@ class Glock : public Weapon Glock() : Weapon(300.0f, 10, 20, true, {"glock"}, 0.3f) { } - ~Glock() override = default; void Shoot(const glm::vec2& /*direction*/) override diff --git a/engine/Input/Event.hpp b/engine/Input/Event.hpp index 9b6dfc2c..24d894c0 100644 --- a/engine/Input/Event.hpp +++ b/engine/Input/Event.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace dgame { @@ -14,7 +14,7 @@ struct Event MOUSE_SCROLL }; - Event(EventType t) : m_type(t) + explicit Event(EventType t) : m_type(t) { } diff --git a/engine/Input/InputListener.hpp b/engine/Input/InputListener.hpp index 56488017..665339c9 100644 --- a/engine/Input/InputListener.hpp +++ b/engine/Input/InputListener.hpp @@ -4,28 +4,29 @@ namespace dgame { +// NOLINTNEXTLINE class InputListener { public: virtual ~InputListener() = default; virtual void - KeyCallback(const KeyEvent&) + KeyCallback(const KeyEvent& /*event*/) { } virtual void - MouseButtonCallback(const MouseButtonEvent&) + MouseButtonCallback(const MouseButtonEvent& /*event*/) { } virtual void - CursorPositionCallback(const CursorPositionEvent&) + CursorPositionCallback(const CursorPositionEvent& /*event*/) { } virtual void - MouseScrollCallback(const MouseScrollEvent&) + MouseScrollCallback(const MouseScrollEvent& /*event*/) { } }; diff --git a/engine/Input/InputManager.cpp b/engine/Input/InputManager.cpp index 31317aa0..5f9d0b13 100644 --- a/engine/Input/InputManager.cpp +++ b/engine/Input/InputManager.cpp @@ -7,10 +7,10 @@ namespace dgame { void -InputManager::InternalKeyCallback(GLFWwindow*, int32_t key, int32_t scancode, int32_t action, +InputManager::InternalKeyCallback(GLFWwindow* /*window*/, int32_t key, int32_t scancode, int32_t action, int32_t mods) { - s_logger.Log(Logger::TYPE::TRACE, "GLFW key {} {} scan code - {}", action, key, scancode); + s_logger.Log(Logger::Type::TRACE, "GLFW key {} {} scan code - {}", action, key, scancode); s_keyMap[key] = action; @@ -18,29 +18,29 @@ InputManager::InternalKeyCallback(GLFWwindow*, int32_t key, int32_t scancode, in } void -InputManager::InternalMouseButtonCallback(GLFWwindow*, int32_t button, int32_t action, int32_t mods) +InputManager::InternalMouseButtonCallback(GLFWwindow* /*window*/, int32_t button, int32_t action, int32_t mods) { - s_logger.Log(Logger::TYPE::TRACE, "GLFW mouse button {} {} {}", button, action, mods); + s_logger.Log(Logger::Type::TRACE, "GLFW mouse button {} {} {}", button, action, mods); BroadcastEvent(MouseButtonEvent{button, action, mods}); } void -InputManager::InternalCursorPositionCallback(GLFWwindow*, double x, double y) +InputManager::InternalCursorPositionCallback(GLFWwindow* /*window*/, double xPos, double yPos) { - s_logger.Log(Logger::TYPE::TRACE, "GLFW cursor pos {} {}", x, y); + s_logger.Log(Logger::Type::TRACE, "GLFW cursor pos {} {}", xPos, yPos); - s_mousePosition = glm::vec2(x, y); + s_mousePosition = glm::vec2(xPos, yPos); - BroadcastEvent(CursorPositionEvent{x, y}); + BroadcastEvent(CursorPositionEvent{xPos, yPos}); } void -InputManager::InternalMouseScrollCallback(GLFWwindow*, double xoffset, double yoffset) +InputManager::InternalMouseScrollCallback(GLFWwindow* /*window*/, double xOffset, double yOffset) { - s_logger.Log(Logger::TYPE::TRACE, "GLFW scroll {} {}", xoffset, yoffset); + s_logger.Log(Logger::Type::TRACE, "GLFW scroll {} {}", xOffset, yOffset); - BroadcastEvent(MouseScrollEvent{xoffset, yoffset}); + BroadcastEvent(MouseScrollEvent{xOffset, yOffset}); } void @@ -49,7 +49,7 @@ InputManager::BroadcastEvent(const Event& event) switch (event.m_type) { case Event::EventType::KEY: { - for (auto listener : s_keyListeners) + for (auto* listener : s_keyListeners) { listener->KeyCallback(static_cast< const KeyEvent& >(event)); } @@ -57,7 +57,7 @@ InputManager::BroadcastEvent(const Event& event) break; case Event::EventType::MOUSE_BUTTON: { - for (auto listener : s_mouseButtonListeners) + for (auto* listener : s_mouseButtonListeners) { listener->MouseButtonCallback(static_cast< const MouseButtonEvent& >(event)); } @@ -65,7 +65,7 @@ InputManager::BroadcastEvent(const Event& event) break; case Event::EventType::MOUSE_CURSOR: { - for (auto listener : s_mouseMovementListeners) + for (auto* listener : s_mouseMovementListeners) { listener->CursorPositionCallback(static_cast< const CursorPositionEvent& >(event)); } @@ -73,7 +73,7 @@ InputManager::BroadcastEvent(const Event& event) break; case Event::EventType::MOUSE_SCROLL: { - for (auto listener : s_mouseScrollListeners) + for (auto* listener : s_mouseScrollListeners) { listener->MouseScrollCallback(static_cast< const MouseScrollEvent& >(event)); } diff --git a/engine/Input/InputManager.hpp b/engine/Input/InputManager.hpp index 34393421..2cc01fd6 100644 --- a/engine/Input/InputManager.hpp +++ b/engine/Input/InputManager.hpp @@ -59,15 +59,15 @@ class InputManager static void InternalMouseButtonCallback(GLFWwindow* window, int32_t button, int32_t action, int32_t mods); static void - InternalCursorPositionCallback(GLFWwindow* window, double xpos, double ypos); + InternalCursorPositionCallback(GLFWwindow* window, double xPos, double yPos); static void - InternalMouseScrollCallback(GLFWwindow* window, double xoffset, double yoffset); + InternalMouseScrollCallback(GLFWwindow* window, double xOffset, double yOffset); private: static void BroadcastEvent(const Event& event); - private: + // NOLINTBEGIN static inline std::vector< InputListener* > s_keyListeners = {}; static inline std::vector< InputListener* > s_mouseButtonListeners = {}; static inline std::vector< InputListener* > s_mouseMovementListeners = {}; @@ -79,6 +79,7 @@ class InputManager static inline glm::vec2 s_mousePosition = {}; static inline std::unordered_map< int32_t, bool > s_keyMap = {}; static inline Logger s_logger = Logger("InputManager"); + // NOLINTEND }; } // namespace dgame \ No newline at end of file diff --git a/engine/Logger/Logger.cpp b/engine/Logger/Logger.cpp index dce456aa..4bf1b31b 100644 --- a/engine/Logger/Logger.cpp +++ b/engine/Logger/Logger.cpp @@ -1,12 +1,9 @@ #include "Logger.hpp" -#include - namespace dgame { -Logger::Logger(const std::string& name) +Logger::Logger(std::string name) : m_moduleName(std::move((name))) { - m_moduleName = name; } void @@ -16,27 +13,27 @@ Logger::Init(const std::string& name) } std::string -Logger::ToString(const Logger::TYPE& type) const +Logger::ToString(Logger::Type type) { std::string returnValue; - if (type == Logger::TYPE::TRACE) + if (type == Logger::Type::TRACE) { returnValue = " [TRACE] "; } - else if (type == Logger::TYPE::DEBUG) + else if (type == Logger::Type::DEBUG) { returnValue = " [DEBUG] "; } - else if (type == Logger::TYPE::INFO) + else if (type == Logger::Type::INFO) { returnValue = " [INFO] "; } - else if (type == Logger::TYPE::WARNING) + else if (type == Logger::Type::WARNING) { returnValue = " [WARNING] "; } - else if (type == Logger::TYPE::FATAL) + else if (type == Logger::Type::FATAL) { returnValue = " [FATAL] "; } @@ -49,7 +46,7 @@ Logger::ToString(const Logger::TYPE& type) const } void -Logger::SetLogType(Logger::TYPE type) +Logger::SetLogType(Logger::Type type) { m_currentLogType = type; } diff --git a/engine/Logger/Logger.hpp b/engine/Logger/Logger.hpp index 22a8cbd2..b5d5a6f1 100644 --- a/engine/Logger/Logger.hpp +++ b/engine/Logger/Logger.hpp @@ -10,7 +10,7 @@ namespace dgame { class Logger { public: - enum class TYPE + enum class Type { TRACE = 0, DEBUG, @@ -19,16 +19,15 @@ class Logger FATAL }; - Logger(const std::string& name); + explicit Logger(std::string name); Logger() = default; - ~Logger() = default; void Init(const std::string& name); template < typename... Args > void - Log(TYPE type, const std::string& buffer, Args&&... args) const + Log(Type type, const std::string& buffer, Args&&... args) const { if (type >= m_currentLogType) { @@ -37,14 +36,16 @@ class Logger } } - static void SetLogType(TYPE); + static void + SetLogType(Type type); - std::string - ToString(const Logger::TYPE& type) const; + static std::string + ToString(Type type); private: std::string m_moduleName; - static inline TYPE m_currentLogType = Logger::TYPE::DEBUG; + // NOLINTNEXTLINE + static inline Type m_currentLogType = Type::DEBUG; }; } // namespace dgame diff --git a/engine/Render/Camera.cpp b/engine/Render/Camera.cpp index 3a2152c9..7a00a075 100644 --- a/engine/Render/Camera.cpp +++ b/engine/Render/Camera.cpp @@ -22,6 +22,8 @@ Camera::Create(const glm::vec3& position, const glm::ivec2& windowSize, const gl const auto bottom = -m_windowSize.y / 2.0f; m_viewMatrix = glm::lookAt(m_position, m_position + m_lookAtDirection, m_upVector); + + // NOLINTNEXTLINE top and bottom swapped intentionally m_projectionMatrix = glm::ortho(left, right, top, bottom, -1.0f, 10.0f); m_viewProjectionMatrix = m_projectionMatrix * m_viewMatrix; } @@ -35,6 +37,7 @@ Camera::SetLevelSize(const glm::vec2& size) void Camera::SetProjection(float left, float right, float top, float bottom) { + // NOLINTNEXTLINE top and bottom swapped intentionally m_projectionMatrix = glm::ortho(left, right, top, bottom, -1.0f, 10.0f); } @@ -52,7 +55,7 @@ Camera::SetCameraAtPosition(const glm::vec2& globalPosition) } void -Camera::SetCameraAtObject(std::shared_ptr< GameObject > object) +Camera::SetCameraAtObject(const std::shared_ptr< GameObject >& object) { m_position = glm::vec3(object->GetCenteredPosition(), 0.0f); UpdateViewMatrix(); @@ -93,6 +96,7 @@ Camera::Zoom(float value) const auto nearPlane = -1.0f; const auto farPlane = 1.0f; + // NOLINTNEXTLINE top and bottom swapped intentionally m_projectionMatrix = glm::ortho(left, right, top, bottom, nearPlane, farPlane); m_viewProjectionMatrix = m_projectionMatrix * m_viewMatrix; } @@ -128,7 +132,7 @@ Camera::GetPosition() const } float -Camera::GetRotation() +Camera::GetRotation() const { return m_rotationValue; } diff --git a/engine/Render/Camera.hpp b/engine/Render/Camera.hpp index 045f49df..83c0a2dc 100644 --- a/engine/Render/Camera.hpp +++ b/engine/Render/Camera.hpp @@ -13,7 +13,6 @@ class Camera { public: Camera() = default; - ~Camera() = default; void Create(const glm::vec3& position, const glm::ivec2& windowSize, @@ -33,7 +32,7 @@ class Camera SetCameraAtPosition(const glm::vec2& globalPosition); void - SetCameraAtObject(std::shared_ptr< GameObject > object); + SetCameraAtObject(const std::shared_ptr< GameObject >& object); void Move(const glm::vec3& conventionalVector); @@ -44,30 +43,30 @@ class Camera void Zoom(float value); - float + [[nodiscard]] float GetZoomLevel() const; - const glm::mat4& + [[nodiscard]] const glm::mat4& GetViewMatrix() const; - const glm::mat4& + [[nodiscard]] const glm::mat4& GetProjectionMatrix() const; - const glm::mat4& + [[nodiscard]] const glm::mat4& GetViewProjectionMatrix() const; - const glm::vec3& + [[nodiscard]] const glm::vec3& GetPosition() const; - float - GetRotation(); + [[nodiscard]] float + GetRotation() const; // Convert 'conventionalVector' to camera state related vector // Example: // - conventionalVector = vec3(1.0f, 0.0f, 0.0f) // - current camera is rotated by 90 degrees // function will return vec3(0.0f, 1.0f, 0.0f) - glm::vec3 + [[nodiscard]] glm::vec3 ConvertToCameraVector(const glm::vec3& conventionalVector) const; private: @@ -83,16 +82,16 @@ class Camera float m_maxZoomIn = 1.5f; float m_maxZoomOut = -1.5f; - glm::vec2 m_levelSize; - glm::vec2 m_windowSize; + glm::vec2 m_levelSize = {}; + glm::vec2 m_windowSize = {}; - glm::vec3 m_position; - glm::vec3 m_upVector; - glm::vec3 m_lookAtDirection; + glm::vec3 m_position = {}; + glm::vec3 m_upVector = {}; + glm::vec3 m_lookAtDirection = {}; - glm::mat4 m_viewMatrix; - glm::mat4 m_projectionMatrix; - glm::mat4 m_viewProjectionMatrix; + glm::mat4 m_viewMatrix = {}; + glm::mat4 m_projectionMatrix = {}; + glm::mat4 m_viewProjectionMatrix = {}; }; } // namespace dgame \ No newline at end of file diff --git a/engine/Render/Font.cpp b/engine/Render/Font.cpp index f69327b7..3a059b3c 100644 --- a/engine/Render/Font.cpp +++ b/engine/Render/Font.cpp @@ -12,20 +12,25 @@ namespace dgame { void -Font::SetFont(const std::string& fontName) +Font::SetFont(const std::string& fileName) { m_logger.Init("Font"); - FT_Library ft; + FT_Library ft = {}; if (FT_Init_FreeType(&ft)) - m_logger.Log(Logger::TYPE::FATAL, "Error initializing FreeType!"); + { + m_logger.Log(Logger::Type::FATAL, "Error initializing FreeType!"); + } - FT_Face face; - std::string filePath = fmt::format("{}.ttf", (FONTS_DIR / fontName).string()); + + FT_Face face = {}; + std::string filePath = fmt::format("{}.ttf", (FONTS_DIR / fileName).string()); if (FT_New_Face(ft, filePath.c_str(), 0, &face)) - m_logger.Log(Logger::TYPE::FATAL, "Error loading font " + filePath); + { + m_logger.Log(Logger::Type::FATAL, "Error loading font " + filePath); + } FT_New_Face(ft, filePath.c_str(), 0, &face); // Set size to load glyphs as @@ -38,17 +43,22 @@ Font::SetFont(const std::string& fontName) for (GLubyte c = 0; c < 128; ++c) { // Load character glyph + // NOLINTNEXTLINE if (FT_Load_Char(face, c, FT_LOAD_RENDER)) - m_logger.Log(Logger::TYPE::FATAL, "Error loading font face for character {} for font {}", + { + m_logger.Log(Logger::Type::FATAL, "Error loading font face for character {} for font {}", c, filePath); + } + // FT_Load_Char(face, c, FT_LOAD_RENDER); // Generate texture - GLuint texture; + GLuint texture = {}; glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, face->glyph->bitmap.width, face->glyph->bitmap.rows, 0, - GL_RED, GL_UNSIGNED_BYTE, face->glyph->bitmap.buffer); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, static_cast< GLint >(face->glyph->bitmap.width), + static_cast< GLint >(face->glyph->bitmap.rows), 0, GL_RED, GL_UNSIGNED_BYTE, + face->glyph->bitmap.buffer); // Set texture options glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); @@ -73,20 +83,20 @@ Font::SetFont(const std::string& fontName) glGenBuffers(1, &m_VBO); glBindVertexArray(m_VAO); glBindBuffer(GL_ARRAY_BUFFER, m_VBO); - glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 6 * 4, NULL, GL_DYNAMIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 6 * 4, nullptr, GL_DYNAMIC_DRAW); glEnableVertexAttribArray(0); - glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), 0); + glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), nullptr); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindVertexArray(0); glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - m_logger.Log(Logger::TYPE::INFO, fmt::format("Loaded font: {}", fontName)); + m_logger.Log(Logger::Type::INFO, fmt::format("Loaded font: {}", fileName)); } void Font::RenderText(const glm::mat4& /*projectionMatrix*/, std::string text, glm::vec2 position, - GLfloat scale, const glm::vec3&) + GLfloat scale, const glm::vec3& /*color*/) { // Activate corresponding render state /*m_program.UseProgram(); @@ -109,6 +119,7 @@ Font::RenderText(const glm::mat4& /*projectionMatrix*/, std::string text, glm::v position.y + static_cast< float >(m_characters['H'].bearing.y - ch.bearing.y) * scale; // Seems like it stores tex coords in Direct3d style FeelsBadMan + // NOLINTNEXTLINE GLfloat vertices[6][4] = { {xpos, ypos + h, 0.0, 1.0}, {xpos + w, ypos, 1.0, 0.0}, {xpos, ypos, 0.0, 0.0}, @@ -119,8 +130,10 @@ Font::RenderText(const glm::mat4& /*projectionMatrix*/, std::string text, glm::v // Update content of VBO memory glBindBuffer(GL_ARRAY_BUFFER, m_VBO); - glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), - vertices); // Be sure to use glBufferSubData and not glBufferData + + // Be sure to use glBufferSubData and not glBufferData + // NOLINTNEXTLINE + glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices); glBindBuffer(GL_ARRAY_BUFFER, 0); @@ -128,7 +141,7 @@ Font::RenderText(const glm::mat4& /*projectionMatrix*/, std::string text, glm::v glDrawArrays(GL_TRIANGLES, 0, 6); // Now advance cursors for next glyph (note that advance is number of 1/64 pixels) - position.x += static_cast< float >(ch.advance >> 6) + position.x += static_cast< float >(ch.advance >> 6U) * scale; // Bitshift by 6 to get value in pixels (2^6 = 64 (divide amount of // 1/64th pixels by 64 to get amount of pixels)) } diff --git a/engine/Render/Font.hpp b/engine/Render/Font.hpp index f9c0cc0a..9a8d7836 100644 --- a/engine/Render/Font.hpp +++ b/engine/Render/Font.hpp @@ -22,9 +22,6 @@ struct Character class Font { public: - Font() = default; - ~Font() = default; - void SetFont(const std::string& fileName); diff --git a/engine/Render/Framebuffer.cpp b/engine/Render/Framebuffer.cpp index cb07d07f..a133fde5 100644 --- a/engine/Render/Framebuffer.cpp +++ b/engine/Render/Framebuffer.cpp @@ -29,7 +29,7 @@ Framebuffer::SetUp(const glm::ivec2& windowSize) } void -Framebuffer::BeginDrawingToTexture() +Framebuffer::BeginDrawingToTexture() const { // DRAW TO FRAMEBUFFER glBindFramebuffer(GL_FRAMEBUFFER, m_framebufferID); @@ -38,7 +38,7 @@ Framebuffer::BeginDrawingToTexture() } void -Framebuffer::EndDrawingToTexture() +Framebuffer::EndDrawingToTexture() const { glBindFramebuffer(GL_FRAMEBUFFER, 0); } diff --git a/engine/Render/Framebuffer.hpp b/engine/Render/Framebuffer.hpp index aa646ef9..64042f4c 100644 --- a/engine/Render/Framebuffer.hpp +++ b/engine/Render/Framebuffer.hpp @@ -11,18 +11,17 @@ class Framebuffer { public: Framebuffer() = default; - ~Framebuffer() = default; void SetUp(const glm::ivec2& windowSize); void - BeginDrawingToTexture(); + BeginDrawingToTexture() const; void - EndDrawingToTexture(); + EndDrawingToTexture() const; - GLuint + [[nodiscard]] GLuint GetTExtureID() const; private: diff --git a/engine/Render/OpenGLRendererAPI.cpp b/engine/Render/OpenGLRendererAPI.cpp index 60cbe571..37e87862 100644 --- a/engine/Render/OpenGLRendererAPI.cpp +++ b/engine/Render/OpenGLRendererAPI.cpp @@ -4,23 +4,24 @@ #include #include - namespace dgame { void OpenGLRendererAPI::Init() { + // NOLINTNEXTLINE int status = gladLoadGLLoader(reinterpret_cast< GLADloadproc >(glfwGetProcAddress)); if (status != 1) { - m_logger.Log(Logger::TYPE::FATAL, "gladLoadGLLoader() != OK"); + m_logger.Log(Logger::Type::FATAL, "gladLoadGLLoader() != OK"); } - int major, minor; + int major = {}; + int minor = {}; glGetIntegerv(GL_MAJOR_VERSION, &major); glGetIntegerv(GL_MINOR_VERSION, &minor); - m_logger.Log(Logger::TYPE::DEBUG, "OpenGL Version - {}.{}", major, minor); + m_logger.Log(Logger::Type::DEBUG, "OpenGL Version - {}.{}", major, minor); glEnable(GL_DEBUG_OUTPUT); glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); @@ -31,27 +32,29 @@ OpenGLRendererAPI::Init() const auto buffer = fmt::format("OpenGL: type = {}, severity = {}, message = {}", type, severity, message); - auto logg = reinterpret_cast< const Logger* >(logger); + // NOLINTNEXTLINE + const auto* logg = reinterpret_cast< const Logger* >(logger); switch (severity) { case GL_DEBUG_SEVERITY_HIGH: - logg->Log(Logger::TYPE::FATAL, buffer); + logg->Log(Logger::Type::FATAL, buffer); return; case GL_DEBUG_SEVERITY_MEDIUM: - logg->Log(Logger::TYPE::WARNING, buffer); + logg->Log(Logger::Type::WARNING, buffer); return; case GL_DEBUG_SEVERITY_LOW: - logg->Log(Logger::TYPE::INFO, buffer); + logg->Log(Logger::Type::INFO, buffer); return; case GL_DEBUG_SEVERITY_NOTIFICATION: - logg->Log(Logger::TYPE::DEBUG, buffer); + default: + logg->Log(Logger::Type::DEBUG, buffer); return; } }, &m_logger); - glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_NOTIFICATION, 0, NULL, + glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_NOTIFICATION, 0, nullptr, GL_FALSE); glEnable(GL_BLEND); @@ -63,7 +66,8 @@ OpenGLRendererAPI::Init() void OpenGLRendererAPI::SetViewport(uint32_t x, uint32_t y, uint32_t width, uint32_t height) { - glViewport(x, y, width, height); + glViewport(static_cast< GLint >(x), static_cast< GLint >(y), static_cast< GLint >(width), + static_cast< GLint >(height)); } void @@ -75,6 +79,7 @@ OpenGLRendererAPI::SetClearColor(const glm::vec4& color) void OpenGLRendererAPI::Clear() { + // NOLINTNEXTLINE glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } @@ -83,14 +88,14 @@ OpenGLRendererAPI::DrawIndexed(const std::shared_ptr< VertexArray >& vertexArray uint32_t indexCount) { uint32_t count = indexCount ? indexCount : vertexArray->GetIndexBuffer()->GetCount(); - glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_INT, nullptr); + glDrawElements(GL_TRIANGLES, static_cast< GLsizei >(count), GL_UNSIGNED_INT, nullptr); glBindTexture(GL_TEXTURE_2D, 0); } void -OpenGLRendererAPI::DrawLines(uint32_t numLines) +OpenGLRendererAPI::DrawLines(uint32_t indexCount) { - glDrawArrays(GL_LINES, 0, numLines * 2); + glDrawArrays(GL_LINES, 0, static_cast< GLsizei >(indexCount * 2)); } } // namespace dgame diff --git a/engine/Render/OpenGLRendererAPI.hpp b/engine/Render/OpenGLRendererAPI.hpp index d6980f03..58455507 100644 --- a/engine/Render/OpenGLRendererAPI.hpp +++ b/engine/Render/OpenGLRendererAPI.hpp @@ -8,21 +8,22 @@ namespace dgame { class OpenGLRendererAPI : public RendererAPI { public: - ~OpenGLRendererAPI() override = default; - - virtual void + void Init() override; - virtual void + + void SetViewport(uint32_t x, uint32_t y, uint32_t width, uint32_t height) override; - virtual void + void SetClearColor(const glm::vec4& color) override; - virtual void + + void Clear() override; - virtual void + void DrawIndexed(const std::shared_ptr< VertexArray >& vertexArray, uint32_t indexCount = 0) override; - virtual void + + void DrawLines(uint32_t indexCount) override; private: diff --git a/engine/Render/RenderCommand.hpp b/engine/Render/RenderCommand.hpp index c13347af..2317b5c5 100644 --- a/engine/Render/RenderCommand.hpp +++ b/engine/Render/RenderCommand.hpp @@ -48,6 +48,7 @@ class RenderCommand } private: + // NOLINTNEXTLINE static inline std::unique_ptr< RendererAPI > s_RendererAPI = RendererAPI::Create(); }; diff --git a/engine/Render/Renderer.cpp b/engine/Render/Renderer.cpp index cc3f3717..e0a4325f 100644 --- a/engine/Render/Renderer.cpp +++ b/engine/Render/Renderer.cpp @@ -5,9 +5,9 @@ #include "TextureLibrary.hpp" #include "VertexArray.hpp" +#include #include #include -#include namespace dgame { @@ -28,10 +28,10 @@ struct LineVertex struct RendererData { - static inline const uint32_t MaxQuads = 20000; - static inline const uint32_t MaxVertices = MaxQuads * 4; - static inline const uint32_t MaxIndices = MaxQuads * 6; - static inline const uint32_t MaxTextureSlots = 32; // TODO: RenderCaps + static constexpr uint32_t MaxQuads = 20000; + static constexpr uint32_t MaxVertices = MaxQuads * 4; + static constexpr uint32_t MaxIndices = MaxQuads * 6; + static constexpr uint32_t MaxTextureSlots = 32; // TODO: RenderCaps std::shared_ptr< VertexArray > QuadVertexArray; std::shared_ptr< VertexBuffer > QuadVertexBuffer; @@ -48,8 +48,8 @@ struct RendererData struct LineRendererData { - static inline const uint32_t MaxLines = 200000; - static inline const uint32_t MaxVertices = MaxLines * 2; + static constexpr uint32_t MaxLines = 200000; + static constexpr uint32_t MaxVertices = MaxLines * 2; uint32_t NumLines = 0; std::shared_ptr< VertexArray > LineVertexArray; @@ -60,29 +60,39 @@ struct LineRendererData LineVertex* LineVertexBufferPtr = nullptr; }; +// NOLINTBEGIN static RendererData s_Data; static LineRendererData s_LineData; +template < typename Type > +static uint32_t +ComputeDataSize(Type* begin, Type* end) +{ + return static_cast< uint32_t >(reinterpret_cast< uint8_t* >(end) + - reinterpret_cast< uint8_t* >(begin)); +} +// NOLINTEND + void Renderer::Init() { s_Data.QuadVertexArray = std::make_shared< VertexArray >(); s_Data.QuadVertexBuffer = std::make_shared< VertexBuffer >( - static_cast< uint32_t >(s_Data.MaxVertices * sizeof(QuadVertex))); - s_Data.QuadVertexBuffer->SetLayout({{ShaderDataType::Float3, "a_Position"}, - {ShaderDataType::Float4, "a_Color"}, - {ShaderDataType::Float2, "a_TexCoord"}, - {ShaderDataType::Float, "a_TexIndex"}, - {ShaderDataType::Float, "a_TilingFactor"}}); + static_cast< uint32_t >(dgame::RendererData::MaxVertices * sizeof(QuadVertex))); + s_Data.QuadVertexBuffer->SetLayout(BufferLayout{{ShaderDataType::Float3, "a_Position"}, + {ShaderDataType::Float4, "a_Color"}, + {ShaderDataType::Float2, "a_TexCoord"}, + {ShaderDataType::Float, "a_TexIndex"}, + {ShaderDataType::Float, "a_TilingFactor"}}); s_Data.QuadVertexArray->AddVertexBuffer(s_Data.QuadVertexBuffer); - s_Data.QuadVertexBufferBase = new QuadVertex[s_Data.MaxVertices]; + s_Data.QuadVertexBufferBase = new QuadVertex[dgame::RendererData::MaxVertices]; - uint32_t* quadIndices = new uint32_t[s_Data.MaxIndices]; + auto* quadIndices = new uint32_t[dgame::RendererData::MaxIndices]; uint32_t offset = 0; - for (uint32_t i = 0; i < s_Data.MaxIndices; i += 6) + for (uint32_t i = 0; i < dgame::RendererData::MaxIndices; i += 6) { quadIndices[i + 0] = offset + 0; quadIndices[i + 1] = offset + 1; @@ -95,20 +105,22 @@ Renderer::Init() offset += 4; } - auto quadIB = std::make_shared< IndexBuffer >(quadIndices, s_Data.MaxIndices); + auto quadIB = std::make_shared< IndexBuffer >(quadIndices, dgame::RendererData::MaxIndices); s_Data.QuadVertexArray->SetIndexBuffer(quadIB); delete[] quadIndices; s_Data.WhiteTexture = std::make_shared< Texture >(); s_Data.WhiteTexture->CreateColorTexture({1, 1}, {1.0f, 1.0f, 1.0f}); - int32_t samplers[s_Data.MaxTextureSlots]; - for (uint32_t i = 0; i < s_Data.MaxTextureSlots; i++) - samplers[i] = static_cast< int32_t >(i); + std::array samplers = {}; + for (uint32_t i = 0; i < dgame::RendererData::MaxTextureSlots; i++){ + samplers.at(i) = static_cast< int32_t >(i); + } + s_Data.TextureShader = ShaderLibrary::GetShader("DefaultShader"); s_Data.TextureShader->UseProgram(); - s_Data.TextureShader->SetUniformIntArray(samplers, s_Data.MaxTextureSlots, "u_Textures"); + s_Data.TextureShader->SetUniformIntArray(samplers.data(), dgame::RendererData::MaxTextureSlots, "u_Textures"); // Set all texture slots to 0 s_Data.TextureSlots[0] = s_Data.WhiteTexture; @@ -117,12 +129,12 @@ Renderer::Init() s_LineData.LineVertexArray = std::make_shared< VertexArray >(); s_LineData.LineVertexBuffer = std::make_shared< VertexBuffer >( - static_cast< uint32_t >(s_LineData.MaxVertices * sizeof(LineVertex))); + static_cast< uint32_t >(dgame::LineRendererData::MaxVertices * sizeof(LineVertex))); s_LineData.LineVertexBuffer->SetLayout( - {{ShaderDataType::Float3, "a_Position"}, {ShaderDataType::Float4, "a_Color"}}); + BufferLayout{{ShaderDataType::Float3, "a_Position"}, {ShaderDataType::Float4, "a_Color"}}); s_LineData.LineVertexArray->AddVertexBuffer(s_LineData.LineVertexBuffer); - s_LineData.LineVertexBufferBase = new LineVertex[s_LineData.MaxVertices]; + s_LineData.LineVertexBufferBase = new LineVertex[dgame::LineRendererData::MaxVertices]; s_LineData.LineShader = ShaderLibrary::GetShader("LineShader"); } @@ -181,17 +193,13 @@ Renderer::SendData(PrimitiveType type) { if (type == PrimitiveType::QUAD) { - auto dataSize = - static_cast< uint32_t >(reinterpret_cast< uint8_t* >(s_Data.QuadVertexBufferPtr) - - reinterpret_cast< uint8_t* >(s_Data.QuadVertexBufferBase)); + auto dataSize = ComputeDataSize(s_Data.QuadVertexBufferBase, s_Data.QuadVertexBufferPtr); s_Data.QuadVertexBuffer->SetData(s_Data.QuadVertexBufferBase, dataSize); Flush(PrimitiveType::QUAD); } else { - auto dataSize = - static_cast< uint32_t >(reinterpret_cast< uint8_t* >(s_LineData.LineVertexBufferPtr) - - reinterpret_cast< uint8_t* >(s_LineData.LineVertexBufferBase)); + auto dataSize = ComputeDataSize(s_LineData.LineVertexBufferBase, s_LineData.LineVertexBufferPtr); s_LineData.LineVertexBuffer->SetData(s_LineData.LineVertexBufferBase, dataSize); Flush(PrimitiveType::LINE); } @@ -202,16 +210,18 @@ Renderer::Flush(PrimitiveType type) { if (type == PrimitiveType::QUAD) { - if (s_Data.QuadIndexCount == 0) + if (s_Data.QuadIndexCount == 0){ return; // Nothing to draw + } s_Data.QuadVertexArray->Bind(); s_Data.QuadVertexBuffer->Bind(); s_Data.TextureShader->UseProgram(); // Bind textures - for (uint32_t i = 0; i < s_Data.TextureSlotIndex; i++) - s_Data.TextureSlots[i]->Use(i); + for (uint32_t i = 0; i < s_Data.TextureSlotIndex; i++){ + s_Data.TextureSlots.at(i)->Use(i); + } RenderCommand::DrawIndexed(s_Data.QuadVertexArray, s_Data.QuadIndexCount); } @@ -250,7 +260,8 @@ Renderer::DrawQuad(const glm::vec2& position, const glm::vec2& size, float radia const glm::vec4& tintColor) { constexpr size_t quadVertexCount = 4; - constexpr glm::vec2 textureCoords[] = {{1.0f, 1.0f}, {0.0f, 1.0f}, {0.0f, 0.0f}, {1.0f, 0.0f}}; + const std::array< glm::vec2, 4 > textureCoords = {glm::vec2{1.0f, 1.0f}, glm::vec2{0.0f, 1.0f}, + glm::vec2{0.0f, 0.0f}, glm::vec2{1.0f, 0.0f}}; if (s_Data.QuadIndexCount >= RendererData::MaxIndices) { @@ -260,7 +271,7 @@ Renderer::DrawQuad(const glm::vec2& position, const glm::vec2& size, float radia float textureIndex = 0.0f; for (uint32_t i = 1; i < s_Data.TextureSlotIndex; i++) { - if (*s_Data.TextureSlots[i] == *texture) + if (*s_Data.TextureSlots.at(i) == *texture) { textureIndex = static_cast< float >(i); break; @@ -279,9 +290,9 @@ Renderer::DrawQuad(const glm::vec2& position, const glm::vec2& size, float radia s_Data.TextureSlotIndex++; } - constexpr auto positions = std::to_array({ - glm::vec4(0.5f, 0.5f, 0.0f, 1.0f), glm::vec4(-0.5f, 0.5f, 0.0f, 1.0f), - glm::vec4(-0.5f, -0.5f, 0.0f, 1.0f), glm::vec4(0.5f, -0.5f, 0.0f, 1.0f)}); + constexpr auto positions = + std::to_array({glm::vec4(0.5f, 0.5f, 0.0f, 1.0f), glm::vec4(-0.5f, 0.5f, 0.0f, 1.0f), + glm::vec4(-0.5f, -0.5f, 0.0f, 1.0f), glm::vec4(0.5f, -0.5f, 0.0f, 1.0f)}); glm::mat4 transformMat = glm::translate(glm::mat4(1.0f), glm::vec3(position, 0.0f)) * glm::rotate(glm::mat4(1.0f), radiansRotation, {0.0f, 0.0f, 1.0f}) @@ -289,9 +300,9 @@ Renderer::DrawQuad(const glm::vec2& position, const glm::vec2& size, float radia for (size_t i = 0; i < quadVertexCount; i++) { - s_Data.QuadVertexBufferPtr->Position = transformMat * positions[i]; + s_Data.QuadVertexBufferPtr->Position = transformMat * positions.at(i); s_Data.QuadVertexBufferPtr->Color = tintColor; - s_Data.QuadVertexBufferPtr->TexCoord = textureCoords[i]; + s_Data.QuadVertexBufferPtr->TexCoord = textureCoords.at(i); s_Data.QuadVertexBufferPtr->TexIndex = textureIndex; s_Data.QuadVertexBufferPtr->TilingFactor = tilingFactor; s_Data.QuadVertexBufferPtr++; @@ -306,7 +317,7 @@ Renderer::DrawLine(const glm::vec2& startPosition, const glm::vec2& endPosition, { constexpr size_t LineVertexCount = 2; - if (s_LineData.NumLines == s_LineData.MaxLines) + if (s_LineData.NumLines == dgame::LineRendererData::MaxLines) { FlushAndReset(PrimitiveType::LINE); } diff --git a/engine/Render/RendererAPI.hpp b/engine/Render/RendererAPI.hpp index 6f7d044f..8b2f8556 100644 --- a/engine/Render/RendererAPI.hpp +++ b/engine/Render/RendererAPI.hpp @@ -6,6 +6,7 @@ namespace dgame { +// NOLINTNEXTLINE class RendererAPI { public: @@ -15,7 +16,6 @@ class RendererAPI OpenGL = 1 }; - public: virtual ~RendererAPI() = default; virtual void @@ -41,9 +41,11 @@ class RendererAPI Create(); protected: + // NOLINTNEXTLINE static inline bool s_initalized = false; private: + // NOLINTNEXTLINE static inline API s_API = RendererAPI::API::OpenGL; }; diff --git a/engine/Render/Shader.cpp b/engine/Render/Shader.cpp index 3d48fee6..90e58d0d 100644 --- a/engine/Render/Shader.cpp +++ b/engine/Render/Shader.cpp @@ -30,7 +30,7 @@ Shader::GetProgram() const void Shader::UseProgram() const { - m_logger.Log(Logger::TYPE::TRACE, "Binding Shader program {}", m_programID); + m_logger.Log(Logger::Type::TRACE, "Binding Shader program {}", m_programID); glUseProgram(m_programID); } @@ -41,7 +41,7 @@ Shader::LoadDefault() } std::string -Shader::ReadShaderFile(std::string fileName) +Shader::ReadShaderFile(const std::string& fileName) { return FileManager::ReadFile((SHADERS_DIR / fileName).string()); } @@ -56,11 +56,11 @@ Shader::LoadShaders(const std::string& shaderName) std::string tmp = ReadShaderFile(shaderName + "_vs.glsl"); const GLchar* shaderSource = tmp.c_str(); - glShaderSource(vertexShaderID, 1, &shaderSource, NULL); + glShaderSource(vertexShaderID, 1, &shaderSource, nullptr); tmp = ReadShaderFile(shaderName + "_fs.glsl"); shaderSource = tmp.c_str(); - glShaderSource(fragmentShaderID, 1, &shaderSource, NULL); + glShaderSource(fragmentShaderID, 1, &shaderSource, nullptr); glCompileShader(vertexShaderID); CheckCompileStatus(vertexShaderID); @@ -78,11 +78,11 @@ Shader::LoadShaders(const std::string& shaderName) glDeleteShader(vertexShaderID); glDeleteShader(fragmentShaderID); - m_logger.Log(Logger::TYPE::DEBUG, "Loaded shader {} bound to ID = {}", shaderName, m_programID); + m_logger.Log(Logger::Type::DEBUG, "Loaded shader {} bound to ID = {}", shaderName, m_programID); } void -Shader::CheckCompileStatus(GLuint shaderID) +Shader::CheckCompileStatus(GLuint shaderID) const { GLint isCompleted = 0; glGetShaderiv(shaderID, GL_COMPILE_STATUS, &isCompleted); @@ -92,14 +92,14 @@ Shader::CheckCompileStatus(GLuint shaderID) glGetShaderiv(shaderID, GL_INFO_LOG_LENGTH, &maxLength); std::string log(static_cast< std::string::size_type >(maxLength), '\0'); - glGetShaderInfoLog(shaderID, maxLength, &maxLength, &log[0]); + glGetShaderInfoLog(shaderID, maxLength, &maxLength, log.data()); - m_logger.Log(Logger::TYPE::FATAL, log); + m_logger.Log(Logger::Type::FATAL, log); } } void -Shader::CheckLinkStatus(GLuint programID) +Shader::CheckLinkStatus(GLuint programID) const { GLint isLinked = 0; glGetProgramiv(programID, GL_LINK_STATUS, &isLinked); @@ -109,9 +109,9 @@ Shader::CheckLinkStatus(GLuint programID) glGetProgramiv(programID, GL_INFO_LOG_LENGTH, &maxLength); std::string log(static_cast< std::string::size_type >(maxLength), '\0'); - glGetProgramInfoLog(programID, maxLength, &maxLength, &log[0]); + glGetProgramInfoLog(programID, maxLength, &maxLength, log.data()); - m_logger.Log(Logger::TYPE::FATAL, log); + m_logger.Log(Logger::Type::FATAL, log); } } @@ -121,7 +121,7 @@ Shader::GetUniformLocation(const std::string& uniformName) GLint location = glGetUniformLocation(m_programID, uniformName.c_str()); if (!location) { - m_logger.Log(Logger::TYPE::WARNING, "Uniform location not found. Uniform name: {}", + m_logger.Log(Logger::Type::WARNING, "Uniform location not found. Uniform name: {}", uniformName); } @@ -129,14 +129,14 @@ Shader::GetUniformLocation(const std::string& uniformName) } void -Shader::SetUniformBool(bool value, const std::string& name) +Shader::SetUniformBool(bool value, const std::string& name) const { GLint location = glGetUniformLocation(m_programID, name.c_str()); glUniform1i(location, value); } void -Shader::SetUniformFloat(float value, const std::string& name) +Shader::SetUniformFloat(float value, const std::string& name) const { GLint location = glGetUniformLocation(m_programID, name.c_str()); glUniform1f(location, value); @@ -153,21 +153,21 @@ Shader::SetUniformFloatVec2(const glm::vec2& value, const std::string& name) } void -Shader::SetUniformFloatVec4(const glm::vec4& value, const std::string& name) +Shader::SetUniformFloatVec4(const glm::vec4& value, const std::string& name) const { GLint location = glGetUniformLocation(m_programID, name.c_str()); glUniform4fv(location, 1, glm::value_ptr(value)); } void -Shader::SetUniformFloatMat4(const glm::mat4& value, const std::string& name) +Shader::SetUniformFloatMat4(const glm::mat4& value, const std::string& name) const { GLint location = glGetUniformLocation(m_programID, name.c_str()); glUniformMatrix4fv(location, 1, GL_FALSE, glm::value_ptr(value)); } void -Shader::SetUniformIntArray(const int* value, int count, const std::string& name) +Shader::SetUniformIntArray(const int* value, int count, const std::string& name) const { GLint location = glGetUniformLocation(m_programID, name.c_str()); glUniform1iv(location, count, value); diff --git a/engine/Render/Shader.hpp b/engine/Render/Shader.hpp index 9026b828..ad9aa4ea 100644 --- a/engine/Render/Shader.hpp +++ b/engine/Render/Shader.hpp @@ -8,17 +8,18 @@ namespace dgame { +// NOLINTNEXTLINE class Shader { public: - Shader(const std::string& shaderName); + explicit Shader(const std::string& shaderName); Shader() = default; ~Shader(); - std::string + [[nodiscard]] std::string GetName() const; - GLuint + [[nodiscard]] GLuint GetProgram() const; void @@ -31,38 +32,38 @@ class Shader LoadShaders(const std::string& shaderName); void - SetUniformBool(bool value, const std::string& name); + SetUniformBool(bool value, const std::string& name) const; void - SetUniformFloat(float value, const std::string& name); + SetUniformFloat(float value, const std::string& name) const; void SetUniformFloatVec2(const glm::vec2& value, const std::string& name); void - SetUniformFloatVec4(const glm::vec4& value, const std::string& name); + SetUniformFloatVec4(const glm::vec4& value, const std::string& name) const; void - SetUniformFloatMat4(const glm::mat4& value, const std::string& name); + SetUniformFloatMat4(const glm::mat4& value, const std::string& name) const; void - SetUniformIntArray(const int* value, int count, const std::string& name); + SetUniformIntArray(const int* value, int count, const std::string& name) const; private: std::string - ReadShaderFile(std::string fileName); + ReadShaderFile(const std::string& fileName); void - CheckCompileStatus(GLuint shaderID); + CheckCompileStatus(GLuint shaderID) const; void - CheckLinkStatus(GLuint programID); + CheckLinkStatus(GLuint programID) const; GLint GetUniformLocation(const std::string& uniformName); - std::string m_name; - GLuint m_programID; + std::string m_name = {}; + GLuint m_programID = {}; Logger m_logger = Logger("Shader"); }; diff --git a/engine/Render/ShaderLibrary.cpp b/engine/Render/ShaderLibrary.cpp index 84266ad2..a66a3bd9 100644 --- a/engine/Render/ShaderLibrary.cpp +++ b/engine/Render/ShaderLibrary.cpp @@ -7,7 +7,7 @@ ShaderLibrary::GetShader(const std::string& shaderName) { if (s_loadedShaders.find(shaderName) == s_loadedShaders.end()) { - s_logger.Log(Logger::TYPE::INFO, "Shader: {} not found in library. Loading it", shaderName); + s_logger.Log(Logger::Type::INFO, "Shader: {} not found in library. Loading it", shaderName); LoadShader(shaderName); } diff --git a/engine/Render/ShaderLibrary.hpp b/engine/Render/ShaderLibrary.hpp index ef3ddedc..9719c617 100644 --- a/engine/Render/ShaderLibrary.hpp +++ b/engine/Render/ShaderLibrary.hpp @@ -13,8 +13,6 @@ namespace dgame { class ShaderLibrary { public: - ShaderLibrary() = default; - ~ShaderLibrary() = default; static std::shared_ptr< Shader > GetShader(const std::string& shaderName); @@ -26,9 +24,10 @@ class ShaderLibrary static void LoadShader(const std::string& shaderName); - private: + // NOLINTBEGIN static inline std::unordered_map< std::string, std::shared_ptr< Shader > > s_loadedShaders = {}; static inline Logger s_logger = Logger("ShaderLibrary"); + // NOLINTEND }; } // namespace dgame \ No newline at end of file diff --git a/engine/Render/Sprite.cpp b/engine/Render/Sprite.cpp index b1f66f76..32a6c207 100644 --- a/engine/Render/Sprite.cpp +++ b/engine/Render/Sprite.cpp @@ -27,8 +27,7 @@ Sprite::SetSpriteTextured(const glm::vec2& position, const glm::ivec2& size, const std::string& fileName) { m_texture = TextureLibrary::GetTexture(fileName); - auto returnPtr = reinterpret_cast< byte_vec4* >( - m_texture->GetData()); // m_texture->LoadTextureFromFile(fileName); + auto* returnPtr = m_texture->GetData(); // m_texture->LoadTextureFromFile(fileName); /*glGenVertexArrays(1, &m_vertexArrayBuffer); glGenBuffers(1, &m_vertexBuffer); @@ -57,7 +56,8 @@ Sprite::SetSpriteTextured(const glm::vec2& position, const glm::ivec2& size, glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0); glBindVertexArray(0);*/ - return returnPtr; + // NOLINTNEXTLINE + return reinterpret_cast(returnPtr); } void diff --git a/engine/Render/Sprite.hpp b/engine/Render/Sprite.hpp index 9c3f3d4c..4c931f42 100644 --- a/engine/Render/Sprite.hpp +++ b/engine/Render/Sprite.hpp @@ -22,11 +22,6 @@ class Sprite RADIANS }; - public: - Sprite() = default; - ~Sprite() = default; - Sprite(Sprite&&) = default; - // Create sprite without texture void SetSprite(const glm::vec2& position = glm::vec2(0.0f, 0.0f), @@ -54,24 +49,24 @@ class Sprite void SetInitialPosition(const glm::vec2& globalPosition); - glm::vec2 + [[nodiscard]] glm::vec2 GetPosition() const; - glm::ivec2 + [[nodiscard]] glm::ivec2 GetSize() const; void SetSize(glm::vec2); - glm::vec2 + [[nodiscard]] glm::vec2 GetOriginalSize() const; - std::string + [[nodiscard]] std::string GetTextureName() const; - glm::vec2 + [[nodiscard]] glm::vec2 GetTranslation() const; - float + [[nodiscard]] float GetRotation(RotationType type = RotationType::RADIANS) const; glm::vec2& @@ -98,11 +93,11 @@ class Sprite ScaleCumulative(const glm::vec2& scaleValue); void - ScaleUniformly(const float scaleValue); + ScaleUniformly(float scaleValue); // 0, 1, 2, 3 // topRight, topLeft, bottomLeft, bottomRight - std::array< glm::vec2, 4 > + [[nodiscard]] std::array< glm::vec2, 4 > GetTransformedRectangle() const; void @@ -114,10 +109,9 @@ class Sprite void Render(); - public: - static inline const std::pair< float, float > s_ROTATIONRANGE = {glm::radians(-360.0f), - glm::radians(360.0f)}; - static inline const std::pair< float, float > s_SCALERANGE = {1.0f, 5.0f}; + static constexpr std::pair< float, float > s_ROTATIONRANGE = {glm::radians(-360.0f), + glm::radians(360.0f)}; + static constexpr std::pair< float, float > s_SCALERANGE = {1.0f, 5.0f}; private: struct State diff --git a/engine/Render/Texture.cpp b/engine/Render/Texture.cpp index 62e19f85..8edfab1a 100644 --- a/engine/Render/Texture.cpp +++ b/engine/Render/Texture.cpp @@ -28,6 +28,7 @@ Texture::CreateColorTexture(const glm::ivec2& size, const glm::vec3& /*color*/) const auto sizeArray = static_cast< size_t >(m_width * m_height) * sizeof(byte_vec4); + // NOLINTNEXTLINE m_data = std::make_unique< uint8_t[] >(sizeArray); std::memset(m_data.get(), 0xFF, sizeArray); @@ -61,18 +62,18 @@ Texture::LoadTextureFromMemory(const glm::ivec2& size, uint8_t* /*data*/, const glTexImage2D(GL_TEXTURE_2D, 0, format, size.x, size.y, 0, format, GL_UNSIGNED_BYTE, m_data.get()); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapModeS); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapModeT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, static_cast(wrapModeS)); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, static_cast(wrapModeT)); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, static_cast(magFilter)); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, static_cast(minFilter)); glGenerateMipmap(GL_TEXTURE_2D); - m_logger.Log(Logger::TYPE::DEBUG, "Created new texture {} and bound it to ID {}", m_name, + m_logger.Log(Logger::Type::DEBUG, "Created new texture {} and bound it to ID {}", m_name, m_textureID); } void -Texture::Use(GLuint slot) +Texture::Use(GLuint slot) const { glBindTextureUnit(slot, m_textureID); } @@ -98,6 +99,7 @@ Texture::Create() byte_vec4* Texture::GetVec4Data() const { + // NOLINTNEXTLINE return reinterpret_cast< byte_vec4* >(GetData()); } diff --git a/engine/Render/Texture.hpp b/engine/Render/Texture.hpp index b1e52cdc..a56b055d 100644 --- a/engine/Render/Texture.hpp +++ b/engine/Render/Texture.hpp @@ -10,11 +10,12 @@ namespace dgame { +// NOLINTNEXTLINE class Texture { public: Texture(); - Texture(const std::string& textureName); + explicit Texture(const std::string& textureName); ~Texture(); // Create new texture which is filled with 'color' @@ -25,27 +26,27 @@ class Texture LoadTextureFromFile(const std::string& fileName = "Default128.png", GLenum wrapMode = GL_REPEAT, GLenum filter = GL_LINEAR); - byte_vec4* + [[nodiscard]] byte_vec4* GetVec4Data() const; - uint8_t* + [[nodiscard]] uint8_t* GetData() const; - std::string + [[nodiscard]] std::string GetName() const; - int32_t + [[nodiscard]] int32_t GetWidth() const; - int32_t + [[nodiscard]] int32_t GetHeight() const; - GLuint + [[nodiscard]] GLuint GetTextureHandle() const; // Make this texture active for given texture slot void - Use(GLuint slot); + Use(GLuint slot) const; GLuint Create(); @@ -60,7 +61,6 @@ class Texture GLenum wrapModeS = GL_CLAMP_TO_EDGE, GLenum wrapModeT = GL_CLAMP_TO_EDGE, GLenum magFilter = GL_NEAREST, GLenum minFilter = GL_LINEAR); - private: FileManager::ImageHandleType m_data; // width and size of texture diff --git a/engine/Render/TextureLibrary.cpp b/engine/Render/TextureLibrary.cpp index ce3f2fa1..6932ce3c 100644 --- a/engine/Render/TextureLibrary.cpp +++ b/engine/Render/TextureLibrary.cpp @@ -7,9 +7,12 @@ TextureLibrary::GetTexture(const std::string& textureName) { if (s_loadedTextures.find(textureName) == s_loadedTextures.end()) { - s_logger.Log(Logger::TYPE::INFO, "Texture: {} not found in library. Loading it", textureName); + s_logger.Log(Logger::Type::INFO, "Texture: {} not found in library. Loading it", textureName); LoadTexture(textureName); } + else { + s_logger.Log(Logger::Type::INFO, "Texture: {} found in library!", textureName); + } return s_loadedTextures[textureName]; } diff --git a/engine/Render/TextureLibrary.hpp b/engine/Render/TextureLibrary.hpp index d2c19f4c..3294a1e7 100644 --- a/engine/Render/TextureLibrary.hpp +++ b/engine/Render/TextureLibrary.hpp @@ -13,8 +13,6 @@ namespace dgame { class TextureLibrary { public: - TextureLibrary() = default; - ~TextureLibrary() = default; static std::shared_ptr< Texture > GetTexture(const std::string& textureName); @@ -26,10 +24,11 @@ class TextureLibrary static void LoadTexture(const std::string& textureName); - private: + // NOLINTBEGIN static inline std::unordered_map< std::string, std::shared_ptr< Texture > > s_loadedTextures = {}; static inline Logger s_logger = Logger("TextureLibrary"); + // NOLINTEND }; } // namespace dgame \ No newline at end of file diff --git a/engine/Render/VertexArray.cpp b/engine/Render/VertexArray.cpp index b05337de..4687f530 100644 --- a/engine/Render/VertexArray.cpp +++ b/engine/Render/VertexArray.cpp @@ -10,23 +10,15 @@ ShaderDataTypeToOpenGLBaseType(ShaderDataType type) switch (type) { case ShaderDataType::Float: - return GL_FLOAT; case ShaderDataType::Float2: - return GL_FLOAT; case ShaderDataType::Float3: - return GL_FLOAT; case ShaderDataType::Float4: - return GL_FLOAT; case ShaderDataType::Mat3: - return GL_FLOAT; case ShaderDataType::Mat4: return GL_FLOAT; case ShaderDataType::Int: - return GL_INT; case ShaderDataType::Int2: - return GL_INT; case ShaderDataType::Int3: - return GL_INT; case ShaderDataType::Int4: return GL_INT; case ShaderDataType::Bool: @@ -79,10 +71,10 @@ VertexArray::AddVertexBuffer(const std::shared_ptr< VertexBuffer >& vertexBuffer case ShaderDataType::Int4: case ShaderDataType::Bool: { glEnableVertexAttribArray(m_VertexBufferIndex); - glVertexAttribPointer(m_VertexBufferIndex, element.GetComponentCount(), + glVertexAttribPointer(m_VertexBufferIndex, static_cast(element.GetComponentCount()), ShaderDataTypeToOpenGLBaseType(element.Type), - element.Normalized ? GL_TRUE : GL_FALSE, layout.GetStride(), - reinterpret_cast< const void* >(element.Offset)); + element.Normalized ? GL_TRUE : GL_FALSE, static_cast(layout.GetStride()), + reinterpret_cast< const void* >(element.Offset)); //NOLINT m_VertexBufferIndex++; break; } @@ -92,10 +84,10 @@ VertexArray::AddVertexBuffer(const std::shared_ptr< VertexBuffer >& vertexBuffer for (uint32_t i = 0; i < count; i++) { glEnableVertexAttribArray(m_VertexBufferIndex); - glVertexAttribPointer(m_VertexBufferIndex, count, + glVertexAttribPointer(m_VertexBufferIndex, static_cast(count), ShaderDataTypeToOpenGLBaseType(element.Type), - element.Normalized ? GL_TRUE : GL_FALSE, layout.GetStride(), - reinterpret_cast< const void* >(sizeof(float) * count * i)); + element.Normalized ? GL_TRUE : GL_FALSE, static_cast(layout.GetStride()), + reinterpret_cast< const void* >(sizeof(float) * count * i)); //NOLINT glVertexAttribDivisor(m_VertexBufferIndex, 1); m_VertexBufferIndex++; } diff --git a/engine/Render/VertexArray.hpp b/engine/Render/VertexArray.hpp index 6a8a8632..44807313 100644 --- a/engine/Render/VertexArray.hpp +++ b/engine/Render/VertexArray.hpp @@ -7,6 +7,7 @@ namespace dgame { +// NOLINTNEXTLINE class VertexArray { public: @@ -23,22 +24,22 @@ class VertexArray void SetIndexBuffer(const std::shared_ptr< IndexBuffer >& indexBuffer); - const std::vector< std::shared_ptr< VertexBuffer > >& + [[nodiscard]] const std::vector< std::shared_ptr< VertexBuffer > >& GetVertexBuffers() const { return m_VertexBuffers; } - const std::shared_ptr< IndexBuffer >& + [[nodiscard]] const std::shared_ptr< IndexBuffer >& GetIndexBuffer() const { return m_IndexBuffer; } private: - uint32_t m_RendererID; - uint32_t m_VertexBufferIndex = 0; - std::vector< std::shared_ptr< VertexBuffer > > m_VertexBuffers; - std::shared_ptr< IndexBuffer > m_IndexBuffer; + uint32_t m_RendererID = {}; + uint32_t m_VertexBufferIndex = {}; + std::vector< std::shared_ptr< VertexBuffer > > m_VertexBuffers = {}; + std::shared_ptr< IndexBuffer > m_IndexBuffer = {}; }; } // namespace dgame diff --git a/engine/Render/VertexBuffer.cpp b/engine/Render/VertexBuffer.cpp index 1bd5e0b4..0c481016 100644 --- a/engine/Render/VertexBuffer.cpp +++ b/engine/Render/VertexBuffer.cpp @@ -40,7 +40,7 @@ VertexBuffer::Unbind() const } void -VertexBuffer::SetData(const void* data, uint32_t size) +VertexBuffer::SetData(const void* data, uint32_t size) const { glBindBuffer(GL_ARRAY_BUFFER, m_RendererID); glBufferSubData(GL_ARRAY_BUFFER, 0, size, data); @@ -57,7 +57,7 @@ IndexBuffer::IndexBuffer(uint32_t* indices, uint32_t count) : m_Count(count) // GL_ELEMENT_ARRAY_BUFFER is not valid without an actively bound VAO // Binding with GL_ARRAY_BUFFER allows the data to be loaded regardless of VAO state. glBindBuffer(GL_ARRAY_BUFFER, m_RendererID); - glBufferData(GL_ARRAY_BUFFER, count * sizeof(uint32_t), indices, GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, static_cast(count * sizeof(uint32_t)), indices, GL_STATIC_DRAW); } IndexBuffer::~IndexBuffer() diff --git a/engine/Render/VertexBuffer.hpp b/engine/Render/VertexBuffer.hpp index b4e38375..c4e50cfa 100644 --- a/engine/Render/VertexBuffer.hpp +++ b/engine/Render/VertexBuffer.hpp @@ -54,46 +54,39 @@ ShaderDataTypeSize(ShaderDataType type) struct BufferElement { - std::string Name; - ShaderDataType Type; - uint32_t Size; - size_t Offset; - bool Normalized; + std::string Name = {}; + ShaderDataType Type = {}; + uint32_t Size = {}; + size_t Offset = {}; + bool Normalized = {}; BufferElement() = default; - BufferElement(ShaderDataType type, const std::string& name, bool normalized = false) - : Name(name), Type(type), Size(ShaderDataTypeSize(type)), Offset(0), Normalized(normalized) + BufferElement(ShaderDataType type, std::string name, bool normalized = false) + : Name(std::move(name)), Type(type), Size(ShaderDataTypeSize(type)), Normalized(normalized) { } - uint32_t + [[nodiscard]] uint32_t GetComponentCount() const { switch (Type) { case ShaderDataType::Float: + case ShaderDataType::Int: + case ShaderDataType::Bool: return 1; case ShaderDataType::Float2: + case ShaderDataType::Int2: return 2; case ShaderDataType::Float3: - return 3; - case ShaderDataType::Float4: - return 4; case ShaderDataType::Mat3: - return 3; // 3* float3 - case ShaderDataType::Mat4: - return 4; // 4* float4 - case ShaderDataType::Int: - return 1; - case ShaderDataType::Int2: - return 2; case ShaderDataType::Int3: return 3; + case ShaderDataType::Float4: + case ShaderDataType::Mat4: case ShaderDataType::Int4: return 4; - case ShaderDataType::Bool: - return 1; } return 0; @@ -103,21 +96,20 @@ struct BufferElement class BufferLayout { public: - BufferLayout() - { - } + BufferLayout() = default; - BufferLayout(const std::initializer_list< BufferElement >& elements) : m_Elements(elements) + BufferLayout(const std::initializer_list< BufferElement >& elements) + : m_Elements(elements) { CalculateOffsetsAndStride(); } - uint32_t + [[nodiscard]] uint32_t GetStride() const { return m_Stride; } - const std::vector< BufferElement >& + [[nodiscard]] const std::vector< BufferElement >& GetElements() const { return m_Elements; @@ -128,17 +120,20 @@ class BufferLayout { return m_Elements.begin(); } + std::vector< BufferElement >::iterator end() { return m_Elements.end(); } - std::vector< BufferElement >::const_iterator + + [[nodiscard]] std::vector< BufferElement >::const_iterator begin() const { return m_Elements.begin(); } - std::vector< BufferElement >::const_iterator + + [[nodiscard]] std::vector< BufferElement >::const_iterator end() const { return m_Elements.end(); @@ -158,15 +153,15 @@ class BufferLayout } } - private: - std::vector< BufferElement > m_Elements; + std::vector< BufferElement > m_Elements = {}; uint32_t m_Stride = 0; }; +// NOLINTNEXTLINE class VertexBuffer { public: - VertexBuffer(uint32_t size); + explicit VertexBuffer(uint32_t size); VertexBuffer(float* vertices, uint32_t size); ~VertexBuffer(); @@ -176,9 +171,9 @@ class VertexBuffer Unbind() const; void - SetData(const void* data, uint32_t size); + SetData(const void* data, uint32_t size) const; - const BufferLayout& + [[nodiscard]] const BufferLayout& GetLayout() const { return m_Layout; @@ -190,10 +185,11 @@ class VertexBuffer } private: - uint32_t m_RendererID; - BufferLayout m_Layout; + uint32_t m_RendererID = {}; + BufferLayout m_Layout = {}; }; +// NOLINTNEXTLINE class IndexBuffer { public: @@ -205,15 +201,15 @@ class IndexBuffer void Unbind() const; - uint32_t + [[nodiscard]] uint32_t GetCount() const { return m_Count; } private: - uint32_t m_RendererID; - uint32_t m_Count; + uint32_t m_RendererID = {}; + uint32_t m_Count = {}; }; } // namespace dgame \ No newline at end of file diff --git a/engine/Time/Timer.cpp b/engine/Time/Timer.cpp index 3b1bec90..426a6caa 100644 --- a/engine/Time/Timer.cpp +++ b/engine/Time/Timer.cpp @@ -7,10 +7,10 @@ namespace dgame { Timer::Timer() + : m_deltaTime(milliseconds(0)), + m_totalTime(milliseconds(0)), + m_timeStamp(std::chrono::steady_clock::now()) { - m_deltaTime = milliseconds(0); - m_timeStamp = std::chrono::steady_clock::now(); - m_totalTime = milliseconds(0); } void diff --git a/engine/Time/Timer.hpp b/engine/Time/Timer.hpp index 1811833a..82e416d3 100644 --- a/engine/Time/Timer.hpp +++ b/engine/Time/Timer.hpp @@ -12,7 +12,6 @@ class Timer using seconds = std::chrono::seconds; Timer(); - ~Timer() = default; static void PauseAllTimers(); @@ -32,14 +31,14 @@ class Timer // Get time elapsed between calling ToggleTimer() functions // Returned value is in miliseconds (float value) - float + [[nodiscard]] float GetFloatDeltaTime() const; - milliseconds + [[nodiscard]] milliseconds GetMsDeltaTime() const; // Returned value in seconds - float + [[nodiscard]] float GetTotalTime() const; void @@ -61,6 +60,7 @@ class Timer // each Toggle() function call std::chrono::steady_clock::time_point m_timeStamp; + // NOLINTNEXTLINE static inline bool m_timersPaused = false; }; diff --git a/engine/Window/Window.cpp b/engine/Window/Window.cpp index 0c653de3..740c821d 100644 --- a/engine/Window/Window.cpp +++ b/engine/Window/Window.cpp @@ -15,12 +15,14 @@ Window::Window(int32_t width, int32_t height, const std::string& title) { m_logger.Init("Window"); - glfwSetErrorCallback( - [](int, const char* description) { fprintf(stderr, "Error: %s\n", description); }); + glfwSetErrorCallback([](int, const char* description) { + // Cast to void to avoid clang-tidy complaint + static_cast(fprintf(stderr, "Error: %s\n", description)); + }); if (GLFW_TRUE != glfwInit()) { - m_logger.Log(Logger::TYPE::FATAL, "GLFW_TRUE != glfwInit()"); + m_logger.Log(Logger::Type::FATAL, "GLFW_TRUE != glfwInit()"); } glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); @@ -30,18 +32,13 @@ Window::Window(int32_t width, int32_t height, const std::string& title) glfwWindowHint(GLFW_RESIZABLE, GL_FALSE); m_pWindow = glfwCreateWindow(m_width, m_height, title.c_str(), nullptr, nullptr); - m_logger.Log(Logger::TYPE::DEBUG, "GLFW Window created - \n" + std::string(*this)); + m_logger.Log(Logger::Type::DEBUG, "GLFW Window created - \n" + std::string(*this)); glfwMakeContextCurrent(m_pWindow); glfwSwapInterval(1); } -Window::~Window() -{ - // glfwTerminate(); -} - void Window::ShutDown() { @@ -57,7 +54,7 @@ Window::SetIcon(const std::string& file) image.height = 16; image.pixels = TextureLibrary::GetTexture(file)->GetData(); - auto cursor = glfwCreateCursor(&image, 0, 0); + auto* cursor = glfwCreateCursor(&image, 0, 0); glfwSetCursor(m_pWindow, cursor); } diff --git a/engine/Window/Window.hpp b/engine/Window/Window.hpp index 44b532df..e67aa0d1 100644 --- a/engine/Window/Window.hpp +++ b/engine/Window/Window.hpp @@ -11,19 +11,19 @@ struct GLFWwindow; namespace dgame { +// NOLINTNEXTLINE class Window { public: Window(int32_t width, int32_t height, const std::string& title); - ~Window(); void ShutDown(); - glm::ivec2 + [[nodiscard]] glm::ivec2 GetSize() const { - return glm::ivec2(m_width, m_height); + return {m_width, m_height}; } void @@ -33,7 +33,7 @@ class Window } // return true if the window is active - bool + [[nodiscard]] bool IsRunning() const { return m_isRunning; @@ -76,7 +76,7 @@ class Window return m_pWindow; } - operator std::string() const + explicit operator std::string() const { std::stringstream returnStr; returnStr << "Window title - " << m_title << "\nWindow dimensions - " << m_width << "x" @@ -86,7 +86,7 @@ class Window } friend std::ostream& - operator<<(std::ostream& os, Window window) + operator<<(std::ostream& os, const Window& window) { os << "Window title - " << window.m_title << "\n Window dimensions - " << window.m_width << "x" << window.m_height; @@ -95,19 +95,20 @@ class Window } private: - int32_t m_width; - int32_t m_height; + int32_t m_width = {}; + int32_t m_height = {}; GLFWwindow* m_pWindow = nullptr; - std::string m_title; + std::string m_title = {}; // cursor position // glm::vec2 m_cursorPos; // is windows active - bool m_isRunning; + bool m_isRunning = {}; - Logger m_logger; + Logger m_logger = {}; + // NOLINTNEXTLINE static inline bool s_glfwInitalized = false; };