Code Snake Game in Java

preview_player
Показать описание
How to code a snake game in Java for beginners! Learn how to create a game of snake in Java using the awt and swing graphics library. Throughout the tutorial, you will learn how to create a graphical user interface (GUI) to display the Snake game, create the game loop, listen for Key presses to move the snake, use the ArrayList to store the snake's segments, and check collision and out of bounds for game over.

Setup Java with Visual Studio Code:

Java Game Programming Projects Playlist:

JavaScript Game Programming Projects Playlist:

Subscribe for more coding tutorials 😄!
Рекомендации по теме
Комментарии
Автор

Check out the playlist of web project tutorials here!



Got a tutorial suggestion? Let me know down below!

KennyYipCoding
Автор

This is just perfect videos for beginners that have learned the lauguage and how it works but needs to see how you use the code in easy small programs. There are tons of "learn how to program"-videos but with no usable examples. That is just like learning some chord on the guitar but no song to play. YT needs a lot more songs to play, like this. You also have a perfect voice for this and no messing around with side tracks. This is the equalivent to BASIC programs that you could find in paper magazines in the 80s. Just perfect! Keep them coming. Thank you.

hansmalm
Автор

Thank you for the opportunity of coding a snake game, it was very beneficial to my coding journey as a student an I do look forward to future projects. You made my entire week awsome.😊

dillonpaul
Автор

The way u explanation for use of each line of code is ❤❤❤ best i have ever seen, thanks you

hnudj
Автор

Great tutorial, thanks for the clear and concise logic.

current_goliath
Автор

thanks for explaining all the complicated parts! really helped me out a lot!

tuxat_
Автор

Thank you so much TTTOTTTT i really needed this for our final project

babymonster
Автор

i love your videos you are taking me to the next level

plandr
Автор

Thanks! you have a knack for story telling, which is good for in this line of work (media).

VietNguyen-vjsu
Автор

I'm so grateful for your videos! It's so much more fun learning Java when there's some GUI and fun games your working with. I've been slowly learning Java for the past year now, but it's all CLI apps in every tutorial. I'm following your tutorial now and I'm learning so much from them, but I know I'll be coming back in a couple of month and do them all over again when I know even more and probably understand even more of all the things your doing.

I just wish you could explain even more of what your doing and why. For an example:
why do you need to add "true" at the end when you're changing the tiles for the snake and the food from 2D to 3D?

Keep up the good work and I promise to recommend this channel to all my classmates (I'm currently studying QA-testing and were using Java)

BabyBunny-Cottontail
Автор

I followed your tutorial on how to code a snake game in Javascript, I think Java is harder but let's see 😁❤️
Thanks for your videos 💙

sammo
Автор

Thank you so much bro finally i made snake game 😊❤

stevensaleh
Автор

Obrigado que tutorial incrível, ficou muito bom esse jogo. Assisti vários vídeos de como criar um jogo da cobrinha, e eu percebi que existe várias inúmeras maneiras de fazer um jogo mesmo sendo parecido, más com instruções diferentes, Obrigado vc explicou muito bem .

damiaotiktok
Автор

I have a question, if i press two directions at the same time when going the opposite direction, it bugs out and ends the game, how do i fix this?

HospiceCarlTaneo
Автор

First of all thank you very much for this tutorial! Apreciate it!
I have a dual boot machine, I tried this tutorial first on Ubuntu and it didn't work, it didn't open the window when I executed the program on 3:44, then I switched to windows 10 and it worked fine.
Do you think is there something wrong with my machine or with how I installed java on Ubuntu? Or does this code doesn't work on Ubuntu?

luuhgentile
Автор

The grid isn't showing up. There are no errors as the program runs. I'm not sure if its because im on a mac and hes using windows but the program produces nothing when I run it.

obieosuji
Автор

Question: Why do you need to declare all the stuff for the frame. and then declare stuff again in another class so it can be drawn on?

noahfeazell
Автор

the best snake video on entire you tube

_I_like_kebeb
Автор

Tks for the video, but I get bug: when i press left down right sequence fastly, game over.
Can u fix that, it happen when score is greater than two

hyf
Автор

That was very good tutorial i learned alot by following along and tweaking! I just have a quick observation regarding the draw(Graphics g) function you created for both the snake and the food graphics. Coming from JS i find it so odd the behavior of both the .setcolor and .fillRect methods, because at first I was so confused of how these methods were targeting the desired tiles but then i figured it out after reading the docs, apparently all subsequent graphics after .setColor will be drawn with said color until specified otherwise. It just seems unecessaribly verbose if I wanted to generate a more complex pattern but i guess thats just Java.

Sweet_Solos