Skip to content

Fixed/Refactored a lot of stuff#10

Merged
Hugo-RM merged 46 commits intomainfrom
meowstro_v2
Sep 5, 2025
Merged

Fixed/Refactored a lot of stuff#10
Hugo-RM merged 46 commits intomainfrom
meowstro_v2

Conversation

@Hugo-RM
Copy link
Owner

@Hugo-RM Hugo-RM commented Sep 5, 2025

Summary

This pull request introduces major improvements to the build system, dependency management, and project structure for multi-platform support. The most important changes are the overhaul of the CI workflow to support Windows, Linux, and macOS, the modernization and simplification of the CMakeLists.txt build configuration, and the addition of automated unit testing. It also removes legacy configuration files and clarifies project dependencies.

Build system and CI improvements:

  • The .github/workflows/build.yml workflow is completely rewritten to support multi-platform builds (Windows, Linux, macOS), with platform-specific setup for dependencies, static analysis (cppcheck, clang-tidy), caching, and artifact uploads. Legacy manual SDL2 downloads are replaced with package managers (vcpkg, apt, Homebrew).

CMake configuration modernization:

  • CMakeLists.txt is refactored to remove reliance on config.json and presets, instead using find_package and pkg-config to locate SDL2 and related libraries. It sets minimum tested versions, splits logic into a static library for easier testing, copies assets after build, and integrates Google Test for unit testing.

Testing and dependency documentation:

  • Adds automated unit testing using Google Test and CTest, with a dedicated test executable and registration in CMake.
  • Adds a new DEPENDENCIES.md documenting minimum tested versions of core dependencies for easier onboarding and troubleshooting.

Cleanup of legacy files:

  • Removes the obsolete CMakePresets.default.json, as configuration is now handled directly in CMake and the workflow.

Legal and attribution update:

  • Updates the LICENSE to include the full list of project contributors.

Refactored Code

  • Reduced main file src/meowstro.cpp from 554 lines to 90.
  • Started utilizing RAII throughout the code
  • Added 15 new classes (might be wrong on the number). 7 are test classes, 1 exception class, 1 RAII Wrapper

Changes

  • Feature added
  • Bug fix
  • Refactored code

Testing

  • Utilized GTest and GitHub Actions.
  • Built and ran the code on my personal devices

Hugo-RM added 30 commits August 28, 2025 22:57
The build process now uses a vcpkg for dependency management.

This simplifies a lot of things but required some changes to file paths.

I also redid the CMakeLists.txt and build.yml files to work with this
new build process. I added a few things to the build.yml so hopefully it
works.

Updated the documentation to reflect these changes.

I also removed some old audio files that are no longer needed.

I plan to add tests that can be ran in Git Actions but this is fine
for now.
Made it so each function is looped once before exiting to test w/o user input.

No tests yet but will probably add them later.
Made it so each function is looped once before exiting to test w/o user input.

No tests yet but will probably add them later.
Updated the build configuration and all documentation/scripts related
to it I believe.

I also changed a bit of the main to just reserve space for a vector of
sprites rather than using push_back for each element.
I removed the global download for dependencies step from the README.md
because it was unnecessary. Running the build script handled that

I also made it so the version information is now documented in
DEPENDENCIES.md. I also edited the vcpkg.json and CMakeLists.txt to
work with those versions.

I also changed the workflow file to be more accurately named

name: Windows Build and Test to -> name: Multi-Platform Build and Test
Changed v2.32.2 to v2.28.2 for sdl2
SDL2 >= 2.30.0
SDL2_Image >= 2.8.2
SDL2_Mixer >= 2.8.0
SDL2_TTF >= 2.22.0
SDL2 >= 2.30.0
SDL2_Image >= 2.8.2
SDL2_Mixer >= 2.8.0
SDL2_TTF >= 2.22.0
Use ResourceManager to load and manage fonts and textures. This removes
the need for constant calling of getRenderer from RenderWindow.hpp

It also reduces code for fixing memory leak. Rather than manually
freeing the memory for each texture, the ResourceManager class handles
it automatically when the program exits.

ResourceManager also uses an unordered_map to cache loaded textures and
fonts, improving efficiency by avoiding redundant loading operations.

The file size of Meowstro.cpp has decreased a bit thanks to this but
there are still many more improvements needed to dismantle the code
and make it more modular, maintainable, and testable.
I removed a couple comments that weren't helpful.

I also removed the usage of the std namespace in the codebase.

Finally, I encapsulated configuration-related data and methods within
the GameConfig class for better organization and maintainability. This
class just puts related colors, paths, and values into nested structs.

I updated the CMakeLists.txt to add the new GameConfig files.
Hugo-RM added 16 commits August 31, 2025 09:27
This makes it easier to handle moving things around and allows me to
add additional screens/states more easily. One critical state that is
planned is the pause menu state. I will also consider a settings state.

Currently it only calls the functions in meowstro.cpp but I plan to
change that so the meowstro.cpp file isn't cluttered.
The gameLoop function continues to exist simply for reference but once
the game loop is completely replaced and moved, the 200 line function
will be deleted. It is currently unused thanks to the changes made.

There may be a small issue related to the hook animation when thrown
but that is a visual bug I will fix in the future. This code is a
working game that is essentially a rough draft.
This class allows us to keep all the menus contained here easily. It
also allows for easy navigation between different menu states. Finally,
It can be used to add more menus. This game really needs a pause and
settings menu so those will be very high priority now!
These include
- tests/unit/test_Entity.cpp
- tests/unit/test_GameConfig.cpp
- tests/unit/test_InputHandler.cpp
- tests/unit/test_ResourceManager.cpp
- tests/unit/test_Sprite.cpp
- tests/unit/test_Logger.cpp
@Hugo-RM Hugo-RM merged commit 6f713ab into main Sep 5, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant