In the previous two posts, we defined what we want our model of Tetris in Blazor to look like, and we created classes such as Grid and CellCollection to help model the game.

In this post, we are going to write up the C## classes that will define each tetromino, as well as enumerations for their style and orientation, their common base class, and a generator class that we will use to populate the “upcoming pieces” display in our game.

It’s a lot of work, but it’ll be super cool when we’re done. Let’s go!

The Sample Project

Don’t forget to check out the entire BlazorGames repository over on GitHub!

Style and Orientation

A _tetromino _is a set of four (4) cells that moves as a unit on the Tetris game grid. In Tetris, tetrominos have the following properties:

  • Each tetromino is a different color.
  • The tetromino can be moved left or right on the grid.
  • The tetromino can be “hard dropped” to the bottom of the play area.
  • Tetrominos can be rotated about a central point.
  • The tetromino automatically drops one row after a certain amount of time has elapsed.

#blazor #modeling practice #tutorials #sample project #games #asp.net

Tetris in Blazor Part 3: Tetrominos
1.50 GEEK