Javatpoint Logo
Javatpoint Logo

Tetris Game in Java

One of the most common computer games ever created is the Tetris game. Nowadays we can play this game on mobile too. The game was designed, as well as created by Alexey Pajitnov in 1985. He was a Russian Programmer. A lot of different variation has come to this game has come in the market. However, in this tutorial, we will be creating a basic Tetris game.

Tetris game is known as a block puzzle falling game. In a Tetris game, we have a total of seven different shapes known as Tetrominoes. Those seven Tetrominoes are Line-shape, Z-shape, S-shape, L-shape, T-shape, Square-shape, and a Mirrored L-shape. All the mentioned shapes are composed of only four squares. The shapes will fall down the board. The aim of a player playing the Tetris game is to rotate and move shapes so that they get fit as much as they can. If a complete row is formed, that row is destroyed, and the score is incremented. Until we top out, the Tetris game is played.

FileName: Window.java

FileName: Title.java

FileName: Board.java

FileName: ImageLoader.java

FileName: Shape.java

Steps to Compile and Run the Game

The above-written program is not going to compile unless and until we provide assets to it. The audio file and the images have to be put along with the .java files. Observe the following.

Tetris Game in Java

The Window.java file contains the main method. Therefore, it is the file we need compile. The file contains the code that invokes the constructor of the classes mentioned in the other files. Thus, compiling the Window.java file compiles the other files too. For running the game, use the command java Window. A few snapshots of the game is mentioned below.

Tetris Game in Java
Tetris Game in Java

Download







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA