Python/Pygame Minesweeper Tutorial
Вставка
- Опубліковано 5 сер 2024
- Minesweeper clone created with python using the pygame module.
Works Referenced:
www.pygame.org/docs/genindex....
Code:
github.com/danielchang2002/Py...
0:00 Setting Up Pygame
2:54 Making Board Class
5:43 Loading Images
14:46 Piece Class
20:46 Getting Number of Mines Around
29:13 Click Handling
39:22 Recursive Click implementation
42:00 Finalizing getImage
44:25 Win/Lost State
46:40 Finished Product and Pro Gameplay
jesus christ the sound effect at the end made me jump out of my seat
Thank you so much! I was in search of an easy pygame project to just mess around and learn, and your vid was of great help!
Glad it helped!
Hey man, congratulations for that amazing job! It was very helpful.
Greetings from Colombia.
Glad it helped! Greetings from Minnesota
Thank you for teaching me this excellent code! Finally, I made it through your tutorial.
Thanks Prime Number, glad it helped!
I was late with my first semester project, you saved me 7 credits, ty :)
Some things you could improve in the future:
- If you want to speak in your tutorial, make sure you make your mic louder next time
- you should structure your tutorial. You jump between the different classes to define methods you use elsewhere but haven't defined yet, what makes it kinda difficult to follow your line of thought. (It also makes using chapters useless as well)
- You're really fast. What is cool per se but makes following along rather hard. That's just something minor, there's also a pause button for a reason
Still a good tutorial. Everything works as intended
this is fire (tho i had to force my fingers to go 1000mph to catch up)
Glad you liked it!
ok nice job , i try to do this game , thank you : )
You are welcome Phil Toa, good luck
I made my own in 4 days without even knowing what a class was 😂😂 it was fun but also the code is not really good (on the bright side, mine had a Cat Mario death animation and victory animation with the classic Mario Bros sounds). You code really fast, it takes me a lot of time of thinking before doing something like that, nice wotk
Good job! Glad you liked the video
nice tutorial
Thank you my friend
not
the code is different in the GitHub then in the video
I applied everything exactly, but when I do it as in 2.51, the screen does not appear, what could be the reason, I would be glad if you could help. (AttributeError: 'Game' object has no attribute 'run')
Is there a way to have it always start on a 0 tile like in regular minesweeper? sometimes im only given a number tile where i have to basically guess which tile doesnt have a bomb
Helpline📲📥⬆️
Questions can come in⬆️
I keep getting a key error when i try to load the "empty-block" images. I tried moving the image to the same directory as the py files and using other images but it can't seem to open any of them. Any clues?
A key error happens when you try to access the value of a key that doesn't exist in a python dictionary, so its possible that you aren't loading the dictionary with the 'empty-block' key? You could test this theory out by just printing out all the keys of it with .keys()
@@daniel_chang2002 The dictionary was empty because I swapped os.listdir for os.walk since when I use os.listdir it couldn't find the images folder. I had to put down the entire path. So far I'm halfway done and so far no issues. Thank you.
@@chinkilagabombo4056 Good to hear, good luck
When in doubt, if your code isn't working . . . did you remember to reference self?
Was losing my mind when pycharm was telling me getListOfNeighbors wasn't defined XD We all good now though, this is a fun project to work on!
@@smolbeanaria Haha, yea, this was a fun project
next episode maybe minesweeper solver? : )
How can I save it as video or jpeg?
Hey! This is a great video and im almost complete with it, but when i get to the point where you begin to flag blocks i get a "list indices must be integers or slices, not float" error when i try to flag a block im using pycharm on windows
I ran into the same issue. This error occurs when using python 3.x instead of 2.x.
In game.py, when self.pieceSize is set, it needs to have // instead of / in order to use integer division instead of float.
@@SAFBF ill try that, thank you!
Helpline📲📥⬆️
Questions can come in⬆️
what IDE did you use?
Which keyboard😂😁
Minesweeper hack
could you speak louder i cannot listen to you with my mics maxed out
Please do not call a video a tutorial if it has an educational value below 0 and please refrain from mumbling to yourself when your aim is clearly to explain things to your audience...😥
bro is mad about his skill issue
The github code doesn't work, there is a problem with the argv list arguments and I don't know how to get beyond that.
size = int(sys.argv[1]), int(sys.argv[2])
IndexError: list index out of range
can you help?
I updated the code so that you can give command line arguments to adjust the board size. Try running "python main.py num_rows num_cols", where num_rows and num_cols are integers