Transcript
Page 1: Make Tetris Using Java By bearzx. What is Tetris A simple but interesting game

Make Tetris Using Java

By bearzx

Page 2: Make Tetris Using Java By bearzx. What is Tetris A simple but interesting game

What is TetrisA simple but interesting game

Page 3: Make Tetris Using Java By bearzx. What is Tetris A simple but interesting game

Java Graphic Programming

Just using Graphics ClassDraw anything you want in a Java GUI Gomponent(Jpanel, Jframe, etc)

Page 4: Make Tetris Using Java By bearzx. What is Tetris A simple but interesting game

Key Points Of Tetris Game

How to store a shape ? How to generate a shape ? What happens after a shape is generated ? How to describe a ground ? How to accept a shape, and DELETE full lines ?

Let’ s fix them one by one

Page 5: Make Tetris Using Java By bearzx. What is Tetris A simple but interesting game

How to store a shape ?Just using an array with 3 dimensions

Page 6: Make Tetris Using Java By bearzx. What is Tetris A simple but interesting game

How to generate a shape ?When we need a new shape, we “new” a instance of Shape Class

Page 7: Make Tetris Using Java By bearzx. What is Tetris A simple but interesting game

What happens after a shape is generated ?

Make it falls down, using Java multithreading feature.Define a class which implements Runnable interface

Page 8: Make Tetris Using Java By bearzx. What is Tetris A simple but interesting game

How to describe a ground ?Like a shape, use a 2 dimensions array for a ground, it is just bigger

When you need to draw the ground, just have a look at the obstacles.

Page 9: Make Tetris Using Java By bearzx. What is Tetris A simple but interesting game

How to accept a shape, and DELETE full lines ?

First you need to decide whether or not the shape can move down

Page 10: Make Tetris Using Java By bearzx. What is Tetris A simple but interesting game

How to accept a shape, and DELETE full lines ?

If the shape can’ t move down, accept it.

And don’ t remember to delete the full lines, if you can

Page 11: Make Tetris Using Java By bearzx. What is Tetris A simple but interesting game

Let’ s Link Them Up

Controller

Shape

Ground

GamePanel

• Int [][] body• Shape Driver• drawMe()• moveDown()• moveLeft()• rotate• …

• int [][] obstacles• isMoveable• accept()• drawMe()• deleteLines()

• newGame()• keyPressed()• pause()• stop()• …

Page 12: Make Tetris Using Java By bearzx. What is Tetris A simple but interesting game

Is This Hard ?

Nope, it just have lots of detailsall you need to do is

install your Java Virtual Machine set up your Java IDE

then start codingIf you need to view the complete code, welcome to fork it on GitHubhttps://github.com/bearzx/MyTetris


Top Related