Tetris Game in JavaOne 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 GameThe 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. 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. Next TopicFactorial Trailing Zeroes in Java |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India