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

Tetris #89

Merged
merged 24 commits into from
Oct 31, 2023
Merged

Tetris #89

merged 24 commits into from
Oct 31, 2023

Conversation

Jahgii
Copy link
Contributor

@Jahgii Jahgii commented Oct 27, 2023

#17

Hi, I made my first game on console, and I would like to share it with the community, I followed the contribution checklist, but maybe I did something wrong.

I played the game on the website, and everything seems to work, except for the color change in the text, which for some reason slows down and breaks the game on the website. so I decided to disable it.

As I mentioned before, this is my first game so it may have a couple of bugs or many.

New Game Contribution Checklist

  • ✅ Projects/
  • ✅ Projects//README.md
  • ❎ README.md add a row in the table (contribution link)
  • ✅ dotnet-console-games-and-website.sln add project to solution
    • ⬜ website.sln add project to solution
  • ✅ dotnet-console-games.slnf add project to solution filters
  • ✅ .vscode/tasks.json add a build task for the project
  • ✅ .vscode/launch.json add a launch entry for the game
  • ✅ .github/workflows/.yml add a GitHub Action
  • ✅ Projects/Website/... (multiple files)

@ZacharyPatten ZacharyPatten added the community contribution Games originally contributed by members of the community. Thank you! label Oct 27, 2023
@ZacharyPatten
Copy link
Collaborator

@Jahgii Thanks for your interest in contributing! :)

Because the project is part of the .NET Foundation, please read and reply to #89 (comment). After you do so I will review your code as soon as I have time.

Also, thanks for following the new game checklist. That helps. :)

@Jahgii
Copy link
Contributor Author

Jahgii commented Oct 27, 2023

@dotnet-policy-service agree

@ZacharyPatten
Copy link
Collaborator

ZacharyPatten commented Oct 28, 2023

I made some edits and I will be working on some additional edits. I will try to be granular with my commits so each change makes sense. Feel free to ask why or express disagreement with any changes I make.

Additional Notes:

  1. While the game does support spinning the tetromninos, it seems like the spinning can be improved. I'm no Tetris expert, but I found this video in a quick search: https://www.youtube.com/watch?v=yIpk5TJ_uaI&t=228s.
  2. It would be nice if the game followed typical Tetris scoring values.
  3. It would be nice if there was a button that would instantly drop a tetromino all the way down.
  4. Rapidly pausing and unpausing the game changes the speed at which the current tetromino falls.
  5. We might want to add a check that the console is large enough to render the game. If the console is not big enough, instead of updating the game we can just write, "Please increase the size of the console to XXX x YYY." until the user does so.
  6. The code shouldn't be using a System.Threading.Timer. There is no need to multithread console games like this, and the multithreading is acutally causing inconsistent update times. This should be adjusted to just a simple loop with either DateTime or Stopwatch checks.

#1, #2, and #3 don't need to be done before this pull request is merged. They could be handled as enhancement issues and tackled in the future.

#4 will be fixed along with #6 and I will work on that. I should be able to fix #5 at the same time too.

Also, I will re-synch the console version with the web version before this pull request is merged. :)

@Jahgii
Copy link
Contributor Author

Jahgii commented Oct 29, 2023

Nice, I made points 1, 3 and partially 2.

I not quite sure which score system use. For the moment I just change the code to add 1 point per line and 1 more if 4 lines were cleared.

@ZacharyPatten
Copy link
Collaborator

Okay I made a considerable number of changes in the last commit 09e9e1f. Sorry I didn't do the changes in a more granular manor, but there were numerous things that needed to be changed at once. Here are some of the changes I made:

  • I changed the scoring a bit so 1 line = 1 score, 2 lines = 3 score, 3 lines = 6 score, and 4 lines = 9 score. While this still isn't the proper tetris scoring, the idea is that you want to give bonus score for when the user is able to clear multiple lines at a time at once.
  • Because I changed the scoring, I also changed the rate at which the current falling speed is adjusted. Falling speed starts at 1000 ms = 1 s and then every 18 points (or 2 Tetris's) the falling speed changes by 100 ms with a minimum of 100 ms per unit fall.
  • I removed the Timer which was #6 from my previous comment, which fixed #4 as well.
  • If the console window is too small to render the game, I pause the game until the user makes their console window bigger, fixing #5 from my previous comment.
  • I removed the debugging controls because in my opinion if users want to debug the app, it is better for them to just download the source code and debug it in an IDE. It is easier to debug in an IDE than use the custom inputs.
  • I removed the ability to change the console colors, because while that is a cool feature, it is just as easy for the user to change the colors of the console themselves. It would be different if we used different colors in the same render frame, but since everything would be the same color, yeah it is just easier for user to change their console settings if they want to.

I made a few more changes than that. Feel free to ask why I made any of the changes. :)

@ZacharyPatten
Copy link
Collaborator

Note: I just tested Tetris on Debian12 (linux) and it ran as expected.

@ZacharyPatten
Copy link
Collaborator

I assigned Tetris a "weight" of 5. I think that is appropriate, but I'm willing to change it if anyone disagrees with that. :D "weight" is just an arbitrary number on the main README to try to nudge new developers to start with easier projects.

@ZacharyPatten ZacharyPatten merged commit 9ffa727 into dotnet:main Oct 31, 2023
3 checks passed
@ZacharyPatten
Copy link
Collaborator

ZacharyPatten commented Oct 31, 2023

@Jahgii Thanks for contributing! :) Your game is now playable online in the website currently at https://dotnet.github.io/dotnet-console-games/Tetris.

I know I made multiple changes to your code. If you disagree with any of them or want to improve anything in the future then feel free to open another pull request.

I think there is still room to clean up the code, but it appears to work and that is what matters. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community contribution Games originally contributed by members of the community. Thank you!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants