From aff4d9939c1ead47ce80423b1f210de58d508d2e Mon Sep 17 00:00:00 2001 From: Joeyrp Date: Wed, 27 Oct 2021 19:46:23 -0400 Subject: [PATCH] Added Box2D to the project (not tested) --- .gitmodules | 3 ++ CMakeLists.txt | 21 +++++++--- docs/{Tasks.todo => core.todo} | 72 ++-------------------------------- docs/editor.todo | 35 +++++++++++++++++ docs/game.todo | 32 +++++++++++++++ external/box2d | 1 + scripts/cmconfig.bat | 4 +- scripts/cmconfig.sh | 2 +- 8 files changed, 92 insertions(+), 78 deletions(-) rename docs/{Tasks.todo => core.todo} (65%) create mode 100644 docs/editor.todo create mode 100644 docs/game.todo create mode 160000 external/box2d diff --git a/.gitmodules b/.gitmodules index 7e74e29..65807e1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "external/freetype"] path = external/freetype url = https://gitlab.freedesktop.org/freetype/freetype.git +[submodule "external/box2d"] + path = external/box2d + url = https://github.com/erincatto/box2d diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ff08ed..6ef5c30 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,23 +63,27 @@ endif() # CHECK THAT ALL SUBMODULES EXIST if(NOT EXISTS "${PROJECT_SOURCE_DIR}/external/glfw/CMakeLists.txt") - message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.") + message(FATAL_ERROR "GLFW submodule was not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.") endif() if(NOT EXISTS "${PROJECT_SOURCE_DIR}/external/glm/CMakeLists.txt") - message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.") + message(FATAL_ERROR "GLM submodule was not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.") endif() if(NOT EXISTS "${PROJECT_SOURCE_DIR}/external/lua/CMakeLists.txt") - message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.") + message(FATAL_ERROR "LUA submodule was not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.") endif() if(NOT EXISTS "${PROJECT_SOURCE_DIR}/external/pugixml/CMakeLists.txt") - message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.") + message(FATAL_ERROR "PUGIXML submodule was not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.") endif() if(NOT EXISTS "${PROJECT_SOURCE_DIR}/external/freetype/CMakeLists.txt") - message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.") + message(FATAL_ERROR "FREETYPE submodule was not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.") +endif() + +if(NOT EXISTS "${PROJECT_SOURCE_DIR}/external/box2d/CMakeLists.txt") + message(FATAL_ERROR "BOX2D submodule was not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.") endif() # add GLFW @@ -109,6 +113,9 @@ add_subdirectory(external/pugixml) # add freetype add_subdirectory(external/freetype) +# add box2d +add_subdirectory(external/box2d) + # add run mode tester add_subdirectory(src/run_modes/tester) @@ -124,6 +131,7 @@ target_include_directories(${PROJECT_NAME} PUBLIC external/pugixml/src PUBLIC external/glad/include PUBLIC external/freetype/include + PUBLIC external/box2d/include ) target_link_directories(${PROJECT_NAME} @@ -135,9 +143,10 @@ target_link_directories(${PROJECT_NAME} PRIVATE src/run_modes/tester PRIVATE external/glad/src PRIVATE external/freetype/src + PRIVATE external/box2d/src ) -target_link_libraries(${PROJECT_NAME} glfw glad glm dearimgui utils assets lua_static pugixml freetype tester) +target_link_libraries(${PROJECT_NAME} glfw glad glm dearimgui utils assets lua_static pugixml freetype box2d tester) if(WIN32) target_link_libraries(${PROJECT_NAME} opengl32.lib) diff --git a/docs/Tasks.todo b/docs/core.todo similarity index 65% rename from docs/Tasks.todo rename to docs/core.todo index e805d84..c922fc5 100644 --- a/docs/Tasks.todo +++ b/docs/core.todo @@ -31,8 +31,8 @@ Core: ✔ Add the InputManager to the core @done (9/9/2021, 2:57:06 PM) Physics: - ☐ Research Box2D as a possibly physics library - ☐ Add Box2D to the project as an external library + ✔ Research Box2D as a possible physics library @done (10/27/2021, 7:40:44 PM) + ✔ Add Box2D to the project as an external library @done (10/27/2021, 7:40:46 PM) ☐ Add a scene to the tester to test Box2D usage Audio: @@ -48,79 +48,13 @@ Core: Utils: ✔ Make Logger fully static (no need to ever GetInstance) @done (10/26/2021, 4:43:55 PM) ✔ Need to add a static initialize method @done (10/26/2021, 4:43:57 PM) - -Game: - ☐ Implement Run Mode interface class - ☐ Load game project data - ☐ Manage list of scenes - ☐ Manage global scripts - ☐ Handle Events from the core - - Scene: - ☐ Manage scene scripts - ☐ Manage game objects in scene - - Manage list of Regions: - ☐ Track which regions should be loaded - - - Region: - ☐ List of renderable images for each layer - - Game Object: - ☐ List of components - - Components: - ☐ Transform - ☐ Image - ☐ Animation Controller - ☐ Collider (maybe via Box2D?) - ☐ Script - ☐ RigidBody (via Box2D) - - Animations: - ☐ Animated Sprite class - - -Editor: @high - ✔ Come up with project directory structure @done (9/17/2021, 6:46:44 PM) - ☐ Make the editor a separate module @high - ☐ Implement Run Mode interface class @high - ☐ Reference raw asset files in a "content" folder@high - ☐ Platform independant file browsing - ☐ Scan script files to make sure they don't overwrite globals - - Raw Asset Importers: - - Need classes to import raw resource files for the editor - ☐ Raw Resource importer interface class - ☐ Raw Image importer class - ☐ Raw Sound importer class - ☐ Raw font file importer class - - GUI Panels: - Project Overview (Tree view): - - Game Viewport: - - Scene View: - - Tile Map Editor: - ☐ Tile map canvas - ☐ Tile map pallete - ☐ Hideable grid - ☐ Stamp creater - - Asset Viewer: - - Properties: Assets: Types: - Classes that represent each resource Types ✔ Image class @done (9/16/2021, 2:46:34 PM) - ☐ Decouple Image class from OGLRenderer @high - - Give the renderer a register image method that will take an Image and finish setting it up + ✔ Decouple Image class from OGLRenderer @high @done (10/27/2021, 7:41:50 PM) ☐ Font class ☐ Sound class ☐ Script class diff --git a/docs/editor.todo b/docs/editor.todo new file mode 100644 index 0000000..67d9975 --- /dev/null +++ b/docs/editor.todo @@ -0,0 +1,35 @@ + +Editor: @high + ✔ Come up with project directory structure @done (9/17/2021, 6:46:44 PM) + ☐ Make the editor a separate module @high + ☐ Implement Run Mode interface class @high + ☐ Reference raw asset files in a "content" folder@high + ☐ Platform independant file browsing + ☐ Scan script files to make sure they don't overwrite globals + + Raw Asset Importers: + - Need classes to import raw resource files for the editor + ☐ Raw Resource importer interface class + ☐ Raw Image importer class + ☐ Raw Sound importer class + ☐ Raw font file importer class + + GUI Panels: + Project Overview (Tree view): + + Game Viewport: + + Scene View: + + Scene Hierarchy (Tree View): + + Tile Map Editor: + ☐ Tile map canvas + ☐ Tile map pallete + ☐ Hideable grid + ☐ Stamp creater + ☐ Flood Fill + + Asset Viewer: + + Properties: \ No newline at end of file diff --git a/docs/game.todo b/docs/game.todo new file mode 100644 index 0000000..787dda3 --- /dev/null +++ b/docs/game.todo @@ -0,0 +1,32 @@ + +Game: + ☐ Implement Run Mode interface class + ☐ Load game project data + ☐ Manage list of scenes + ☐ Manage global scripts + ☐ Handle Events from the core + + Scene: + ☐ Manage scene scripts + ☐ Manage game objects in scene + + Manage list of Regions: + ☐ Track which regions should be loaded + + + Region: + ☐ List of renderable images for each layer + + Game Object: + ☐ List of components + + Components: + ☐ Transform + ☐ Image + ☐ Animation Controller + ☐ Collider (maybe via Box2D?) + ☐ Script + ☐ RigidBody (via Box2D) + + Animations: + ☐ Animated Sprite clas \ No newline at end of file diff --git a/external/box2d b/external/box2d new file mode 160000 index 0000000..cd2c28d --- /dev/null +++ b/external/box2d @@ -0,0 +1 @@ +Subproject commit cd2c28dba83e4f359d08aeb7b70afd9e35e39eda diff --git a/scripts/cmconfig.bat b/scripts/cmconfig.bat index 751f3bc..f61d918 100644 --- a/scripts/cmconfig.bat +++ b/scripts/cmconfig.bat @@ -5,8 +5,8 @@ REM ex. scripts/cmconfig.bat IF "%~1" == "noedit" ( echo "no editor build" -cmake -Wno-dev -DNO_EDITOR=ON -DGLFW_BUILD_DOCS=OFF -B build/ -S . -G "Visual Studio 16 2019" -A x64 +cmake -Wno-dev -DNO_EDITOR=ON -DGLFW_BUILD_DOCS=OFF -DBOX2D_BUILD_TESTBED=OFF -B build/ -S . -G "Visual Studio 16 2019" -A x64 ) ELSE ( echo "WITH EDITOR" -cmake -Wno-dev -DNO_EDITOR=OFF -DGLFW_BUILD_DOCS=OFF -B build/ -S . -G "Visual Studio 16 2019" -A x64 +cmake -Wno-dev -DNO_EDITOR=OFF -DGLFW_BUILD_DOCS=OFF -DBOX2D_BUILD_TESTBED=OFF -B build/ -S . -G "Visual Studio 16 2019" -A x64 ) \ No newline at end of file diff --git a/scripts/cmconfig.sh b/scripts/cmconfig.sh index 73b86f5..32be43d 100755 --- a/scripts/cmconfig.sh +++ b/scripts/cmconfig.sh @@ -2,4 +2,4 @@ # This script expects to be run from the parent directory # ex. scripts/cmconfig.sh -cmake -DGLFW_BUILD_DOCS=OFF -S . -B build/ \ No newline at end of file +cmake -Wno-dev -DNO_EDITOR=OFF -DGLFW_BUILD_DOCS=OFF -DBOX2D_BUILD_TESTBED=OFF -S . -B build/ \ No newline at end of file