Skip to content
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

Added R key to reset game #350

Merged
merged 9 commits into from
Mar 27, 2023
Merged

Added R key to reset game #350

merged 9 commits into from
Mar 27, 2023

Conversation

imizao
Copy link
Contributor

@imizao imizao commented Mar 25, 2023

Hi guys, I added a reset_game method to the example invaders.

When the game is over, you can use the R key to reset!

And use the min function instead of the if function expression!

Copy link
Owner

@parasyte parasyte left a comment

Choose a reason for hiding this comment

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

Thank you! I love the refactor in shrink_bounds().

IIRC what I wanted to do with this game was show a quick "game over" message and then automatically reset after a few seconds. It looks like you did the hard part implementing a reset method.

I'll accept this, but it would be a "more professional" looking game with the game over screen and not requiring the player to reset with a button.

self.shields = (0..4)
.map(|i| Shield {
sprite: Sprite::new(&self.assets, Frame::Shield1),
pos: Point::new(i * 45 + 32, 192),
Copy link
Owner

Choose a reason for hiding this comment

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

We should probably move these magic numbers to const values at global (module) scope. If they need to be reused in multiple modules, we can create a crate::consts module for them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

LGTM

@@ -165,6 +169,11 @@ fn main() -> Result<(), Error> {
return;
}

// Reset game
if g.game.input.key_pressed(VirtualKeyCode::R) {
Copy link
Owner

Choose a reason for hiding this comment

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

Please add a binding for controller inputs as well. Maybe the "select" button? I don't actually know what it's called any more on XBox/PS/Switch!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe the "select" button? I don't know!LOL ; )

But I believe that if add the selected operation interface, this problem will be solved!

@imizao
Copy link
Contributor Author

imizao commented Mar 26, 2023

Thank you! I love the refactor in shrink_bounds().

Yes, I also like shrink_bounds(), but after the actual test, there are still problems (such as: eliminating the entire line or sorting), so I removed it!

IIRC what I wanted to do with this game was show a quick "game over" message and then automatically reset after a few seconds. It looks like you did the hard part implementing a reset method.

I'll accept this, but it would be a "more professional" looking game with the game over screen and not requiring the player to reset with a button.

Yes, I agree with you!

Show game_over, adding a selection button interface will give users better interaction! This is what I want too!

For more professional games, you can also consider adding score and explosion effects...

But it is still a challenge for me now ; )

@parasyte
Copy link
Owner

and explosion effects...

This was partially implemented a long time ago in #18! I was never quite satisfied with the way collision shapes are managed in that PR. This and some sound effects make the game really enjoyable.

@imizao
Copy link
Contributor Author

imizao commented Mar 26, 2023

and explosion effects...

This was partially implemented a long time ago in #18! I was never quite satisfied with the way collision shapes are managed in that PR. This and some sound effects make the game really enjoyable.

Nice!

@imizao
Copy link
Contributor Author

imizao commented Mar 26, 2023

image

What do I need to do with this?

@parasyte
Copy link
Owner

There's a button to request reviews which will clear that status. I'll get to the review in the morning!

@parasyte
Copy link
Owner

BTW here's that button I was talking about.

image

@imizao imizao requested a review from parasyte March 27, 2023 01:43
@imizao
Copy link
Contributor Author

imizao commented Mar 27, 2023

Should I just click on it?

Copy link
Owner

@parasyte parasyte left a comment

Choose a reason for hiding this comment

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

This looks good! Are you planning to continue working toward the "game over" screen in this PR, or do you prefer this to be merged as it is? I'm ok even with the latter, but it seems kind of "half baked" to stand on its own.

I would just like a sense of what your plans are.

@imizao
Copy link
Contributor Author

imizao commented Mar 27, 2023

Yes, I think I know what you mean!

Hmmm...my thought was to merge first!

Because I am still at work, I usually only consider dealing with open source work when I have enough time on weekends! In this process, I don’t want to have a PR hanging in my heart all the time.

Maybe I saw some parts that can be modified, or parts that can be optimized in the community, so I would consider participating in it! Just like the PR I submitted, I only want to do "Added R key to reset game" at the moment, maybe it may look like "half baked" at the moment! Don't worry about merging this PR! Maybe there will be another "me" to realize the "game over" function. Of course, if I realize it, I will submit a PR without hesitation. I am very happy to contribute my meager strength to the community! Thank you also for your valuable advice, which gave me a lot of direction! I have learned a lot from cooperating with you, thank you very much!

@parasyte
Copy link
Owner

Thank you for your contribution! It is objectively an improvement, even if it is not exactly what we want. :)

@parasyte parasyte merged commit d850918 into parasyte:main Mar 27, 2023
@imizao
Copy link
Contributor Author

imizao commented Mar 27, 2023

Thank you for making a decision, things need to be perfected step by step, excellent products also need to come from constant polishing! Maybe someday I will find out that "Added R key to reset game" is wrong, and I will improve it too! Both we and our products need to undergo continuous self-improvement and self-iteration, so that we can grow slowly and become better slowly! ; )

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