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

Snake speed options #87

Merged
merged 6 commits into from
Oct 17, 2023
Merged

Snake speed options #87

merged 6 commits into from
Oct 17, 2023

Conversation

alexsrk09
Copy link
Contributor

No description provided.

sleep TimeSpan via velocity integer changeable depending of the level selector
conditional to prevent non valid number and catch to prevent other imputs
@ZacharyPatten
Copy link
Collaborator

ZacharyPatten commented Oct 12, 2023

@alexsrk09 Thanks for the interest in contributing! :) Sorry it took me a while to respond.

My initial review notes:

  1. int.TryParse is better than Convert.ToInt32 with exception handling
  2. I want to keep all the output in English
  3. This change would also need to be applied to the web version of the game located here: https://github.com/dotnet/dotnet-console-games/blob/main/Projects/Website/Games/Snake/Snake.cs

Please reply to #87 (comment). After you do so, I can help with each of these topics.

@alexsrk09
Copy link
Contributor Author

@alexsrk09 Thanks for the interest in contributing! :) Sorry it took me a while to respond.

My initial review notes:

  1. int.TryParse is better than Convert.ToInt32 with exception handling
  2. I want to keep all the output in English
  3. This change would also need to be applied to the web version of the game located here: https://github.com/dotnet/dotnet-console-games/blob/main/Projects/Website/Games/Snake/Snake.cs

Please reply to #87 (comment). After you do so, I can help with each of these topics.

@ZacharyPatten thank you very much for your reply!
This is my first contribution, our programming teacher has recommended this repo to us to learn c#, anyway, I have no problem correcting those 3 points that you have pointed out to me!

@alexsrk09
Copy link
Contributor Author

@alexsrk09 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@dotnet-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@dotnet-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@dotnet-policy-service agree company="Microsoft"

Contributor License Agreement

@dotnet-policy-service agree

@alexsrk09
Copy link
Contributor Author

alexsrk09 commented Oct 17, 2023

@alexsrk09 Thanks for the interest in contributing! :) Sorry it took me a while to respond.

My initial review notes:

  1. int.TryParse is better than Convert.ToInt32 with exception handling
  2. I want to keep all the output in English
  3. This change would also need to be applied to the web version of the game located here: https://github.com/dotnet/dotnet-console-games/blob/main/Projects/Website/Games/Snake/Snake.cs

Please reply to #87 (comment). After you do so, I can help with each of these topics.

all 3 topics done!

@ZacharyPatten
Copy link
Collaborator

Nice. The changes you made work, but I applied a few extra changes. Here are some notes if you were curious:

  • I removed your exception handling try...catch because int.TryParse lets us handle user input without the need for exception handling. Instead of throwing exceptions, int.TryParse returns a bool indicating if the input was able to be parsed into an int or not. No exception handling required.
  • I added a default velocity so that if the user presses enter instead of providing a speed (they leave the input blank) it will default to speed [2].
  • I removed the comments in the code because in general if code is written well it should be easy to read even without comments.
  • I reduced the velocities of the web version from [100ms, 70ms, 50ms] to [50ms, 35ms, 20ms] because the web version feels a little sluggish using the same sleeps as the console version. This might be due to some inneficiency in my code or Blazor. Regardless, I just felt these shorter sleep times felt better.

Good job figuring out that you needed await on the web version of the code. :)

@ZacharyPatten ZacharyPatten changed the title New snake Snake speed options Oct 17, 2023
@ZacharyPatten ZacharyPatten merged commit 0eb8e52 into dotnet:main Oct 17, 2023
3 checks passed
@ZacharyPatten
Copy link
Collaborator

@alexsrk09 Thanks for contributing! 🎉

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