Skip to content

CLIENT-GAME: Fix sounds#108

Merged
guillaumeAbel merged 6 commits intodevfrom
fix/RB-137-Fix-bullets-sounds
Oct 15, 2023
Merged

CLIENT-GAME: Fix sounds#108
guillaumeAbel merged 6 commits intodevfrom
fix/RB-137-Fix-bullets-sounds

Conversation

@kw4ntiq
Copy link
Copy Markdown
Collaborator

@kw4ntiq kw4ntiq commented Oct 15, 2023

PATCH

  • Please check if the PR fulfills these requirements
  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Norm of the code has been respected
  • In what state is your pull request?
  • Ready to merge / Waiting a reviwer to see my work.
  • Work In Progress (WIP) / My work is not finish but i want daily reviews. (Draft)
  • CI Review / I want to see what the CI thinks of my work.
  • Need feedback / Just to have feedback on what i produced. (May not be merged)
  • What kind of change does this PR introduce? (You can choose multiple)
  • Bug fix
  • Feature request
  • New / Updated documentation
  • Testing CI ( Make the pull request in draft mode)
  • What is the current behavior? (link an issue based on the kind of change this pr introduce)

  • What is the new behavior (if this is a feature change)?

  • Other information:

Summary by CodeRabbit

  • New Feature: Added sound effects to enhance the gaming experience. Now, when a player shoots a bullet, a laser sound will be played. This addition makes the game more immersive and interactive.
  • Refactor: Simplified the audio system by removing unnecessary checks for sound path matches and keyboard key presses. This change streamlines the audio functionality, improving the game's performance and reliability.

@kw4ntiq kw4ntiq self-assigned this Oct 15, 2023
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Oct 15, 2023

Rate Limit Exceeded

@TTENSHII has exceeded the limit for the number of files or commits that can be reviewed per hour. Please wait 16 minutes and 20 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, convert this PR to a draft and then mark it as ready for review again to re-trigger the review. Alternatively, you can push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per repository.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between 89edaf0 and fcc7037.

Walkthrough

The changes introduce audio functionality to the game by adding a new constant soundPathShoot and modifying the playerShootBullet function to play a sound when shooting a bullet. The arrSounds component array is retrieved from the registry and iterated over to find the matching sound. The redundant loop in AudioSystems.cpp has been removed.

Changes

File Path Summary
src/Client/Systems/Events/EventsSystems.cpp Introduced a new constant soundPathShoot and modified playerShootBullet function to play a sound when shooting a bullet. The arrSounds component array is retrieved from the registry and iterated over to find the matching sound.
src/Client/Systems/Graphic/AudioSystems.cpp Removed a redundant loop that checked for a specific sound path and keyboard key press.

🎵🐇

"In the realm of code, changes we make,

For the joy of sound, a journey we take.

With a bullet's flight, a sound will play,

In the heart of the game, it will sway.

Redundant loops, we bid adieu,

For cleaner code, we continue to pursue."


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • Mention @coderabbitai in any review comment for bot assistance.
  • Note: Review comments are made on code diffs or files, not on the PR overview.

Pause Incremental Reviews

  • Insert @coderabbitai: ignore in the PR description to halt the bot's ongoing reviews. Remove the line to resume.
  • Additionally, enter @coderabbitai pause to halt the bot's ongoing reviews as any issue or review comment. To
    resume reviews, enter @coderabbitai resume as any issue or review comment.

@kw4ntiq kw4ntiq added the bug Something isn't working label Oct 15, 2023
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 2

Details

Commits Files that changed from the base of the PR and between 1303069 and 85c603a.
Files selected for processing (2)
  • src/Client/Systems/Events/EventsSystems.cpp (3 hunks)
  • src/Client/Systems/Graphic/AudioSystems.cpp (1 hunks)
Files skipped from review due to trivial changes (1)
  • src/Client/Systems/Graphic/AudioSystems.cpp

Comment on lines +67 to +68
const std::size_t waitTimeBullet = 500;
const std::string soundPathShoot = "assets/Audio/Sounds/laser.ogg";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The soundPathShoot constant is defined within the playerShootBullet function. If this sound path is used elsewhere in the code, consider moving it to a more global scope to avoid duplication.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 1

Details

Commits Files that changed from the base of the PR and between 85c603a and 856f1f0.
Files selected for processing (1)
  • src/Client/Systems/Events/EventsSystems.cpp (3 hunks)
Additional comments (Suppressed): 2
src/Client/Systems/Events/EventsSystems.cpp (2)
  • 67-68: The soundPathShoot constant is defined but not used in the old hunk. Ensure that it is used appropriately in the new hunk.

  • 74-80: The retrieval of arrSounds and ids seems to be a new addition to the function. Ensure that these are used appropriately in the function and that the necessary error handling is in place in case the retrieval fails.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Details

Commits Files that changed from the base of the PR and between 856f1f0 and 89edaf0.
Files selected for processing (1)
  • src/Client/Systems/Events/EventsSystems.cpp (2 hunks)
Additional comments (Suppressed): 2
src/Client/Systems/Events/EventsSystems.cpp (2)
  • 67-70: The waitTimeBullet and soundPathShoot variables have been moved inside the playerShootBullet function and made static. This change is good for encapsulation and makes the function more self-contained. However, ensure that the waitTimeBullet variable is not used elsewhere in the codebase, as this change would break those references.

  • 85-89: The new code introduces audio functionality to the playerShootBullet function. It retrieves the Raylib::Sound components from the registry and iterates over them to find the sound with the matching path. If found, it sets the needToPlay flag of the sound to true. This is a good addition for enhancing the game's user experience. However, consider extracting this logic into a separate function for better modularity and reusability.

void playSound(const std::string& soundPath) {
    Registry &registry = Registry::getInstance();
    Registry::components<Raylib::Sound> arrSounds = registry.getComponents<Raylib::Sound>();
    for (auto &sound : arrSounds) {
        if (sound.getPath() == soundPath) {
            sound.setNeedToPlay(true);
        }
    }
}

Then, you can simply call this function in playerShootBullet:

void playerShootBullet(std::size_t /*unused*/, std::size_t /*unused*/)
{
    // ...
    playSound(soundPathShoot);
    // ...
}

@guillaumeAbel guillaumeAbel merged commit 3c921a8 into dev Oct 15, 2023
@Saverio976 Saverio976 deleted the fix/RB-137-Fix-bullets-sounds branch October 17, 2023 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants