Updated game structure
Some checks failed
Build and Package Tetris / build-windows (push) Has been cancelled
Build and Package Tetris / build-linux (push) Has been cancelled

This commit is contained in:
2025-08-16 12:10:19 +02:00
parent 71648fbaeb
commit 2afaea7fd3
36 changed files with 665 additions and 382 deletions

View File

@ -22,14 +22,16 @@ find_package(SDL3_ttf CONFIG REQUIRED)
add_executable(tetris
src/main.cpp
src/Game.cpp
src/Scores.cpp
src/Starfield.cpp
src/Starfield3D.cpp
src/Font.cpp
src/Audio.cpp
src/LineEffect.cpp
src/SoundEffect.cpp
src/gameplay/Game.cpp
src/core/GravityManager.cpp
src/core/StateManager.cpp
src/persistence/Scores.cpp
src/graphics/Starfield.cpp
src/graphics/Starfield3D.cpp
src/graphics/Font.cpp
src/audio/Audio.cpp
src/gameplay/LineEffect.cpp
src/audio/SoundEffect.cpp
# State implementations (new)
src/states/LoadingState.cpp
src/states/MenuState.cpp
@ -73,4 +75,30 @@ if (WIN32)
endif()
# Include production build configuration
include(cmake/ProductionBuild.cmake)
include(cmake/ProductionBuild.cmake)
# Enable CTest so `add_test` registers tests for `ctest`
enable_testing()
# Unit tests (simple runner)
find_package(Catch2 CONFIG REQUIRED)
add_executable(tetris_tests
tests/GravityTests.cpp
src/core/GravityManager.cpp
)
target_include_directories(tetris_tests PRIVATE ${CMAKE_SOURCE_DIR}/src)
target_link_libraries(tetris_tests PRIVATE Catch2::Catch2WithMain)
add_test(NAME GravityTests COMMAND tetris_tests)
if(EXISTS "${CMAKE_SOURCE_DIR}/vcpkg_installed/x64-windows/include")
target_include_directories(tetris_tests PRIVATE "${CMAKE_SOURCE_DIR}/vcpkg_installed/x64-windows/include")
endif()
# Add new src subfolders to include path so old #includes continue to work
target_include_directories(tetris PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/audio
${CMAKE_SOURCE_DIR}/src/gameplay
${CMAKE_SOURCE_DIR}/src/graphics
${CMAKE_SOURCE_DIR}/src/persistence
)