How to Code Tetris in Java
Coded Tetris for the first time and this is how I did it.
If you want to learn how the game loop works in detail:
• Game Loop and Key Inpu...
The in-game background music is from:
• 【フリーBGM】白い迷宮 - active ...
ポケットサウンド - @pocketse
The sound effects download link:
drive.google.com/drive/folder...
*All sound effects were made using Beepbox
www.beepbox.co
Thanks for watching!
Timestamps
0:00:00 Introduction and Setup
0:01:28 Window and Game Panel
0:04:25 Game Loop
0:08:30 Play Area
0:14:35 Block and Tetromino
0:18:52 Create the First Tetromino
0:25:40 Auto Drop
0:28:32 Movement
0:32:08 Rotation
0:37:05 Create Other 6 Tetrominoes
0:42:45 Pickup a Random Tetromino
0:44:55 Collision
0:54:19 Replace the Current Tetromino with the Next One
0:59:19 Static Blocks Collision
1:01:50 Sliding
1:05:02 Delete line(s)
1:10:15 Add Effect
1:13:00 Game Over
1:15:50 Scores and Level
1:20:40 Music and Sound Effect
1:30:15 FINAL RESULT
#gamedev #javatutorial
Пікірлер: 115
The goat is back
Super excited to see another tutorial! Your explanations are very clear and have helped me a lot. I only have a couple of videos left in the 2D tutorial and I'm looking forward to tackling this one when I'm ready.
So great to have new videos from you. Currently following your Java tutorial for creating my 2D game, thank you!
Love your videos! Thanks so much for uploading a new tutorial.
Thank-you so much for the tutorial! It's always so cool to see how people handle these kinds of projects differently and your take was very simple and straight-to-the-point, which I find to be one of the best things about your channel! I can't wait to see what else you have planned in the future and wish the best of luck to you!
Thank you legend, this is just awesome. Your coherent and elegantly paced explanation makes it easy to follow and learn the concepts.
I have been very excited for this since I saw tweet about the tutorial. It's always exciting to see an upload from you!! I learned so much from your videos 💕
I always look forward to your uploads! They always inspire me to keep coding! Thank you :D
I picked up Java as my first computer language and I can't thank you enough for these tutorials. You are literally the best Java teacher on KZread.
@RyiSnow
7 ай бұрын
Glad you liked them and good luck with your learning!
I've been waiting for your new tutral!! 新しいチュートリアルずっと待ってました!
@Sir_Isaac_Newton_
4 ай бұрын
I know some of those, I recognize Shi, Ri, Su'', Tsu, Te, Ma, Ta
love videos like this, would love to see more videos of you making some retro game clones :D
this is really awesome. Just finished following this over 2 days (!) I have found this really good in writing my own projects using your code as a template for how to do things the right way! Many thanks - I look forward to seeing more excellent content.
Gonna give this a go after I make more progress on your Java adventure game. Thanks!
@RyiSnow
8 ай бұрын
Happy to hear that!
This looks way more fun than using a Game Engine. And not only that its more fun, but its a great way to learn more cause its so challenging ! Amazing work Ryi .
This is awesome, thanks for the new vid!
Thank you so much for this video. You've inspired me to study programming on my own. I don't know if I ever make a career out of it, but I really like it as a hobby :) Keep up the good work, RyiSnow!
I can't thank you enough for these videos, you are an excellent teacher, plus I love your accent!
pls continue making this content... ur way of teaching is awesome.. specially inbetween topic/method explanation. thanks
Love your videos ! Keep it up !
Thanks for making these!!
Thank you very much. It's crazy that such legendary games can be so easily replicated in just few hours
As always, amazing vid man!
@RyiSnow
5 ай бұрын
Glad you like it! Gracias for the support🙏
BRO I JUST LOVE YOU !
loved this!
I thank you for making this code, it is very well explained and complete, greetings from Mexico!!! ❤️🇲🇽
I love it thanks !
Just finished following the tutorial series about a few minutes ago. I just want to say thank you RyiSnow for providing these awesome videos and tutorials! You're one of the main reasons why I love the Java programming language 😁 Additional note for those using IntelliJ, you can simply create the "res" Folder as a Directory and then update it into a "Sources Folder" inside the Module Settings or Project Structure menu. And another issue I ran into was with the White-Labyrinth-Active BGM. I don't know why it couldn't be accessed by the AudioInputStream while it was in mp3 format, so I just changed it into wav format and everything worked perfectly.
@allanbranson4693
4 күн бұрын
can i please see your code files? on git?
You're so awesome man.
I picked up Java as my first computer language and I can't thank you enough for these tutorials. You are literally the best Java teacher on KZread. А еще меня заставили: Ю хев ошибка Ин ер коде
LOVE your videos! I have a quick question though... what font are you using? lol
so that is a great video thanks a lot.
I love your videos, and have been working on your 2D Game tutorial and want to make a video walking through it. What screen recording software do you use?
Awesome video, as always! I am glad you enjoyed coding Tetris. You are incredible, Ryi!
Thanks RyiSnow, you are Awesome..:)
Welcome back king❤
love it
PlayManager class 68 line: While the value is 7, Mino Z2 does not fall out, if you change it to 8, then everything works, since now we take into account 0 and count from 0, not from 1
Been looking for a good reason to use Java again
ur the best ytber i ever know
Thanks
Your are the best
Beautiful Video. Keep Coding. Also please complete Rayndia. I wish we could see the final result one day.
@RyiSnow
8 ай бұрын
I will most certainly complete Rayndia! I've been working on it behind the scenes and hopefully release a demo next year :D
the GOAT
thanks... Amazing video!
Actually, you should put the "repaint" method outside that if. You should update in every possible moment, it's good to limitate the update but the render should be outside.
Hello, could you tell me what application are you using to code in java? (I'm new to programing) Also, how much time did it take to you to make it?
Hi, why are you using eclipse and not intelij ?
I finally finished this tutorial, the end result looks really cool! When testing the Sound class at about 1:26:12 I kept getting a null pointer exception for the Clip object, which seemed to indicate the file paths for the wav files weren't being read correctly. After checking the Sound class for typos and not finding any, I eventually figured out that the res folder wasn't included as a resource in the project's build configuration by default. If anyone runs into this situation while using Eclipse, the steps I took to fix it are: 1. Right-click on your project in the Project Explorer and select "Properties" 2. Select "Java Build Path" from the menu on the left 3. Click "Add Folder", check the "res" folder in the window that pops up, hit OK, and then "Apply and Close". This allowed the res folder to be recognized, stopped the null pointer exception and now music & sound effects play perfectly. :) It's kind of weird because I've never had this issue before. I could always just create a folder, add the sound files and it would work without any extra steps just like it did in the tutorial. So maybe it had to do with me recently moving my projects around on my hard drive? I'm not sure. Anyway, thanks for another awesome tutorial, Ryi. I'd love to see more tutorials for classic games like this. I appreciate your hard work.
@RyiSnow
7 ай бұрын
Or you can directly create a resource folder as I did in the video! 1:21:06
@current_goliath
7 ай бұрын
@RyiSnow OH woops, I thought I followed what you did at that timestamp exactly, but turns out that I selected "Folder" instead of "Source Folder". That explains it. 😄
This is timeline for my own studying 44:55
hey @ryiSnow. i've been following your code very carefully but at doing the auto drop part when i tried calling the gp.launchgame, i dont see any blocks falling but before i call the gp.launchgame its just floating and not moving just like yours.
Hey! I've ran into an issue, I tried adding a 1x1 mino, but it didnt work. I tried putting all 4 cubes in 1, but then the line breaker didn't work, then I tried just removing other 3 parts, but then it had some bugs. Could you please help me?
hey bro nice tutorial! keep it up, and can i ask you a favor? can i get the source code of this project?
can you please tell that how did you change the color theme of netbeans. which one is yours?
can you build snake game next?
thank you!! pls how to make 2d platformer ... You are the best person to explain game programming using Java
@RyiSnow
8 ай бұрын
Check the @KaarinGaming channel! He did a nice 2D platformer tutorial series ;)
@samg5183
8 ай бұрын
Thank you.. but your explanations are good and easier for beginners@@RyiSnow
@user-Red_Haired1984
7 ай бұрын
@@RyiSnow His tutrials are good, but his pace of explanation, wiriting, scrolling are too fast so its hard to chatch up for beginners.. I hope your version of platformer tutrial too!
at 13:01 I have written the code as it is but instead of a white border my whole window is turning white...how can I solve this?
How would you go about approaching a cutscene intro animation - before a game starts? Mega-Man
how would you implement holding a tetromino function?
hi how to ocreate a menu for this game?cam you put a tutorial for that?
can you do a multiplayer game next one 🤔
ia have a question, in this tetris there is just one thread right?
Hey nice video !! I'm using your video for training my java haha. But i'm stock because I use intelij. Is someone here using intelij ? because at 5:29 you telling us to add unimplemented methods but can we do that on intelij ?
@RyiSnow
7 ай бұрын
If it doesn't show up in your environment, you can manually type the run method. I just used the auto-fill function of Eclipse. I'm pretty sure IntelliJ also has a similar function though.
@gandalflesuisse2
7 ай бұрын
@@RyiSnow thank you :) but I have an other bug. I check all of my code but I dont found the bug... the left, top and right colision of the static mino's are OK But the left side have no colision. I review the chapiter colision but I didnt found any diffence btwn my code and your code. can you help me pls ?
why does mine say cannot read field "x" because this.b[0] is null am i missing something
2:12 I am getting NullPointerException for // window.setLocationRelativeTo(null); // please tell how to fix Exception in thread "main" java.lang.NullPointerException: Cannot read field "x" because "p" is null at java.desktop/java.awt.Component.setLocation(Component.java:2191) at java.desktop/java.awt.Window.setLocation(Window.java:956) at main.Main.main(Main.java:17)
Theres no error when i run it but the collision didnt work for me i checked it many times i cant see why it wont work
how come yours mino is moving and rotating fast and mine is so slow?
hi snow i cannot get the sound part in my project
Can you do a 3D game from scratch?
Hi Ryi, thank you very much for this video. I am having some trouble though when creating the first mino. When running the project, it returns the error: Exception in thread "main" java.lang.NullPointerException: Cannot assign field "x" because "this.b[0]" is null. Could anyone help me please?
@RyiSnow
6 ай бұрын
Sounds like the mino or the b[0] block hasn't been instantiated. I'd recommend you check the line of code that was suggested in the error message.
@juliennepper6150
6 ай бұрын
Thank you, I found a solution, checking the rest of the video now :-)@@RyiSnow
The collision part doesn't work. I've rechecked it, nothing seems to be wrong
good video please keep going
Thank you so much for the video ❤❤ but the static boolean variables upPressed,downPressed... doesn't work in the class Mino(KeyHandler.upPressed...) please inform me to solve this problem
@RyiSnow
4 ай бұрын
Could you be more specific? Just saying "it doesn't work" doesn't give me any clue to guess your issue/situation. More context would be appreciated!
@melouka3
4 ай бұрын
@RyiSnow the code now is correct until the sound but in execution stoped the score and level and next are displaying but the mino doesn't move
Can you make a Pokemon game in Java ?
Help mine still go out the box but my codes are right
What Text-Editor is This?
@user-sh3zt5nl7f
8 ай бұрын
Eclipse
@dirtyfrk
8 ай бұрын
@@user-sh3zt5nl7f which font he code?
hmmm, do you like Game Engine like unity or Unreal engine?
@RyiSnow
8 ай бұрын
Yes (well maybe not Unity anymore though...), but I also like coding from scratch.
@uchihaitachi7964
8 ай бұрын
@@RyiSnow That's awesome
can you share the code files? i am lost somewhere
Do you have a github that i can follow you?
Hey Ryi! I wanted to know if you could do a candy crush on java, im studying computer science in Argentina and that is my class first proyect for this semester. Im actually really stressed and nervous about it so it would be the best of helps and reliefs if you could do it. Thank you and I love your videos
Bro how you not a google employee yet
can i try to do this whit intellij idea?
@RyiSnow
3 ай бұрын
You can!
@afrog5622
3 ай бұрын
@@RyiSnow ty, ill try it then
At 22:02, when I type in Block.SIZE, it shows an error that it cannot find symbol variable for Block. In the mino class I did make it a public array, so not sure why its not finding the symbol. Otherwise, great video so far!
@mp3skater940
7 ай бұрын
maybe it's not static.. do you have it like: "public static final int SIZE = 30;" this?
am tilted, its not working,idk
17:39
日本人ですか?
@RyiSnow
6 ай бұрын
はい
@zel9219
6 ай бұрын
@@RyiSnow 色々教えてくれてありがとうございます!これからもよろしくお願いします!
ok i did something wrong, mine turned white xD ahahhahahahha
thanks... Amazing video!