diff --git a/.gitignore b/.gitignore index 852e3c8..1e28113 100644 --- a/.gitignore +++ b/.gitignore @@ -364,3 +364,4 @@ FodyWeavers.xsd /Resources/weapons/.bubblegun.xml.swp *.swp /Resources/scenes/.debugScene.xml.swp +compile_commands.json diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ccd5db..e650643 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,11 +12,20 @@ endif() include(FetchContent) SET(CMAKE_EXPORT_COMPILE_COMMANDS 1) +#SET(SOL_LUAJIT 1) SET(TRACY_ENABLE 1) SET(TRACY_ON_DEMAND 1) SET(TRACY_ONLY_LOCALHOST 1) +SET(FT_DISABLE_BROTLI 1) +SET(FT_DISABLE_BZIP2 1) +SET(FT_DISABLE_HARFBUZZ 1) +SET(FT_DISABLE_PNG 1) +SET(FT_DISABLE_ZLIB 1) + +option(GLM_ENABLE_FAST_MATH OFF) + FetchContent_Declare( tracy GIT_REPOSITORY https://github.com/wolfpld/tracy.git @@ -25,7 +34,34 @@ FetchContent_Declare( GIT_PROGRESS TRUE ) +FetchContent_Declare( + tinyxml2 + GIT_REPOSITORY https://github.com/leethomason/tinyxml2.git + GIT_TAG 10.0.0 + GIT_SHALLOW TRUE + GIT_PROGRESS TRUE +) + +FetchContent_Declare( + sol2 + GIT_REPOSITORY https://github.com/ThePhD/sol2.git + GIT_TAG v3.3.1 + GIT_SHALLOW TRUE + GIT_PROGRESS TRUE +) + +FetchContent_Declare( + freetype + GIT_REPOSITORY https://github.com/freetype/freetype.git + GIT_TAG VER-2-13-3 + GIT_SHALLOW TRUE + GIT_PROGRESS TRUE +) + FetchContent_MakeAvailable(tracy) +FetchContent_MakeAvailable(tinyxml2) +FetchContent_MakeAvailable(sol2) +FetchContent_MakeAvailable(freetype) project ("YuppleMayham") diff --git a/Resources/scripts/ai/grunt_behaviour.lua b/Resources/scripts/ai/grunt_behaviour.lua index a63f233..d1ce686 100644 --- a/Resources/scripts/ai/grunt_behaviour.lua +++ b/Resources/scripts/ai/grunt_behaviour.lua @@ -5,7 +5,7 @@ moveLeft = true function watchPosition(actor, pos) local y = pos.y - actor.position.y local x = pos.x - actor.position.x - local rotation = math.atan(y, x) + local rotation = math.atan2(y, x) actor.rotation = math.deg(rotation) end diff --git a/YuppleMayham/CMakeLists.txt b/YuppleMayham/CMakeLists.txt index c8a16c5..d57a623 100644 --- a/YuppleMayham/CMakeLists.txt +++ b/YuppleMayham/CMakeLists.txt @@ -2,30 +2,31 @@ # project specific logic here. # -find_package(SDL2 REQUIRED) -find_package(SDL2_IMAGE REQUIRED) +find_package(SDL2 2.30.2 REQUIRED) +find_package(SDL2_IMAGE 2.8.2 REQUIRED) +#find_package(luajit CONFIG REQUIRED) + -include_directories(SYSTEM "${PROJECT_SOURCE_DIR}/YuppleMayham/include") include_directories(SYSTEM "c:/sdks/glad/include") -include_directories(SYSTEM "c:/sdks/tinyxml2-10.0.0/debug/include") +#include_directories(SYSTEM "c:/sdks/tinyxml2-10.0.0/debug/include") include_directories(SYSTEM "c:/sdks/glm") -include_directories(SYSTEM "C:/sdks/sol2-3.3.0/single/single/include") -include_directories(SYSTEM "c:/sdks/lua-5.4.6/include") -include_directories(SYSTEM "C:/sdks/freetype-2.13.2/include") -link_directories(SYSTEM "C:/sdks/freetype-2.13.2/objs") -if (CMAKE_BUILD_TYPE STREQUAL "Debug") - link_directories(SYSTEM "c:/sdks/tinyxml2-10.0.0/debug/lib") -else() - link_directories(SYSTEM "c:/sdks/tinyxml2-10.0.0/release/lib") -endif() -link_directories(SYSTEM "c:/sdks/lua-5.4.6/lib") +#include_directories(SYSTEM "C:/sdks/sol2-3.3.0/single/single/include") +#include_directories(SYSTEM "c:/sdks/lua-5.4.6/include") +#include_directories(SYSTEM "C:/sdks/freetype-2.13.2/include") +#link_directories(SYSTEM "C:/sdks/freetype-2.13.2/objs") +#if (CMAKE_BUILD_TYPE STREQUAL "Debug") +# link_directories(SYSTEM "c:/sdks/tinyxml2-10.0.0/debug/lib") +#else() +# link_directories(SYSTEM "c:/sdks/tinyxml2-10.0.0/release/lib") +#endif() +#link_directories(SYSTEM "c:/sdks/lua-5.4.6/lib") -include_directories("${PROJECT_SOURCE_DIR}/YuppleMayham/include") +#include_directories("${PROJECT_SOURCE_DIR}/YuppleMayham/include") # Add source to this project's executable. add_executable (YuppleMayham "src/main.cpp" - "c:/sdks/glad/src/glad.c" + "c:/sdks/glad/src/glad.c" "src/graphics/sprite.cpp" "src/graphics/mesh.cpp" "src/gameplay/entity.cpp" @@ -87,6 +88,12 @@ if (CMAKE_VERSION VERSION_GREATER 3.12) set_property(TARGET YuppleMayham PROPERTY CXX_STANDARD 20) endif() -target_link_libraries(YuppleMayham SDL2::SDL2main SDL2::SDL2 SDL2_image::SDL2_image tinyxml2 lua_static freetype Tracy::TracyClient) +target_include_directories(YuppleMayham PRIVATE "C:/sdks/luajit/include") +target_include_directories(YuppleMayham PRIVATE "${PROJECT_SOURCE_DIR}/YuppleMayham/include") +target_include_directories(YuppleMayham PRIVATE ${freetype_SOURCE_DIR}) +target_include_directories(YuppleMayham PRIVATE ${tinyxml2_SOURCE_DIR}) +target_include_directories(YuppleMayham PRIVATE "${sol2_SOURCE_DIR}/include") + +target_link_libraries(YuppleMayham SDL2::SDL2main SDL2::SDL2 SDL2_image::SDL2_image "C:/sdks/luajit/lib/luajit.lib" "C:/sdks/luajit/lib/lua51.lib" tinyxml2 freetype Tracy::TracyClient) # TODO: Add tests and install targets if needed. diff --git a/YuppleMayham/include/gameplay/map.h b/YuppleMayham/include/gameplay/map.h index c2797c2..88a1ba4 100644 --- a/YuppleMayham/include/gameplay/map.h +++ b/YuppleMayham/include/gameplay/map.h @@ -26,7 +26,7 @@ private: void loadMap(); void createCollisionMap(); - int getTileSetIndex(int id) const; + size_t getTileSetIndex(int id) const; std::shared_ptr mapData; std::vector> tileSetData; diff --git a/YuppleMayham/include/graphics/glwindow.h b/YuppleMayham/include/graphics/glwindow.h index fa172e8..d761f62 100644 --- a/YuppleMayham/include/graphics/glwindow.h +++ b/YuppleMayham/include/graphics/glwindow.h @@ -10,9 +10,9 @@ class GLWindow { public: GLWindow(const char* windowName, int width, int height) : - name(windowName), w(width), - h(height) {}; + h(height), + name(windowName) {}; ~GLWindow(); bool Init(); diff --git a/YuppleMayham/include/utility/resourcemanager.h b/YuppleMayham/include/utility/resourcemanager.h index 54b4cee..a0720bc 100644 --- a/YuppleMayham/include/utility/resourcemanager.h +++ b/YuppleMayham/include/utility/resourcemanager.h @@ -15,7 +15,6 @@ class Script; class AnimationSet; class AIScript; class WeaponScript; -class TileSetData; class SpriteComponent; class ResourceManager diff --git a/YuppleMayham/src/gameplay/ai.cpp b/YuppleMayham/src/gameplay/ai.cpp index 5505dee..3c36243 100644 --- a/YuppleMayham/src/gameplay/ai.cpp +++ b/YuppleMayham/src/gameplay/ai.cpp @@ -18,14 +18,11 @@ void AI::attachBehaviourScript(const std::shared_ptr& behaviour) // pay special attention each ai script has control of only their own instance of ai! this->behaviour = behaviour; this->behaviour->lua["raycaster"] = raycaster; - this->behaviour->lua["ai"] = shared_from_this(); + this->behaviour->lua["ai"] = sol::make_reference(this->behaviour->lua, shared_from_this()); - if (this->behaviour->lua["idle"].valid()) - idleFunc = this->behaviour->lua["idle"]; - if (this->behaviour->lua["patrol"].valid()) - patrolFunc = this->behaviour->lua["patrol"]; - if (this->behaviour->lua["alert"].valid()) - alertFunc = this->behaviour->lua["alert"]; + idleFunc = this->behaviour->lua["idle"]; + patrolFunc = this->behaviour->lua["patrol"]; + alertFunc = this->behaviour->lua["alert"]; } void AI::update() diff --git a/YuppleMayham/src/gameplay/map.cpp b/YuppleMayham/src/gameplay/map.cpp index fc3e3ef..bf93af7 100644 --- a/YuppleMayham/src/gameplay/map.cpp +++ b/YuppleMayham/src/gameplay/map.cpp @@ -48,7 +48,7 @@ void Map::loadMap() glm::translate(glm::mat4(1.f), glm::vec3(x * mapData->tileSize, y * mapData->tileSize, 0.0f)) * glm::scale(glm::mat4(1.f), glm::vec3(mapData->tileSize, mapData->tileSize, 1.0f)); - int textureIndex = getTileSetIndex(tileIds[layer][y][x]); + int textureIndex = static_cast(getTileSetIndex(tileIds[layer][y][x])); glm::vec2 originalSize = (textureIndex != -1) ? glm::vec2(tileSetData[textureIndex]->width, tileSetData[textureIndex]->height) : glm::vec2(0.0f); @@ -81,7 +81,7 @@ void Map::createCollisionMap() for (int x = 0; x < tileIds[layer][y].size(); x++) { int id = tileIds[layer][y][x]; - int tileSetIndex = getTileSetIndex(id); + size_t tileSetIndex = getTileSetIndex(id); if (tileSetIndex == -1) collisionMap[y][x] = 0; else @@ -111,7 +111,7 @@ the index of the tileSet is the same index as the texture index used in the inst returns tileSetIndex of the tile id passed. Unless the id is either 0 or the returned tileSetIndex is out of bounds, returns -1 */ -int Map::getTileSetIndex(int id) const +size_t Map::getTileSetIndex(int id) const { // work from the bottom, break if ID > startID // If we get a textureIndex of -1 then we are on an empty tile diff --git a/YuppleMayham/src/gameplay/scene.cpp b/YuppleMayham/src/gameplay/scene.cpp index 1e48625..1927415 100644 --- a/YuppleMayham/src/gameplay/scene.cpp +++ b/YuppleMayham/src/gameplay/scene.cpp @@ -132,7 +132,11 @@ std::shared_ptr Scene::getPlayer() const void Scene::update(double deltaTime) { +#if _DEBUG +#else ZoneScoped; +#endif + for (const auto& [id, e] : entities) { e->update(deltaTime); @@ -145,7 +149,10 @@ void Scene::update(double deltaTime) void Scene::render(std::shared_ptr renderer) { +#if _DEBUG +#else ZoneScoped; +#endif renderer->clear(); renderer->setProjAndViewMatrix(camera->getProjectionMatrix(), camera->getViewMatrix()); diff --git a/YuppleMayham/src/gameplay/weapons/bulletmanager.cpp b/YuppleMayham/src/gameplay/weapons/bulletmanager.cpp index 77c4f80..9058187 100644 --- a/YuppleMayham/src/gameplay/weapons/bulletmanager.cpp +++ b/YuppleMayham/src/gameplay/weapons/bulletmanager.cpp @@ -4,6 +4,7 @@ #include "gameplay/camera.h" #include "utility/events.h" #include "utility/component.h" +#include "utility/logger.h" #include #include diff --git a/YuppleMayham/src/graphics/postprocess.cpp b/YuppleMayham/src/graphics/postprocess.cpp index 6736f48..523dcd2 100644 --- a/YuppleMayham/src/graphics/postprocess.cpp +++ b/YuppleMayham/src/graphics/postprocess.cpp @@ -70,7 +70,6 @@ void Postprocessor::applyPostProcess(bool worldOrHud) postProcessData.dt = curTime - lastTime; tickEffectTime(worldOrHud); - LOG(DEBUG, "Blur duration: {}", postProcessData.blurDuration); postProcessShader->use(); postProcessShader->setBool("worldOrHud", worldOrHud); diff --git a/YuppleMayham/src/main.cpp b/YuppleMayham/src/main.cpp index e40e6b4..fe89119 100644 --- a/YuppleMayham/src/main.cpp +++ b/YuppleMayham/src/main.cpp @@ -1,3 +1,4 @@ +#undef GLM_FORCE_FAST_MATH #include #include diff --git a/YuppleMayham/src/utility/xmlloader.cpp b/YuppleMayham/src/utility/xmlloader.cpp index e3ecee9..0520430 100644 --- a/YuppleMayham/src/utility/xmlloader.cpp +++ b/YuppleMayham/src/utility/xmlloader.cpp @@ -437,7 +437,7 @@ bool XMLLoader::loadTile(tinyxml2::XMLElement* tileElement, TileSetData::TileDat /* May support multiple properties in the future with a future property struct to hold any value type But this may not be needed, so we'll just capture the walkable property for now. - Notice we just return true if there is no property, we can just safely default to walkable = true + Assume default of there is no properties tag or walkable property, just use nested if's */ tinyxml2::XMLElement* properties = tileElement->FirstChildElement("properties"); if (properties == NULL) {