How to make PAC MAN game in Windows Form and C# with Visual Studio
HTML-код
- Опубликовано: 12 сен 2024
- Download images here - www.mooict.com...
In this tutorial we will be making a simple pac man game in visual studio with Windows form and C#. In this game we will control pac man in 4 different directions. Up, down, left and right. In the images you will find a GIF to represent all 4 directions. You have 4 walls and 3 moving ghosts in the game. The main objective of this game is to, collect all of the coins and not touch the ghosts or walls. IF you do then the game is over.
3 Ghosts in the game will have their own movements and collision with the walls and the player. This process will give you an idea of how to program standard AI inside of a game and you can use the same process in other projects.
We will learn how to make this together by adding of the elements manually and then writing the c# script animate and logically progress through the game.
Instead of removing the elements from the form this time around we are using a different approach. We will show you how to make a component invisible in Windows Form once you have interacted with it, and gain a score from it.
Hope you have fun with this one, and keep making stuff it really doesn't matter what it is long as you keep at it you will only get good at it.
Moo out.
Download this project here github.com/mooict/Pac-man-game-tutorial-in-windows-form
I have to make this game as homework , and as a starter this helped me a lot, lot lot.
Still I needed something a bit more complicated with the ghosts, they're supposed to do a different task each, im still figuring that out!
Thank you a lot!!
You really helped me a lot!! Thank you so much!! I've learned a lot of things thanks to you!! :DD Good vibes to you wherever you are!!!
Thank you for the kind comment. I’m glad this tutorial was helpful 😊
Thanks dude, up helped me so much on learning about "How to use foreach"... Thank you so much ~~~
Thank you for the video, good and simple manual.
what a video thankyou so very much, u saved my coursework
Glad it helped
I love this video ❤️
Thanks. Done it. Next stop jet shooter.
thank youu
Your training was perfect.....
I wish you success^^
I’m having problems with my program. It keeps saying there is an error when I write private void reset game. Also I cannot properly move Pac-Man around. I do not know the problems I’m having as I have followed all of your steps. Any help?
Nice!!! Good Work
Thank you im glad you like it. Let me know if you want any other tutorials
Thank you! the best game tutorial in my life)
thank you sir you teach me how to create a game using c#
How can I make this a 2 player game by making one of the ghosts move using the wasd keys?
I have a question i desigend the form loike you did but when i debuged the game pink and yellow ghost werent in thier place and i didnt finish the code at that time
Very good game
ty
'KeyPressEventArgs' does not contain a definition for 'KeyCode' and no accessible extension method 'KeyCode'. It seemss to be fine in keydown but not working in the keyisup function?
Add a key up event to the form instead of key press event. Key press event do not support key code
@@mooict thank you!
Thankyou just made this for small project :) Best tutorial!!!!🫶🏻🫶🏻❤️
Glad it was helpful!
How do I make PacMan stop when it touches the wall instead of the game ending?
I'm currently working on the new pac man tutorial with wall hits. Still a work in progress ☺️
@@mooict I found a way to do this, but it takes a long time.
Noice well done 👍
@@mooict Thanks
Can somebody help me with this please?
I love this video 🖤
Game over label is not come when the game is over and in the code u gave there is no reset and game over function in the written code
God work !!
Thank you. Glad you liked it. I'm working on WPF C# version of this at the moment will be up soon hopefully
@@mooict great, I'll be waiting for you
(postscript I am Bolivian, forgive my English)
I can't get my ghosts to slow down :/ they bump against the walls but really really fast, they are set to 1 :( and they are still not slowing down... any suggestions how I can fix this?
OMG I fixed it it doesn't matter! haha check those curly braces everyone!!
Thx bro
please can you make a video of how can make the coins make a sound we pacman collect it
Hi, I've done a video on how to play different sound files in windows forms on the channel. That should help you on how to include sound to this type of game.
If you can help, the yellow ghost is moving from picturebox 4 to the right, instead of picturebox 3, how can I fix it?
Thanks ☺
Check the name of the picture box 3 and 4 in the property window. If it’s James differently you can change it in the code.
I have a question... Why do you use pacman.Left
( if (goleft == true)
{
pacman.Left -= playerSpeed;
pacman.Image = Properties.Resources.left;
}
)
and pacman.Top
( if (godown == true)
{
pacman.Top += playerSpeed;
pacman.Image = Properties.Resources.down;
}
)
for pacman's movement and not pacman.Right or pacman.Bottom?
I mean if he goes bottom, why don't you use pacman.Bottom ?
I should have used the bottom and right at the time but I didn't because I got used to programming similar apps on JavaScript before this. So I think my old practice just translated to this one. You can use picturebox.Bottom and pictureBox.Right easily to achieve the results you need for your projects.
Muy buen juego
is this game made with object-oriented programming ?
No I haven't used OOP in this example
is this applicable for 2010?
Yes it is
hiii my pacman is not moving why please help
in the main game timer part it is telling me resources does not contain a definition for left, right, etc
It means the pictures in your resources are called different than left right etc. You can open the resources and rename the pictures to fix this issue or just call them as they are named in there.
@@mooict thank you, so far you're my favorite person on the internet to help me with game dev
Could you please made this into console.app visual studio?
When i try to write "pacman.Left" (14.05) the Left part turns red, why is that? And the same thinga applies to pacman, but i added him to the int part but idk if that is correct :/
The pacman is name of that picture box. Integers don't have left or top properties. Name the picturebox pacman in the form and then you can access left and top properties of the pacman.
My pac man doesn't eat the coins and the score doesn't work. What can I do?
Hi, check the tags for the coins and make sure its the same as the tutorial.
@@mooict Thank you, it worked!
What is the template. Visual Basic or Visual C#?
This is C# .Net Framework
I have a problem when i press arrow to go its doing it job,but when i put my finger off the arrow or i change direction game restart it self
Check the key up event from the tutorial. I think it's restarting the game from any key release instead of enter key.
@@mooict thanks,nice contect i like it so much.Will u make a video how to make levels in this game?
@@urosgojak9317 you can add more levels by inserting new form to the current project in the solutions explorer. From there you can make a new level and load it when the current one has been passed.
i always wanted to make Creeper Eats Ghosts
And now you can. More power to ya
AW MAN
i made a maze and put coins all over the maze (now my hands hurt)
the coins are not disappearing 😭😢
The character won't move and the code doesn't seem to have any errors.
Check if the key down and key up events are linked to the form. You can do this by going to the events window inside the properties.
@@mooict They are
@@aidanacero4912 are the ghosts moving in the game?
@@mooict I haven't added moving ghosts yet and in the game I'm making they are sharks and yes I have added my own names in the code and not ghost and Pacman names.
@@mooict BRUH I JUST REALIZED IT WAS BECAUSE I HAD A CUSTOM WINDOW BORDER
What version of Visual Studio are you using?
2019 version
My pacman is not moving :(
Neither do the ghosts
Hi have you enabled the timer?
@@mooict Yes
@@noonecaresbish check if the timer event is linked to the timer and the key down and key up are linked to the form.
@@mooict I solved the problem 😄
Is this an Asmr
It can be 👍
@@mooict 😂😂😂😂 yeah
Btw should i understand visual studio fully before starting unity?
@@shubhsanganeria9483 no you don't have to, it's C# you will need to be familiar with to use unity properly.
@@mooict oh kk thanks👍👍😄
"coins"
lol coins u should put dots
Animated coins look better but I get your points. Dots would have much more optimised for this game but look how shiny they are 😂
yeAh coins have animations and dots do not have AND THE cOiNs ArE sO sHiNy
and is the size of the window really cares like can i use something random instead of what you used
AND WHY MS PAC-MAN
@@shilperwork9755 why are you being so rude for