Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,18 @@ jobs:
Write-Host "No compilation database found, skipping clang-tidy"
}

- name: Build and Test via Script
- name: Build and Test (Debug)
shell: pwsh
run: |
# Run the test script which handles build, test execution, and CTest
./test.ps1

- name: Build and Test (Release)
shell: pwsh
run: |
# Test Release build as well
cmake --build build --config Release
./build/bin/Release/meowstro_tests.exe

- name: Upload Executable Artifact (main branch only)
if: github.ref == 'refs/heads/main'
Expand Down Expand Up @@ -148,11 +155,18 @@ jobs:
echo "No compilation database found, skipping clang-tidy"
fi

- name: Build and Test via Script
- name: Build and Test (Debug)
run: |
# Make script executable and run it
chmod +x ./test.sh
./test.sh

- name: Build and Test (Release)
run: |
# Test Release build as well
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
cmake --build build
./build/bin/Release/meowstro_tests

- name: Upload Executable Artifact (main branch only)
if: github.ref == 'refs/heads/main'
Expand Down Expand Up @@ -219,11 +233,19 @@ jobs:
echo "No compilation database found, skipping clang-tidy"
fi

- name: Build and Test via Script
- name: Build and Test (Debug)
run: |
# Make script executable and run it
chmod +x ./test.sh
./test.sh

- name: Build and Test (Release)
run: |
# Test Release build as well
HOMEBREW_PREFIX=$(brew --prefix)
cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_PREFIX_PATH="$HOMEBREW_PREFIX"
cmake --build build
./build/bin/Release/meowstro_tests

- name: Upload Executable Artifact (main branch only)
if: github.ref == 'refs/heads/main'
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ add_executable(meowstro_tests
tests/unit/test_Sprite.cpp
tests/unit/test_ResourceManager.cpp
tests/unit/test_InputHandler.cpp
tests/unit/test_AssetLoading.cpp
)

target_link_libraries(meowstro_tests
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ After building, run the executable:

> The output directory is always `build/bin/Debug` or `build/bin/Release` depending on the build type, on all platforms.

## Known Issues

**Audio Synchronization:** There are known synchronization issues between the audio, game logic, and rendering that can cause the game to feel slow or off. Due to time constraints and other priorities, this issue remains unresolved. I (Hugo) will get back to it as soon as I feel like I have time to do so. This project will be worked on in the future with the goal of making the game good enough.

## Additional Tools Used in GitHub Actions

- **cppcheck**
Expand Down
20 changes: 1 addition & 19 deletions TEST_RUNNERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,9 @@ test.bat
4. **Display colored status** (✅ pass / ❌ fail)
5. **Exit with proper codes** for CI integration

## Manual Commands

If you prefer to run commands manually:

```bash
# Build everything
cmake --build build --config Debug

# Run tests directly (detailed output)
./build/bin/Debug/meowstro_tests.exe

# Run tests with CTest (CI-style)
cd build && ctest --output-on-failure -C Debug

# Run specific test patterns
./build/bin/Debug/meowstro_tests.exe --gtest_filter="GameStatsTest.*"
```

## Adding New Tests

1. Create new test files in `tests/unit/`, `tests/component/`, etc.
1. Create new test files in appropriate directory.
2. Add the test file to `CMakeLists.txt` in the `meowstro_tests` target
3. Rebuild and run tests

Expand Down
2 changes: 2 additions & 0 deletions include/AnimationSystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class AnimationSystem {

// Update animation timing (call once per frame)
void updateTiming();
void updateTiming(Uint64 currentTime);

// Hook throwing animation
void startHookThrow(Sprite& hook, int handX, int handY, int throwDuration);
Expand Down Expand Up @@ -69,6 +70,7 @@ class AnimationSystem {

private:
float m_timeCounter;
Uint64 m_animationStartTime; // For absolute time calculations

// Helper methods for sway calculations
int calculateSway(float timeOffset = 0.0f) const;
Expand Down
3 changes: 3 additions & 0 deletions include/Audio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ class Audio {
void playBackgroundMusic(const std::string& filePath);
void stopBackgroundMusic();
bool isValid() const { return m_valid; }

// Get precise audio position for beat synchronization
double getMusicPositionMs() const;

private:
Mix_Music* bgMusic;
Expand Down
11 changes: 7 additions & 4 deletions include/Entity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class Entity
// Get raw texture pointer for SDL API calls
inline SDL_Texture* getTexture() const
{
return texture_ ? texture_->get() : nullptr;
// Return shared texture if available, otherwise raw texture
return texture_ ? texture_->get() : rawTexture_;
}
// Get shared texture for ownership transfer
inline SharedSDLTexture getSharedTexture() const
Expand All @@ -37,10 +38,11 @@ class Entity
{
texture_ = texture;
}
// Set texture from raw pointer (creates shared ownership)
// Set texture from raw pointer (non-owning reference)
inline void setTexture(SDL_Texture* texture)
{
texture_ = texture ? makeSharedSDLTexture(texture) : nullptr;
rawTexture_ = texture;
texture_ = nullptr; // Clear shared texture
}
protected:
// Fixed type consistency - use float to match member variables
Expand All @@ -55,5 +57,6 @@ class Entity
float x;
float y;
SDL_Rect currentFrame;
SharedSDLTexture texture_;
SharedSDLTexture texture_; // For owned textures
SDL_Texture* rawTexture_; // For non-owned textures (ResourceManager-owned)
};
6 changes: 6 additions & 0 deletions include/ResourceManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ class ResourceManager {
// Manual cleanup (called automatically in destructor)
void cleanup();

// Clear texture cache without destroying textures (for state resets)
void clearCache();

// Validate that a texture pointer is still valid
bool isTextureValid(SDL_Texture* texture) const;

// Validity checking
bool isValid() const { return m_valid; }

Expand Down
7 changes: 7 additions & 0 deletions include/RhythmGame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ class RhythmGame {
Uint32 m_songStartTime;
std::vector<bool> m_noteHitFlags;

// Frame timing for consistent framerates
Uint64 m_lastFrameTime;
Uint64 m_targetFrameTime;

// Game entities
Entity m_ocean;
Entity m_scoreLabel;
Expand Down Expand Up @@ -100,4 +104,7 @@ class RhythmGame {

// Format score helper
std::string formatScore(int score);

// Helper method for precise timing
double getCurrentGameTimeMs() const;
};
Loading
Loading