To create a simple game like Tetris requires minimal logic operations and basic knowledge of a programming language. This time, we are going to use Java.
The tools required by this application include:
- a two-dimensional array for the game board
- a data type for a game piece (Tetris pieces)
- a set of rules and checks for game functions
- a viewer to display things graphically (Swing)
- a runnable thread to keep the game moving
- a event handler class to tie everything together
Using the MVC design pattern, we can categorize these into three main components:
- Model Class: holds all game assets, including objects and rules (functions)
- Viewer Class: with subcomponents done in Swing
- Controller Class: implements Runnable and acts as listener for Swing components
Files: