Skip to content

Commit

Permalink
Random.Shared
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacharyPatten committed Oct 28, 2023
1 parent a134118 commit 3aed2ca
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions Projects/Tetris/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,12 @@
int TextColor = 0;
GameStatus GameStatus = GameStatus.Gameover;

Random RamdomGenerator = new();

int INITIALTETROMINOX = (PLAYFIELD[0].Length / 2) - 3;
int INITIALTETROMINOY = 1;
Tetromino TETROMINO = new()
{
Shape = TETROMINOS[RamdomGenerator.Next(0, TETROMINOS.Length)],
Next = TETROMINOS[RamdomGenerator.Next(0, TETROMINOS.Length)],
Shape = TETROMINOS[Random.Shared.Next(0, TETROMINOS.Length)],
Next = TETROMINOS[Random.Shared.Next(0, TETROMINOS.Length)],
X = INITIALTETROMINOX,
Y = INITIALTETROMINOY
};
Expand Down Expand Up @@ -569,8 +567,8 @@ void RestartGame()
Score = 0;
TETROMINO = new()
{
Shape = TETROMINOS[RamdomGenerator.Next(0, TETROMINOS.Length)],
Next = TETROMINOS[RamdomGenerator.Next(0, TETROMINOS.Length)],
Shape = TETROMINOS[Random.Shared.Next(0, TETROMINOS.Length)],
Next = TETROMINOS[Random.Shared.Next(0, TETROMINOS.Length)],
X = INITIALTETROMINOX,
Y = INITIALTETROMINOY
};
Expand Down Expand Up @@ -655,7 +653,7 @@ void TetrominoFall(object? e)
TETROMINO.X = INITIALTETROMINOX;
TETROMINO.Y = INITIALTETROMINOY;
TETROMINO.Shape = TETROMINO.Next;
TETROMINO.Next = TETROMINOS[RamdomGenerator.Next(0, TETROMINOS.Length)];
TETROMINO.Next = TETROMINOS[Random.Shared.Next(0, TETROMINOS.Length)];

xCollision = TETROMINO.Shape[0].Length;
collision = true;
Expand Down

0 comments on commit 3aed2ca

Please sign in to comment.