Search⌘ K

Step 2: The Board class

Explore the Board class in this lesson to understand how it handles drawing game blocks and user inputs in a Java Tetrominos game. Learn how methods like paintComponent, nextTurn, slide, and rotate control game behavior and graphics using Java Swing components.

We'll cover the following...

To focus on learning Java, you may reasonably ignore the Tetrominos class. It will be the file that you run to start the program, but the Board class can be thought of as the core of your Tetrominos program, and it’s where you’ll write the most code. Go to Eclipse and start reading the code now.

The keyword extends and some provided code in the constructor set the Board up as a user interface component that can be added to a window, and you may safely ignore this code.

Each of the other existing methods in the Board class will be called in response to certain actions, either by the user, or due to time passing. Specifically:

  • paintComponent ...