Skip to content

Conversation

@jerryf276
Copy link

Time Details and Changelist:

⦁ Fixed compiler error (Took 3 minutes)
⦁ Changed pause button to escape (took 1 minute)
⦁ Made rng seed based on the time since the seed would be the same every time you ran it (1 minute)
⦁ Implemented Screen Shaking when a life is lost (took 30 minutes)
⦁ Added ability to restart the game (took 25 minutes)
⦁ Implemented mouse movement for the pad (took 10 minutes)
⦁ Added a leaderboard (Took 2 hours, took a while due to problem solving)
⦁ Replaced the time left with a guage that decreases based on the time left (took 45 minutes, took a while due to problem solving/debugging)

TOTAL TIME: 3 hours and 55 minutes

… mins)

I also changed the keybind for pause from p to escape for quality of life improving
allows us to see scores up to top 10, when the game finishes an 11th time, the lowest score is deleted off the top 10 scores vector
took a while since i was trying to figure out how to get the maximum time (unfortunately couldn't work it out so i've hard coded 5 seconds since all the power ups use that as their starting time)

if (screenPosition.x != 0 && screenPosition.y != 0) {
shakerSwitch *= -1;
}
Copy link

Choose a reason for hiding this comment

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

This if statement's purpose is a little confusing, with relation to why you don't switch direction when both = 0, perhaps a comment explainer would be nice.

Copy link

Choose a reason for hiding this comment

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

Overall class is set out well, clear, and decoupled from window nicely. Good work!

float shakeDuration = 0;
float currentTime = 0;
sf::Vector2i screenPosition = sf::Vector2i(0, 0);
int shakerSwitch = 1;
Copy link

Choose a reason for hiding this comment

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

Shaker switch only stores -1 or 1, perhaps a smaller 1 byte variable could be used such as int8_t.

_lives = 3;
_ui->addLivesBack();
_masterText.setString("");
}
Copy link

Choose a reason for hiding this comment

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

This feature and commit is pretty clear and sensible, only thing which could be changed is ball & managers could have a reset function instead of being deleted and recreated. Ok here, but could cause issues if say the paddle had a reference to the ball, which is now invalid as the ball has moved.

Copy link

@Corcso Corcso Nov 2, 2025

Choose a reason for hiding this comment

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

In relation to game restarting commit

_sprite.setPosition(sf::Mouse::getPosition().x, _sprite.getPosition().y);
//}
}

Copy link

Choose a reason for hiding this comment

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

Feature is clear and layout is sensible, perhaps could remove unnecessary comments once feature is finalised.

_window->draw(_masterText);
_window->draw(scoreText);

if (gameFinished == true) {
Copy link

Choose a reason for hiding this comment

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

"== true" could be removed here but not a large issue

{
_masterText.setString("Game over. Press R to retry.");

if (gameFinished == true) {
Copy link

@Corcso Corcso Nov 2, 2025

Choose a reason for hiding this comment

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

There is a bug at the moment, if you win the game you cannot play again, it looks to be caused by _levelComplete = false; being missing from the reset logic

Copy link
Author

Choose a reason for hiding this comment

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

Noted, I will fix that when I can.

//adding new score
storedScores.push_back(score);
//sorting the current scores by descending order
std::sort(storedScores.begin(), storedScores.end(), comp);
Copy link

@Corcso Corcso Nov 2, 2025

Choose a reason for hiding this comment

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

comp function could be replaced with std::greater<int>() see https://en.cppreference.com/w/cpp/algorithm/sort.html

{
std::ostringstream oss;

switch (powerup.first)
Copy link

Choose a reason for hiding this comment

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

Large amount of repeated code within this switch case, perhaps could be separated into a separate function.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, it would be more ideal if I do it this way. Thanks for the tip!


// Game logic
float _time;
float maxTime = 5;
Copy link

Choose a reason for hiding this comment

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

Wouldn't a powerup's max time always be their starting time?

Copy link
Author

Choose a reason for hiding this comment

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

If I remember right I believe I was trying to solve the best way to do the timer bar, but got stuck during it.

static constexpr float LIFE_RADIUS = 15.0f;
static constexpr float LIFE_PADDING = 20.0f;

int barSize = 200;
Copy link

Choose a reason for hiding this comment

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

This looks like it could this be const static

Copy link
Author

Choose a reason for hiding this comment

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

That's true, thanks for letting me know.

@Corcso
Copy link

Corcso commented Nov 2, 2025

Overall code is clear and well layed out, changes make sense with no unnecessarily complex class structure or logic.

Some things I noticed besides the comments above:

  • Naming conventions could be better followed for member variables which are prefixed with _
  • Entire window is shook with screen shake which is an interesting choice, but the window is currently locked to the top left of the screen and cannot be moved, perhaps a current window position could be taken at the start of the screen shake so the player can move the window.
  • Bug with restarting after winning, but easy enough fix, mentioned in comment above.
  • There is a few magic number around, both from the original code and added code. These could be moved to constexpr's or static consts.
  • It's hidden so don't worry that you didn't catch it but there is a memory leak (from the original code) in fire ball powerup's deconstructor.

Nice work, could follow and understand code easily 🔥

@jerryf276
Copy link
Author

@Corcso Thank you for taking the time out to review my code :).

Going forward, I will improve my solution based on the feedback you have given me.

I understand that going forward (based on looking at your review as well):

  • I will include more suited naming conventions that match the original code's (Since in the games industry it is very common to add onto existing code).
  • Make use of more modern C++ features (such as the auto keyword and smart pointers)
  • Fix the bugs as mentioned in the review.
  • Instead of using magic numbers, I create an h file that involves constexpr's or static constants
  • Review the original code more in depth so that I can spot bugs (such as the memory leak)

I have taken the feedback regarding the code being clear and well laid out, and using the simple to understand class structure and logic into consideration and will continue to these programming patterns. Thanks again!

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.

2 participants