-
Notifications
You must be signed in to change notification settings - Fork 115
Fixes and tasks for assignment #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…Fireball in its base class)
… 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; | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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(""); | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); | ||
| //} | ||
| } | ||
|
|
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
|
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:
Nice work, could follow and understand code easily 🔥 |
|
@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 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! |
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