make tetris using java by bearzx. what is tetris a simple but interesting game
TRANSCRIPT
![Page 1: Make Tetris Using Java By bearzx. What is Tetris A simple but interesting game](https://reader036.vdocuments.mx/reader036/viewer/2022062801/56649e575503460f94b4f119/html5/thumbnails/1.jpg)
Make Tetris Using Java
By bearzx
![Page 2: Make Tetris Using Java By bearzx. What is Tetris A simple but interesting game](https://reader036.vdocuments.mx/reader036/viewer/2022062801/56649e575503460f94b4f119/html5/thumbnails/2.jpg)
What is TetrisA simple but interesting game
![Page 3: Make Tetris Using Java By bearzx. What is Tetris A simple but interesting game](https://reader036.vdocuments.mx/reader036/viewer/2022062801/56649e575503460f94b4f119/html5/thumbnails/3.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022062801/56649e575503460f94b4f119/html5/thumbnails/4.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022062801/56649e575503460f94b4f119/html5/thumbnails/5.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022062801/56649e575503460f94b4f119/html5/thumbnails/6.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022062801/56649e575503460f94b4f119/html5/thumbnails/7.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022062801/56649e575503460f94b4f119/html5/thumbnails/8.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022062801/56649e575503460f94b4f119/html5/thumbnails/9.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022062801/56649e575503460f94b4f119/html5/thumbnails/10.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022062801/56649e575503460f94b4f119/html5/thumbnails/11.jpg)
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](https://reader036.vdocuments.mx/reader036/viewer/2022062801/56649e575503460f94b4f119/html5/thumbnails/12.jpg)
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