Make Pong With Python!

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 พ.ย. 2024

ความคิดเห็น • 163

  • @wearegeek
    @wearegeek 2 ปีที่แล้ว +68

    Hey Tim. I just recently discovered your channel and I must say I'm very impressed with your hands on tutorials. I'm working for a non-profit organization that helps people with a psychiatric background to rehabilitate. A lot of the participants show an interest in programming and your content is very helpful to explore this. Well explained; bite sized; project based. Thanks man!

  • @jakemasters4361
    @jakemasters4361 2 ปีที่แล้ว +14

    Hey man, I don't comment too often but I felt the need to express my gratitude for all the great content. I studied C# years ago, loved it but got pigeon holed doing helpdesk work for 7 years and pretty much forgetting everything I'd learned. Almost a decade later I'm picking back up where I left off, discovering my passion again, and trying to get my foot in the development door professionally. Your channel has been a godsend. You have a natural talent for teaching and presenting information in a way that's easy to grasp. I've never been the type who learns much from just watching lectures. The guided tutorial format has always been best for me, and you've got some of the best I've been able to find. All the best!

  • @tobyokoi0909
    @tobyokoi0909 14 วันที่ผ่านมา

    You taught me way more than my intro to programming has, WAY easier to understand!! You're a life saver, fr.

  • @myhatmygandhi6217
    @myhatmygandhi6217 2 ปีที่แล้ว +5

    I did this as a complete beginner, literally know nothing about programming/coding. Just followed the video and did it using Pythons IDLE. Had to make 4 or 5 corrections along the way but is was pretty straight forward. Great video! Looking forward to learning actual fundamentals of coding online now, preferably in Python.
    Edit: Being able to programme AI in this game would be great too for a future video.

    • @TechWithTim
      @TechWithTim  2 ปีที่แล้ว +3

      I have a video on AI!

  • @user-do3pd1sk6c
    @user-do3pd1sk6c 2 ปีที่แล้ว +21

    I've missed your pygame tutorials! I find your tutorials interesting and especially the pygame ones since I started programming by making simple games, and now I'm learning pygame, so good job

  • @junealexissantos4341
    @junealexissantos4341 2 ปีที่แล้ว +17

    Tim, you are the best. I'm just a python beginner and I understand everything you taught here. Keep these kind of content going man. You're a legend.

  • @Lahmeinthehouse
    @Lahmeinthehouse 2 ปีที่แล้ว +13

    Hey Tim! Great video, just one tip:
    Did you know that you can place the mouse location at multiple places AND do the exact same commands?
    So if you want to change left_paddle , left_paddle and change that directly to right, you can hold CTRL, click at the end of the words in BOTH variables, backspace and then write Right. This makes you able to change and write the same thing multiple places.

  • @salimmohammed1016
    @salimmohammed1016 ปีที่แล้ว

    Hey Tim. I dont have programming background except for seeing a few videos on python. I had visual studio code on my pc. I saw the first few minutes of the video and I installed pygame using the code given and then copy-pasted the code you attached and now I am playing ping on my pc. I am done within 10 minutes. Thanks a lot.

  • @tiagovieira5080
    @tiagovieira5080 2 ปีที่แล้ว +11

    Tim, please do a video implementing AI for Pong.

  • @HcmfWice
    @HcmfWice 2 ปีที่แล้ว +3

    You could save yourself a lot of typing by using the object-oriented features of Python. E.g. you could add some methods to the Paddle class like left_x(), right_x(), top_y(), bottom_y() that calculate and return the relevant edge values of the paddle. Same with the ball. It would also make the code much cleaner.

  • @nextgodlevel
    @nextgodlevel 2 ปีที่แล้ว +6

    I am following you since you just have 10k subs and I am very happy to see your growth and Keep doing this kind of work.

  • @lukaszb3233
    @lukaszb3233 8 หลายเดือนก่อน

    Brilliant work Tim 😁 I absolutely love your content and it's very helpful for the beginner programmer to understand.
    The only thing I could add to this is to avoid repeatable code in your handle_paddle_movement function you could alter the move function of the Paddle class. That's what I did in the sample below:
    def move(self, up):

    if up == True and self.y >= 0:
    self.y -= self.VELOCITY
    elif up == False and self.y < HEIGHT - PADDLE_HEIGHT:
    self.y += self.VELOCITY
    Keep up the great work you do :)

  • @olesmor72
    @olesmor72 2 ปีที่แล้ว +3

    Thank you very much for this super tutorial!
    You are a very good teacher and I managed to learn a lot of useful things . Now I feel confident enough to try making something on my own.

  • @Alk0h0liX
    @Alk0h0liX 2 ปีที่แล้ว +2

    Hey Tim - thanks a lot for your amazing videos! I just started coding/Python two months ago and you helped me so much already. Always thought, that coding is something I am not able to do, because during study it was just horribly boring, but you definetely helped to show me, that coding is a lot of fun, a lot of thinking and a lot of "sense of archievement", if everything works in the end. An AI-pong video would be great by the way! I am just now trying something similar with "Brick Breaker" and I am kind of stuck :D

  • @davebostain8588
    @davebostain8588 11 หลายเดือนก่อน

    Great Video! I have a program to train the Gym Pong in Pythorch. The training appears to go well, but the AI cannot play the game well. I am hoping these videos will provide some insight into why this is occurring. I like the way you didn't make a bunch of classes just to make classes, but made classes when it made sense to make classes. Looking forward to the Pong AI training video!

  • @kiish8571
    @kiish8571 2 ปีที่แล้ว +1

    thank you, watching this is like therapy for me

  • @ozgur8946
    @ozgur8946 2 ปีที่แล้ว +1

    Thanks for guide , really nice for both pygame and oop.I was wondering how to refresh text like scores without blinking text!

  • @jamesstone8988
    @jamesstone8988 2 ปีที่แล้ว +1

    Awesome tutorial and clear explanations! Especially appreciated how to "solve for" with the equation :) Thanks!

  • @HenryTSBs
    @HenryTSBs ปีที่แล้ว

    Thank you very much Tim for this tutorial for just this pong game. I am a beginner in pygame coding so this really helped me a lot and I appreciate it. Keep it up Tim

  • @piotrczerechowicz9352
    @piotrczerechowicz9352 2 ปีที่แล้ว +5

    Tim, great tutorial. You should definitely make video about implementing AI to opponent pong :D

  • @ВладиславМасляк
    @ВладиславМасляк 2 ปีที่แล้ว +2

    thanks a lot helped now i will know python better :)

  • @justmyfavs5796
    @justmyfavs5796 2 ปีที่แล้ว +4

    you can just add this instead of left_paddle movement to make an AI "
    if ball.y

  • @tntredstone
    @tntredstone 2 ปีที่แล้ว +1

    I was the 7,825 viewer watched the entire video and loved it👍

  • @ranselaar
    @ranselaar 2 ปีที่แล้ว +3

    Just started programming with Python, the fun is immense. Altough sometimes I get lost in my code spaghetti. Do you also have a video about clean code perhaps?

  • @karpagambaskar6608
    @karpagambaskar6608 2 ปีที่แล้ว +1

    Love your videos tim. Congrats on 900k. Just 100k more and you'll reach the glorious 1000000. Your videos are great tim keep It up

    • @tntredstone
      @tntredstone 2 ปีที่แล้ว +2

      golden programming play button

  • @guipe7712
    @guipe7712 2 ปีที่แล้ว +1

    Hello Tim, Great video and interesting material. Im practice with this pygame is really cool. Thanks friend

  • @wrb5682
    @wrb5682 9 หลายเดือนก่อน +1

    Thank you Tim! It really helped in enhancing my knowledge.

    • @TechWithTim
      @TechWithTim  9 หลายเดือนก่อน

      Very welcome!

  • @Heraclius.Maps1121
    @Heraclius.Maps1121 ปีที่แล้ว

    biggest thanks from me!
    I had a project and You saved me

  • @codesaif8075
    @codesaif8075 2 ปีที่แล้ว +1

    Just started learning pygame today and you uploaded another game tutorial, Thanks Tim!

  • @Lokakoskt
    @Lokakoskt 2 ปีที่แล้ว +2

    First of all congrats for the video!
    And let me ask a question how you learned all this stuffs?

    • @UnemployedMacintosh
      @UnemployedMacintosh 2 ปีที่แล้ว +2

      He posted a video a while back I think it’s called something like his programming journey. Shouldn’t be too hard to find on his channel

  • @alexbartles
    @alexbartles 2 ปีที่แล้ว +5

    Here goes 1 hour of my day!

  • @asharhabib4742
    @asharhabib4742 2 ปีที่แล้ว +1

    Awesome work! Keep up the great videos :)

  • @softwhere07
    @softwhere07 2 ปีที่แล้ว +1

    Looks interesting, but I will have to check it out if I can ever get more time. I suppose I could watch 10 or 20 minutes if this a day until I finish it.

  • @Aditya_777
    @Aditya_777 2 ปีที่แล้ว +2

    Thank you very much!!! Did it finally 🙏

  • @JastaCon
    @JastaCon ปีที่แล้ว

    it would help if you could show your keyboard inputs too. sometimes i cant see the difference between __ and _

  • @Child0ne
    @Child0ne 2 ปีที่แล้ว +1

    Yyeeeessssssssssssss I know what I’m doing today ! Thanks timbo

  • @adimac9346
    @adimac9346 2 ปีที่แล้ว +5

    AI for pong is a great idea Tim!

  • @puturavindrawiguna3025
    @puturavindrawiguna3025 2 ปีที่แล้ว +1

    hey Tim, i have a question about the reason you are passing the left paddle and right paddle into a list,
    is there any reason why you choose list instead of other array like type like say tuple?
    or is it completely free to choose and doesn't have an impact on the peformance

  • @36aryansharma83
    @36aryansharma83 2 ปีที่แล้ว +2

    Pretty cool man! never thought you could make games with python lol

  • @GreenScreenKid284
    @GreenScreenKid284 2 ปีที่แล้ว +5

    Can you make something related like creating Jarvis irl or how iron man codes his Armor and other gadgets

  • @aumpauskar4653
    @aumpauskar4653 2 ปีที่แล้ว +1

    This video couldn't come at a much better time, I tried pygame juat last week and was halfway through making my *cursed pong* game.

  • @WatchItWithFuture
    @WatchItWithFuture 2 ปีที่แล้ว +1

    I'm waiting on the planet simulation tutorial 😁

  • @terryjophlin
    @terryjophlin 2 หลายเดือนก่อน

    I don't really like how Tim seems to get bored and starts to rush, especially when it causes mistakes. It's cool that he kind of admits making the mistake, but the damage is done and the pattern is in my brain.

  • @lawson1310
    @lawson1310 2 ปีที่แล้ว +2

    Bro, you are just the best!, am gonna make an AI beat this game😎

  • @Schmacksz
    @Schmacksz 2 ปีที่แล้ว +1

    I’m on pythonista right now.

  • @sp1nk1ck53
    @sp1nk1ck53 2 ปีที่แล้ว +1

    I have a question: In the handle collision function, is it really necessary to check if the ball is in between the corners of the paddle it's about to hit if in it's nested "if" statement, you're going to check if the ball hits the paddle anyways?

  • @Schmacksz
    @Schmacksz 2 ปีที่แล้ว +1

    If I’m not using pygame… what should I use for the import?

  • @pushkarajsavji729
    @pushkarajsavji729 2 ปีที่แล้ว +1

    where is the paddles defined ?
    it says undefined and two arguments in draw function

  • @kushalop_2
    @kushalop_2 2 ปีที่แล้ว +2

    Hi bro, nice tutorial. I got an error called NameError: name 'paddles' is not defined. I am a beginner so pls help me with this 😂😅😅

  • @sirgb7
    @sirgb7 2 ปีที่แล้ว +1

    Great tutorial, thank you Tim

  • @SneakySnakesStudio
    @SneakySnakesStudio 2 ปีที่แล้ว +1

    Much thanks bro ;-)

  • @zulfiqar7967
    @zulfiqar7967 2 ปีที่แล้ว +1

    I completed ur Blockchain beginning course.. do you have any other plans to do another playlist on Blockchain development?

  • @Mangohawk124
    @Mangohawk124 ปีที่แล้ว

    This is smooth thats what i need ❤❤❤

  • @anuvabchakraborty4900
    @anuvabchakraborty4900 2 ปีที่แล้ว +1

    You are really consistent

  • @Gunsi-kb2xq
    @Gunsi-kb2xq 2 ปีที่แล้ว +2

    Question... if you do not reset the ball (around 1:04) it keeps counting up the score (understood) but if you just wait the balls comes back from somewhere....why is that?

  • @therabidpancake1
    @therabidpancake1 หลายเดือนก่อน

    So I have the program pretty much written the problem is that I don’t just want to copy down the program. I want to use as a learning tool. I am not going to lie I am learning a little bit . Some of it is clicking but I have a lot to learn.

  • @enomskenneth3125
    @enomskenneth3125 2 ปีที่แล้ว +1

    Mr may i conquire your help i was trying to download pygame but then an error occurec saying "no mudule named 'pygame'"

  • @alexanderwierzbicki7988
    @alexanderwierzbicki7988 2 ปีที่แล้ว +2

    quick question Tim. I have downloaded pygame successfully but when i run my module it just doesn't work. do you know why?

    • @dw5197
      @dw5197 2 ปีที่แล้ว

      Do you have the right pycharm?

  • @Clipaholick
    @Clipaholick 2 ปีที่แล้ว +1

    omg this is awesome!!

  • @Sniper1903
    @Sniper1903 2 ปีที่แล้ว +1

    20:11 how can I make this bracket on the keyboard like here I mean this -> ( in straight form

  • @cYuber356
    @cYuber356 2 ปีที่แล้ว +1

    Ai for pong!

  • @kulandaigeorgemariasingara5089
    @kulandaigeorgemariasingara5089 2 ปีที่แล้ว +1

    I 'm your number one fan!

  • @caleb7327
    @caleb7327 ปีที่แล้ว

    Great Video

  • @ghengushahn2852
    @ghengushahn2852 2 ปีที่แล้ว +2

    I’m having issues with collision, implementing what you have here my ball still only travels on the x axis I have no y travel at all I wonder what could be happening?

    • @MonTech0451
      @MonTech0451 2 ปีที่แล้ว +1

      I have the same thing and dont know whats wrong

    • @MonTech0451
      @MonTech0451 2 ปีที่แล้ว +2

      yo check your move function in the ball class i wrote self.x += self.y_vel and it sould be self.y+= self.y_vel

    • @ghengushahn2852
      @ghengushahn2852 2 ปีที่แล้ว +1

      @@MonTech0451 yea I had the same thing good catch!

  • @jamieharper5665
    @jamieharper5665 ปีที่แล้ว

    I learned so damn much in this video! On to the AI using NEAT video that I've been eyeing up lol :P

  • @shiamjuniorchuttoocode
    @shiamjuniorchuttoocode ปีที่แล้ว

    Awesome video, really great, you did a great job.

  • @peterbregnbk8119
    @peterbregnbk8119 2 ปีที่แล้ว +1

    what does size must be 2 numbers mean

  • @Aerospace-innovation
    @Aerospace-innovation 4 หลายเดือนก่อน

    I literaly coded this on my calculator lol (not even kidding)

  • @Billman07
    @Billman07 2 ปีที่แล้ว +2

    U are my fav teacher

    • @TechWithTim
      @TechWithTim  2 ปีที่แล้ว +2

      You're my fav commenter ;)

    • @Billman07
      @Billman07 2 ปีที่แล้ว +1

      @@TechWithTim damm i first time commented-

  • @bigbro1815
    @bigbro1815 ปีที่แล้ว

    Great game

  • @bxr4231
    @bxr4231 2 ปีที่แล้ว +1

    Such a cool video

  • @BackyardFusion
    @BackyardFusion 2 ปีที่แล้ว

    where was paddles defined(minute20:26)
    it tells me that it isnt defined and also:
    TypeError: draw() takes 1 positional argument but 2 were given

  • @MonTech0451
    @MonTech0451 2 ปีที่แล้ว +1

    Hey Tim my program is just changing the speed of the ball when it collides with different sides of the paddle instead of changing angles. Do you know what might be wrong or anyone in the comments know?

    • @MonTech0451
      @MonTech0451 2 ปีที่แล้ว +1

      ok i figure it out it was in the ball call move function and i wrote self.x += self.y_vel so my y movement was not working on the ball lol. I wonder why this caused my ball to change speeds instead of angle most be the collision equation was only appling on the x coordinates of the ball

  • @dant872
    @dant872 2 ปีที่แล้ว +2

    I would like to see the AI piece of this

  • @markadyash
    @markadyash 2 ปีที่แล้ว +2

    yeah we all need AI playing pingpoing

  • @The_IT_kid
    @The_IT_kid 4 หลายเดือนก่อน

    I'm using python 3.12.3

  • @mdjackhan
    @mdjackhan ปีที่แล้ว +1

    hey um the code didnt work because every time u run it it just opens for 1 second and then closes, I even tried running your github code (it had same result)

    • @masterm987
      @masterm987 6 หลายเดือนก่อน

      You need to make sure your using the pygame.display.update() to keep the window open.

  • @kshutt6242
    @kshutt6242 ปีที่แล้ว

    How can I do this with IDLE? I have installed Pygame via the command prompt, but IDLE doesn't recognize pygame with import. Thanks in advance.

  • @0Clappy
    @0Clappy 2 ปีที่แล้ว +1

    Can you give a quick tid bit about the left_paddle.y - left_paddle.VEL >= 0 ? Is this like a vector thats updated per frame?

  • @ali-bibon--
    @ali-bibon-- 2 ปีที่แล้ว +1

    Tim

  • @Tinker250
    @Tinker250 ปีที่แล้ว

    I am getting an error that reads AttributeError: partially initialized module 'pygame' has no attribute 'init' (most likely due to a circular import) pls help me

  • @alfredgomez7701
    @alfredgomez7701 ปีที่แล้ว

    Hi sir how to out a game over message and please restart and start the game.

  • @thequeerulantin
    @thequeerulantin ปีที่แล้ว

    Thanks for this tutorial. I've learned, that pygame is garbage. Not really for game developement. I will never use it again. Not nessescary for the real word. And i've learned, that I am not so far in my progress to really understand, what you have done.

  • @tipsminecraftchannel4348
    @tipsminecraftchannel4348 11 หลายเดือนก่อน

    Tim the code isnt working it wont let my paddles go up can you help me with this

  • @PaiganBeast
    @PaiganBeast 2 ปีที่แล้ว +1

    Can someone help me?
    I'm getting a name error, saying '_name_' is not defined, and I'm not getting the black screen popping up at 9:14
    :(

    • @brucemozart3665
      @brucemozart3665 2 ปีที่แล้ว

      I had the same error. Make sure that there are two '_' on each side of "name" and "main". This is easy to mess up :D

    • @PaiganBeast
      @PaiganBeast 2 ปีที่แล้ว

      @@brucemozart3665 I double checked, and ive two underscores on each side 🥺

  • @davidisfrench6560
    @davidisfrench6560 2 ปีที่แล้ว

    why dies it say that the module "pygame" is not found?

  • @MathewBey13
    @MathewBey13 2 ปีที่แล้ว

    When I do the first test run, my window appears for a second then disappears. How do I fix this issue?

  • @ownser1
    @ownser1 2 ปีที่แล้ว +1

    Can anyone explain to me why you would prefer to use something like pygame that takes much more time and knowledge, over a game engine like godot that will do a lot of the tedious work for you? This is a real question and I'm asking purely out of ignorance. Thanks to anyone who answers!

    • @malindrome9055
      @malindrome9055 2 ปีที่แล้ว +4

      the reason why is pygame isnt about learning game dev per se, but its more about learning how to code and learning how to do other projects, like if you wanted to do gamedev, then pygame is not for you, then you can use godot, but pygame teaches you how to make other software, hope this helps!

  • @OHIOHUBPS99
    @OHIOHUBPS99 ปีที่แล้ว

    i got trouble at excuting it it always fail and the pong is not responding

  • @ZgavY
    @ZgavY 2 ปีที่แล้ว +2

    The only reason why I don't really like python + pygame, even though it's easy, it's because it's slow af, and If I wanna make a super intense game with high detail graphics and image manipulation and complicated stuff, the game ends up running at 10 fps. Maybe 30 if I actually write good code...

    • @foreversleepy4379
      @foreversleepy4379 2 ปีที่แล้ว +2

      It's only as easy as the game you're making. It's still hard to make anything good with it. It's actually easier using a modern game engine where you have a lot of visual tools to help you slap on a few colliders and what not. You don't even need to think about architecture because the engine already does it for you, you just write a script and attach it.
      The reason why you can't make anything like that with Pygame is because it's software rendered, which is how they used to make games before they started to take advantage of graphics hardware, I believe. Unity and other engines use the graphics hardware, which is a lot faster than doing all the calculations on the CPU.

    • @ZgavY
      @ZgavY 2 ปีที่แล้ว +1

      @@foreversleepy4379 I meant performance... Using something as basic as pygame, and a programming language as slow as python will make it impossible to make a sofisticated game, unless it's a pixel art game where you don't do too heavy manipulation on certain things

    • @foreversleepy4379
      @foreversleepy4379 2 ปีที่แล้ว +2

      @@ZgavY Well of course, that's what engines are for. No one learns Pygame to make those types of games because doing a lot of that stuff on your own would take forever, and even if you wanted to write all the systems from scratch, another language would be better suited.
      I use Pygame so I can solve a lot of problems and build my problem solving skills. It's also just a bit of fun. Not everything has to be serious.

  • @monkey-t4h
    @monkey-t4h 4 หลายเดือนก่อน

    1 question. How do you even get that Python???

  • @sarhabernalumana4206
    @sarhabernalumana4206 11 หลายเดือนก่อน

    9:14 uhhh my window opens for a second and than closes by itself ....

  • @granpajestaz292
    @granpajestaz292 ปีที่แล้ว

    Followed to a T but getting error paddle object has no attribute draw any ideas?

    • @theatfshotmydog8224
      @theatfshotmydog8224 9 หลายเดือนก่อน

      did you add a draw(): function within the paddle class?

  • @FRAMEDSKATEKREW69
    @FRAMEDSKATEKREW69 2 ปีที่แล้ว +1

    Idk if you'll see this but how do I display 10 at the end of the match? Its kind of bothering me that it shows 9 when it ends. Hopefully I figure it out soon, Nice tutorial btw!

  • @ryanali156
    @ryanali156 ปีที่แล้ว

    for some reason when i put the second set of parenthases in the pygame.display.set_mode((WIDTH, HIEGHT)) it says thats its invalid syntax pls help

    • @jagzey
      @jagzey ปีที่แล้ว +1

      u spelt height wrong

  • @priyankagupta4772
    @priyankagupta4772 หลายเดือนก่อน

    I'm a beginner, so can someone please tell me what the class function does?

  • @THEMATT222
    @THEMATT222 2 ปีที่แล้ว +1

    Very Noice 👍

  • @JastaCon
    @JastaCon ปีที่แล้ว

    there is no window opening. it just says "no module named pygame"

  • @hudsonmcknight4221
    @hudsonmcknight4221 ปีที่แล้ว

    the screen wouldnt show up

  • @ChristopherBruns-o7o
    @ChristopherBruns-o7o 3 หลายเดือนก่อน

    9:02 why does if __name__ == "__main__":, not expect else after line break? Like most if statements.
    15:46 and how do we get self.COLOR if we never define self.COLOR = COLOR?
    19:55 Is there not some css equivant or rich font and bold colors and just a straight line would work i think. Maybe1pc.
    20:18 one where your paddles break each move and hifher velocity has higher durability payout but handle the hame completely by math and right hand angles to geometry of polygon. Cause paddles break.
    23:23 Bro its math. and have the model return pure JSON cause maths.