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

КОМЕНТАРІ • 43

  • @jettaeschroff6924
    @jettaeschroff6924 3 місяці тому +1

    jesus christ the sound effect at the end made me jump out of my seat

  • @zierasecundario8952
    @zierasecundario8952 2 роки тому +4

    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!

  • @danielbrandtaborda9935
    @danielbrandtaborda9935 3 роки тому +3

    Hey man, congratulations for that amazing job! It was very helpful.
    Greetings from Colombia.

  • @primenumber349
    @primenumber349 2 роки тому

    Thank you for teaching me this excellent code! Finally, I made it through your tutorial.

  • @reallo1753
    @reallo1753 8 місяців тому

    I was late with my first semester project, you saved me 7 credits, ty :)

  • @TBird136
    @TBird136 2 роки тому +9

    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

  • @onlysukii
    @onlysukii 3 роки тому +5

    this is fire (tho i had to force my fingers to go 1000mph to catch up)

  • @philtoa334
    @philtoa334 3 роки тому +2

    ok nice job , i try to do this game , thank you : )

  • @OOO-mn1ds
    @OOO-mn1ds 2 роки тому +4

    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

  • @flamechain9113
    @flamechain9113 3 роки тому +2

    nice tutorial

  • @silverlox2858
    @silverlox2858 3 роки тому +3

    the code is different in the GitHub then in the video

  • @azadar2289
    @azadar2289 Рік тому

    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')

  • @pattyx5743
    @pattyx5743 2 роки тому

    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

    • @user-md5lz2xq5i
      @user-md5lz2xq5i Рік тому

      Helpline📲📥⬆️
      Questions can come in⬆️

  • @chinkilagabombo4056
    @chinkilagabombo4056 3 роки тому +2

    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?

    • @daniel_chang2002
      @daniel_chang2002  3 роки тому

      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()

    • @chinkilagabombo4056
      @chinkilagabombo4056 3 роки тому

      @@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.

    • @daniel_chang2002
      @daniel_chang2002  3 роки тому

      @@chinkilagabombo4056 Good to hear, good luck

  • @smolbeanaria
    @smolbeanaria 2 роки тому +2

    When in doubt, if your code isn't working . . . did you remember to reference self?

    • @smolbeanaria
      @smolbeanaria 2 роки тому

      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!

    • @daniel_chang2002
      @daniel_chang2002  2 роки тому +1

      @@smolbeanaria Haha, yea, this was a fun project

  • @mihuhih2186
    @mihuhih2186 2 роки тому

    next episode maybe minesweeper solver? : )

  • @Exynoss1
    @Exynoss1 6 місяців тому

    How can I save it as video or jpeg?

  • @cuppyquake6133
    @cuppyquake6133 Рік тому

    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

    • @SAFBF
      @SAFBF Рік тому

      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.

    • @cuppyquake6133
      @cuppyquake6133 Рік тому +1

      @@SAFBF ill try that, thank you!

    • @user-md5lz2xq5i
      @user-md5lz2xq5i Рік тому

      Helpline📲📥⬆️
      Questions can come in⬆️

  • @jhudielbongcalos6951
    @jhudielbongcalos6951 2 місяці тому

    what IDE did you use?

  • @twinstar6247
    @twinstar6247 2 роки тому

    Which keyboard😂😁

  • @Subhash6666
    @Subhash6666 Рік тому

    Minesweeper hack

  • @Standboard
    @Standboard 2 роки тому +2

    could you speak louder i cannot listen to you with my mics maxed out

  • @bcgamer2
    @bcgamer2 11 місяців тому

    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...😥

  • @metaphyzikal1
    @metaphyzikal1 2 роки тому +2

    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?

    • @daniel_chang2002
      @daniel_chang2002  2 роки тому

      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