Code Pacman in Java

preview_player
Показать описание
How to code pac man game in java. In this tutorial, you will learn how to code pac-man using java awt/swing graphics.

Throughout the tutorial, you will learn how to create the game loop, create a jframe and jpanel, draw images on the jpanel, load the game map using a tilemap, add click handlers to make the pacman move, create a simple algorithm to move each ghost at random, detect collisions between the pacman and ghosts, have pacman eat the food pellets, add a running score, and reset the game when pacman collides with a ghost.

Setup Java with Visual Studio Code:

Java Game Programming Projects Playlist:

JavaScript Game Programming Projects Playlist:

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

//X = wall, O = skip, P = pac man, ' ' = food
//Ghosts: b = blue, o = orange, p = pink, r = red
private String[] tileMap = {

"X X X",
"X XX XXX X XXX XX X",
"X X",
"X XX X X XX X",
"X X X X",
"XXXX XXXX XXXX XXXX",
"OOOX X X XOOO",
"XXXX X XXrXX X XXXX",
"O bpo O",
"XXXX X X XXXX",
"OOOX X X XOOO",
"XXXX X X XXXX",
"X X X",
"X XX XXX X XXX XX X",
"X X P X X",
"XX X X X X XX",
"X X X X X",
"X X X",
"X X",

};

Completed code with sprites:

KennyYipCoding
Автор

Fantastic video man, just coded along with the video. The walkthrough was very smooth and great explanation. Loved it

I'm thinking to add an 8 bit audio, powerups etc, it was real fun

neverexperience
Автор

This channel is amazing! I've just started learning Java and your channel has been really helpful

MarkE-mpli
Автор

You're the goat man! I love all your videos!

CaioSantos_p
Автор

hi! great tutorial that was very efficient thank you so much!

ps: at 20:45 you said you would put the map code in the video description and i think you forgot ;)

lokaam
Автор

Thanks for your videos! They are amazing :)

nnalife
Автор

kenny, is any datastructure used in that project???

HarisKhan-ibs
Автор

bro, your work is amazing, but can you please help me with something? everytime i save my project some lines in the code gets deleted and i dont know why. Ill apreciate it if you can help me

stefangrigore
Автор

Hey can you tell me which platform you are using for coding?

excujeeme
Автор

Can i ask what are the sizes of the pictures that you used on this game?

johnmichaelocado
Автор

9:00 Why did u add private to all of them?

lila
Автор

Can you tell me the name of the app you used here?

SajithaUdesh
Автор

bro while trying to run the code after 27:40, the following error is showing :
exception in thread "main" Cannot invoke because "location" is null
at
at
at
i have tried changing the path if the images, but still not working . i am using eclipse ide. can u help me further in this plz ....

adityamukherjee
welcome to shbcf.ru