Lesson Block · Detail
Tetris with Matrices and Rotations
This building block reveals the modeling of a game field as a matrix as well as the algorithmic processing of movement, rotation, and collision. Didactically relevant is the step-by-step connection of data structure, state logic, and visual implementation in a clearly traceable application context.

Introduction (Original Extract)
Didactic Classification
Subjective Target Setting
In the center of this module is the modeling of a game field as a two-dimensional list. This introduces a central information concept: representing a discrete grid by a matrix structure. Based on this, stones are described as smaller matrices and their position is managed through coordinates. Learners link abstract data models to a concrete visual representation in the game. The rotation of forms requires a structured rearrangement of matrix entries and makes algorithmic transformations visible. The connection between model and implementation shows itself particularly in that every movement, collision, and row deletion directly results from the chosen data structure.
Competence development
- Modeling a game field as a two-dimensional list with row and column structure
- Representation of game stones as small matrices with occupied and unoccupied cells
- Managing an active stone over form data and coordinates in a data structure
- Implementation of movement logic through event processing and state changes in the main loop
- Development of a collision check for edges, floor, and already occupied fields
- Application of matrix rotation as an algorithmic transformation of form data
- Analysis and processing of complete rows as a prerequisite for point logic and speed adjustment
Didactic added value in the lesson
- Gradual progression from the data structure to movement rules to extended game logic
- Clear sequence of tasks with well-distinguishable partial problems in the subject area
- Promoting systematic thinking through repeated examination of states and conditions
- Transparent goal orientation through immediate visible effects of each implementation decision
- Supporting differentiation through successive extension steps in varying levels of depth
Lesson flow
Game field matrix and keyboard control
At the beginning, the game field is secured as a matrix and supplemented with basic keyboard control. The task combines the representation of the grid with initial movement rules and introduces the logic for when a stone can fall again or must be newly generated. This creates the functional basis for all further game mechanisms.
- Didactic focus: matrix model and state-based control
- Typical challenge: consistent testing of boundary conditions during movements
Rotating Tetrominos as matrices
In the second step, various forms are introduced and processed as small matrices. The rotation requires a targeted rearrangement of the matrix entries and is linked with the same collision test as movement. This makes it clear that different game actions rely on common logical rules.
- Didactic focus: matrix transformation and rule consistency
- Typical challenge: valid rotation without exceeding the game field
Deleting rows, points, and speed
Subsequently, the game logic is extended to recognize and remove complete rows. Based on this, points, lines, and levels are introduced as additional states from which a changed fall speed can be derived. This step combines data processing with a comprehensible rule development in the course of the game.
- Didactic focus: Evaluation of matrix states and progress logic
- Typical challenge: Correct removal and addition of rows in the game field
Full game
The final task serves a consolidating consideration of a complete reference game. In the foreground is not the addition of new code, but the recognition of previously developed mechanisms in a cohesive overall application. This reflects the development of competence and secures it professionally.
- Didactic focus: Integration and reflection of the overall context
- Typical challenge: Individual components in the overall system to be safely assigned
Work assignment (excerpt)
- Model the game field as a matrix and add a controllable fall movement of the active stone.
- Extend the game with various Tetrominos and rotation based on matrix operations.
- Consequently check movements and rotations through uniform collision logic.
- Implement deleting complete rows, points, lines, and increasing speed.
Example (excerpt)
The following excerpt is didactically relevant because it makes the rotation as targeted reordering of a matrix visible, thus highlighting a central core of the module.
| |
Hints for classroom practice
- For the overall sequence, a division into at least two teaching phases is recommended, as modeling, rotation, and extended game logic each form independent focal points.
- Differentiation can be achieved through the depth of collision logic, additional shapes or refined level calculation.
- To ensure results, a comparison of used data structures and derived rules for movement, rotation, and row deletion is suitable.
- As an extension, further Tetromino variants, a preview system for the next stone, or additional game states are offered.
- Content-wise, this module can be easily linked to topics such as two-dimensional data structures, state-checking algorithms, and event-driven programming.
The clear task structure supports classroom organization and facilitates systematic result verification. Extension tasks enable proper differentiation in the further course.
Request a demo access and test the module in your own course context.