Learning Pygame by making Pong part 3 - Improving the collision mechanics and adding sound

Поділитися
Вставка
  • Опубліковано 21 січ 2025

КОМЕНТАРІ • 53

  • @yussefhallak981
    @yussefhallak981 4 роки тому +20

    hey! I started watching your pong game series yesterday and finished the first 2 parts, and it was such a surprize that you posted another one thank you so much you really explain everything so well and I learned a lot from you, you are so underrated and I don't know how you still dont have more than 100k subs keep up the work and you will reach it someday. Can you please continue this series in like adding difficulty and a timer that counts how much time you are in the game playing, maybe a main menu with game modes like a one that you can move the player left and right... I would really appreciate it and if you make this game as much as its basics are simple a really cool game it will help grow your youtube channel a lot and maybe after you finish pong you can create others like snake and much more. Thank you again for this amazing videos

  • @kew3088
    @kew3088 4 роки тому +6

    Hey! I really wanted to leave a comment here since you really deserve some feedback for the effort you put into your videos.Been playing around with some python for a while and thought it would be cool to use pygame to learn some basic stuff before diving into machine learning. Went through the docs of pygame a little bit and decided that i am way to lazy to go through it all by myself yet so i went on youtube and found your videos.I really want to say that i really like the way you explain and especially the way you visualize the abstract concepts. If you go on like that im sure you are going to have alot of followers soon.I am an experienced java developer by the way.You're doing a great job there!Chapeau!

    • @ClearCode
      @ClearCode  4 роки тому +1

      Hey thank you so much. Always happy to hear kind words! :)

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

    Really appreciate this - I was trying to figure out my pong collisions with the top and bottom, and this helped a lot in my understanding! I added some changes in mine so it wasn't just a threshold and wouldn't repeatedly collide with anything.

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

    Thanks, the sound really adds to the game.

  • @raghuveershinde5728
    @raghuveershinde5728 3 роки тому +1

    I didn't understand code at 5:19
    if abs(ball,right -player.left)

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

    Thank you so much! Your video helped with my Pong game collision

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

    How can you change the direction the ball goes to after every hit? How it's always the same Is there a way?? Please??

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

    Had to use winsound for the sound. Pymixer was giving me problems. Awesome lesson!!

  • @munjolla
    @munjolla 4 роки тому +1

    Great tutorial. Thank you very much

  • @learningpythonaccount3909
    @learningpythonaccount3909 4 роки тому +1

    So underrated

  • @ladiyehl
    @ladiyehl 22 дні тому

    Thanks bro you're the best

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

    thank you man.well done

  • @qqlez
    @qqlez 3 роки тому +1

    you can also do pong_sound.play() instead of pygame.mixer.Sound.play(pong_sound)
    :)

  • @manasmj
    @manasmj 3 роки тому +1

    U R GOD OF PYGAME FOR ME !!!! LOVE YOUR CONTENT :)
    who thinks he will reach 100k very very very soon ?!

  • @randomsregime1803
    @randomsregime1803 4 роки тому

    Hi, how do I make it so that the opponent ai paddle moves once the bot is above/below the middle of it instead of the ends? Thanks

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

    Can you please tell me how to put a picture or a sound in the same directory of my code I use pycharm community edition and been trying to solve this problem for almost 2 weeks, I tried a lot of methods but none worked. Also, I don't know if its a mistake but thelink in the description leads to a video about surface laptops

    • @ClearCode
      @ClearCode  4 роки тому

      Hey, thanks for letting me know, fixed the link. And not sure what you mean about the directory. all you need to put all the files in the some folder in the file explorer.

    • @yussefhallak981
      @yussefhallak981 4 роки тому +1

      @@ClearCode I tried everything and I am using only one sound
      its still not working I use this code{pong_sound = pygame.mixer.Sound("pong_pygame.wav")}
      I named my file pong_pygame.ogg this problem also happens when I try to put a bg image it gives FileNotFoundError or sometimes cannot open file can you please help me I tried everything!

    • @ClearCode
      @ClearCode  4 роки тому +1

      for the sound file the solution is quite easy, when you import it you need to add the proper file ending, so the line in python should be: pong_sound = pygame.mixer.Sound("pong_pygame.ogg") so the use the file ending ogg instead of wav. Maybe doublecheck all the names?

    • @yussefhallak981
      @yussefhallak981 4 роки тому +1

      @@ClearCode Thank you so much it worked been trying to solve this problem for weeks, the problem just wasn't correctly putting it in the same directory!

    • @ClearCode
      @ClearCode  4 роки тому +1

      @@yussefhallak981 well done :)

  • @Rakhu-e2f
    @Rakhu-e2f 4 роки тому +1

    why u have put 10 in collision part

  • @edwardchen4447
    @edwardchen4447 4 роки тому +1

    I have a problem, I couldn't download the files, could you please do a tutorial on downloading them?

    • @ClearCode
      @ClearCode  4 роки тому +1

      just click on clone and then you can see a dropdown menu; in there click on 'download zip' and then it should download all the files. I think it would be a bit overkill to do an entire video on that.

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

    Hey, thanks for all this great content. I was mid way through making this pong game when it came to my mind if there is a way to change the ball's color when it collides with the player and the opponent. For example, the ball would turn red when the opponent hit it and blue when the player did it. I've been trying to do it but can't achieve it. Hope you can help me with this and once again, thanks for everything!

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

    For some reason I'm having the hardest time incorporating the sound file into the game. Maybe I'm not as familiar with pycharm and importing files (I'm very new to programming) but every time i do it comes up with an encoding error

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

      what's the error?

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

      @@ClearCode the file was loaded in a wrong encoding: 'UTF-8'

    • @ClearCode
      @ClearCode  3 роки тому +1

      @@thenamesloca okay, that is a strange error, can you upload the entire thing to github or something? Then I'll have a look. Afraid I haven't seen that error message before and there doesn't seem to be much on it online. You got very unlucky, sorry :)

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

      I'll do that! Thank you so much!

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

      @@ClearCode Sorry for the delay. I'm new to this all and github as well but I've uploaded my files to github. Please let me know if I should change how I uploaded for easier look over. I'm learning all of this as I go so sorry for the chaos. My user name is everydaySeidr and this is the upload github.com/everydaySeidr/beginner-pong.git

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

    I know this video is old but I thought Id share some issues that I had that may help some others. If your file gives you pygame.error: cannot open file 'pong.ogg', I was able to fix this by changing them to .wav files.
    Not sure why, perhaps something to due with the encoding or limited frueqencies of the OGG? not an audio guy tho so could be wrong. Regardless, hope this helps someone.

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

      Helped me. .wav is the way! Edit: I also didn't have to change the buffer when using .wav. Why even use a weird .ogg file when .wav just works?

  • @markus808
    @markus808 4 роки тому

    Where can I get the sound files?

    • @ClearCode
      @ClearCode  4 роки тому

      Hey, sorry about that, forgot to add the GitHub link: github.com/clear-code-projects/Pong_in_Pygame

    • @markus808
      @markus808 4 роки тому

      @@ClearCode Thanks!

  • @szabadosdonat4506
    @szabadosdonat4506 4 роки тому +1

    why did you thange the theme to light? :'( my eyes are burning...
    jokes aside , I really love this video/series, keep it up!

    • @ClearCode
      @ClearCode  4 роки тому +3

      sorry about that... I thought that the light them with dark text was a good contrast and helped readability. But I changed my mind really fast after doing some editing in the evening, newer tutorials are better with that :)

  • @mitchellfolbe8729
    @mitchellfolbe8729 4 роки тому

    Great stuff. A few suggestions. I was unable to download the sounds from github; it didn't work on chrome and "file not supported on microsoft edge". Also, can you show us how to end the game with a winner? Finally, you used a lot of global variables and you said that was bad form. Can you show us a way to code it without the global variables?

    • @ClearCode
      @ClearCode  4 роки тому

      Hey, I am working on more tutorials on the pong game, should be ready next week. I am not sure what the problem with github is, I'll check it tomorrow.

  • @learningpythonaccount3909
    @learningpythonaccount3909 4 роки тому

    Thanks

  • @kaido5412
    @kaido5412 4 роки тому +1

    Bro dont reply to the comment "wanna be friends" , that channel is a hacker

    • @ClearCode
      @ClearCode  4 роки тому

      Don't worry, my parents raised me well to not talk to weirdos on the internet :)

    • @kaido5412
      @kaido5412 4 роки тому

      Lol nice, and yeah your content is good👍

  • @keesdenuil5862
    @keesdenuil5862 4 роки тому

    hey! I can't download the files of the sounds.. Do you know how I can use them?

    • @ClearCode
      @ClearCode  4 роки тому

      Hey, how do you try to download them? I just tried to download the entire project folder and that works fine.