No video

Python Game Tutorial: Pong

  Рет қаралды 512,789

freeCodeCamp.org

freeCodeCamp.org

Күн бұрын

Пікірлер: 1 400
@47noodles
@47noodles 4 жыл бұрын
Me: *Gets a black box to appear on the screen* *Smiles Proudly*
@chriscreates7772
@chriscreates7772 4 жыл бұрын
me
@47noodles
@47noodles 4 жыл бұрын
Christian Thompson I done now, I even figured out how to get the ball to go faster at every bounce
@goku445
@goku445 4 жыл бұрын
I had to work to ge to that point. Linux python install versioning shitfest...
@seventyfox7442
@seventyfox7442 4 жыл бұрын
@@TokyoEdTech Wow! I think that it is really cool that you are still responding to these comments, even after about a year of this being up. I watched this video a while ago and it jump-started my passion for coding, so thank you!
@cal847
@cal847 4 жыл бұрын
ha, me too. that made my day.
@mikemindacodemy7279
@mikemindacodemy7279 5 жыл бұрын
Build a game, no matter how simple, always makes learning a new language more fun and motivating. Thank you!
@goku445
@goku445 4 жыл бұрын
I always start with a pong whenever I want to learn a new language :D
@Jojo-cs4bl
@Jojo-cs4bl 4 жыл бұрын
Whan I wirt square it say error 😩
@samisha9145
@samisha9145 3 жыл бұрын
We made a pong game in Python using the Turtle and Freegames libraries. kzfaq.info/get/bejne/h7Z7gqWWs922kp8.html
@joebot001
@joebot001 5 жыл бұрын
This is my first-ever (finally) attempt at coding something in Python. After dozens of "learn python in x-hours" videos, I finally realized I needed a specific goal, and pong was recommended. I had to pause at 32min to just play my pong game, with the biggest grin on my face. Thanks so much for this tutorial, it's EXACTLY what I needed to finally jump into coding.
@zachface.19
@zachface.19 4 жыл бұрын
It's been 5 months since you said this. How much more would you say your coding has improved?
@markuskorpijarvi5538
@markuskorpijarvi5538 4 жыл бұрын
@@zachface.19 Its 6 months
@markuskorpijarvi5538
@markuskorpijarvi5538 4 жыл бұрын
@@zachface.19 How much do You haves?
@user-xq2dz4rp9k
@user-xq2dz4rp9k 4 жыл бұрын
It's been 9 months since you said this. How much more would you say your coding has improved?
@bravosix8171
@bravosix8171 4 жыл бұрын
Have you learned? Plz tell
@crunchygs8771
@crunchygs8771 4 жыл бұрын
Me: copies everything he did but the color and size ratio's Also Me : i am programr
@TheComedyBlackGuy
@TheComedyBlackGuy 4 жыл бұрын
literally
@tankytitan1304
@tankytitan1304 4 жыл бұрын
The program is easy if you know math
@rayanking4773
@rayanking4773 4 жыл бұрын
i don't think is a good way that's a video for learning not for copy
@Zubs1507
@Zubs1507 4 жыл бұрын
lol
@Itz_me_JB
@Itz_me_JB 4 жыл бұрын
its fine to copy the code the point is to make sure to understand it
@TheWorldsStage
@TheWorldsStage 4 жыл бұрын
Do a beginners tutorial on how to program a game like "Fallout 4" using turtle in Python. It may need a few extra lines of code.
@cOnT3ST
@cOnT3ST 4 жыл бұрын
Or maybe he should just recode "Fallout 76"
@cOnT3ST
@cOnT3ST 4 жыл бұрын
@@linushallgren4156 Of course he wasn't. what made you think so???
@TheWorldsStage
@TheWorldsStage 4 жыл бұрын
@@linushallgren4156 So, maybe like, 20 extra lines of code?
@cooperbrahmsteadt5123
@cooperbrahmsteadt5123 4 жыл бұрын
Whitney 25 at most
@xdemoman3692
@xdemoman3692 4 жыл бұрын
@@cooperbrahmsteadt5123 Maybe 30, but that's only when worst comes to worst.
@protoactivenuclear7727
@protoactivenuclear7727 5 жыл бұрын
richards from silicon valley was right, spaces are annoying just use tabs
@peesicle
@peesicle 4 жыл бұрын
Yeah he was also nice to see someone who actually watches something i watch
@sireopossom7860
@sireopossom7860 3 жыл бұрын
I watched the whole 44min and I was not bored a second. I loved it, thanks for the great tutorial, please make more!
@English.with.Mateusz
@English.with.Mateusz 2 жыл бұрын
did you continue your journey with Python?
@josephshaw2747
@josephshaw2747 3 жыл бұрын
31:25 "I just call it a pen, but it's actually just a turtle" - Smart computer man, 2020
@TokyoEdTech
@TokyoEdTech 3 жыл бұрын
Thanks - I try.
@anonymoustechgeek
@anonymoustechgeek 4 жыл бұрын
Starting at 40:49, the sound comes after the ball hits the coordinates because that is where it is placed in the program. If you move the sound to right after the if statement, it will occur in the correct order hit-sound-rebound. I do not have Python and have never programmed in it but I used to be a Visual Basic programmer years ago (VB 6). Now I am a sys admin. I kind of miss programming. I followed the logic perfectly in this video despite that fact. I believe I will try it now that I have watched this. Thank you! This is awesome! It reminded me how much fun programming was!
@antonkarolik6993
@antonkarolik6993 4 жыл бұрын
instead of ball.shape("square"), do ball.shape("circle")
@user-ze3ui8ur9h
@user-ze3ui8ur9h 2 жыл бұрын
i believe this was inspired by the original version of pong.
@kiddo7562
@kiddo7562 2 жыл бұрын
thanks u made it look better and interesting :)
@ankeet4044
@ankeet4044 2 жыл бұрын
it looks more retro with square.
@abhijeetkushwaha424
@abhijeetkushwaha424 5 жыл бұрын
@ 23:50 instead of sending the ball to 0,0 when it collides with the x boundaries, i used: ball.goto(390,ball.ycor()) and ball.goto(-390,ball.ycor()) This is preserving continuity of the game, instead of directly sending the ball at center.
@chrispowell8121
@chrispowell8121 4 жыл бұрын
Finished. I never thought I could code a game until I watched this video. Thank you, Christian!
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
You're very welcome - keep on codin'!
@LunaBellaRosa
@LunaBellaRosa 5 жыл бұрын
Thanks so much for this. I am super new to coding and found this and decided to give it a try. I still have a long way to go, but I’m having fun. I hope to learn more with your videos and free code camp soon.
@logandukes5984
@logandukes5984 4 жыл бұрын
this is probably the best coding tutorial i have watched so far. He explains everything super well for those who have never used turtle before. He simplifies everything and takes his time instead of speeding through it. I really want to see a snake game tutorial by this guy but I hope he teaches us how to make a grid instead of just a dark backround because a grid looks much better and makes it easier to play the game
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
Thanks! I have a snake tutorial, but no grid - sorry.
@jamesleibee890
@jamesleibee890 2 жыл бұрын
i dont know if i missed it, but if you wanna end the game you can do something like this at the end of it all under the while True loop. # game over if score_a == 5: pen.clear() ball.dx = 0 ball.dy = 0 ball.goto(0, 0) pen.write("Player A wins!!!", align="center", font=("courier", 32, "normal")) if score_b == 5: pen.clear() ball.dx = 0 ball.dy = 0 ball.goto(0, 0) pen.write("Player B wins!!!", align="center", font=("courier", 32, "normal"))
@maayancole
@maayancole 4 жыл бұрын
Thank you so much for taking time aside to help people code, coding can be very hard without basic information, and what you do so helpful, please keep uploading. (Sorry for the grammar mistakes, English isn't my native language)
@harmannatsingh3933
@harmannatsingh3933 4 жыл бұрын
This is the best tutorial about a project in python. Thanks so so so much!
@CarlC9898
@CarlC9898 5 жыл бұрын
Thanks for this awesome tutorial! The game is working great for me (I just needed to change the ball.dx and ball.dy to 0.2 and -0.2 respectively). I'm going to try and make another game using the turtle module and the techniques I learned in this video.
@lannyboover229
@lannyboover229 5 жыл бұрын
oh, thnx for your ball speed advice
@jrezzi1308
@jrezzi1308 5 жыл бұрын
# Simple Pong in Python 3 for Beginners # By @TokyoEdTech import turtle import os wn = turtle.Screen() wn.title("Pong") wn.bgcolor("black") wn.setup(width=800, height=600) wn.tracer(0) # Score score_a = 0 score_b = 0 # Paddle A paddle_a = turtle.Turtle() paddle_a.speed(0) paddle_a.shape("square") paddle_a.color("white") paddle_a.shapesize(stretch_wid=5,stretch_len=1) paddle_a.penup() paddle_a.goto(-350, 0) # Paddle B paddle_b = turtle.Turtle() paddle_b.speed(0) paddle_b.shape("square") paddle_b.color("white") paddle_b.shapesize(stretch_wid=5,stretch_len=1) paddle_b.penup() paddle_b.goto(350, 0) # Ball ball = turtle.Turtle() ball.speed(0) ball.shape("square") ball.color("white") ball.penup() ball.goto(0, 0) ball.dx = 2 ball.dy = 2 # Pen pen = turtle.Turtle() pen.speed(0) pen.shape("square") pen.color("white") pen.penup() pen.hideturtle() pen.goto(0, 260) pen.write("Player A: 0 Player B: 0", align="center", font=("Courier", 24, "normal")) # Functions def paddle_a_up(): y = paddle_a.ycor() y += 20 paddle_a.sety(y) def paddle_a_down(): y = paddle_a.ycor() y -= 20 paddle_a.sety(y) def paddle_b_up(): y = paddle_b.ycor() y += 20 paddle_b.sety(y) def paddle_b_down(): y = paddle_b.ycor() y -= 20 paddle_b.sety(y) # Keyboard bindings wn.listen() wn.onkeypress(paddle_a_up, "w") wn.onkeypress(paddle_a_down, "s") wn.onkeypress(paddle_b_up, "Up") wn.onkeypress(paddle_b_down, "Down") # Main game loop while True: wn.update() # Move the ball ball.setx(ball.xcor() + ball.dx) ball.sety(ball.ycor() + ball.dy) # Border checking # Top and bottom if ball.ycor() > 290: ball.sety(290) ball.dy *= -1 os.system("afplay bounce.wav&") elif ball.ycor() < -290: ball.sety(-290) ball.dy *= -1 os.system("afplay bounce.wav&") # Left and right if ball.xcor() > 350: score_a += 1 pen.clear() pen.write("Player A: {} Player B: {}".format(score_a, score_b), align="center", font=("Courier", 24, "normal")) ball.goto(0, 0) ball.dx *= -1 elif ball.xcor() < -350: score_b += 1 pen.clear() pen.write("Player A: {} Player B: {}".format(score_a, score_b), align="center", font=("Courier", 24, "normal")) ball.goto(0, 0) ball.dx *= -1 # Paddle and ball collisions if ball.xcor() < -340 and ball.ycor() < paddle_a.ycor() + 50 and ball.ycor() > paddle_a.ycor() - 50: ball.dx *= -1 os.system("afplay bounce.wav&") elif ball.xcor() > 340 and ball.ycor() < paddle_b.ycor() + 50 and ball.ycor() > paddle_b.ycor() - 50: ball.dx *= -1 os.system("afplay bounce.wav&")
@dreggeth
@dreggeth 2 жыл бұрын
Thank you for this great tutorial! If someone wants to limit paddles movement in y direction you can do this: def paddle_a_up(): y = paddle_a.ycor() if y < 250: y += 20 paddle_a.sety(y) def paddle_a_down(): y = paddle_a.ycor() if y > -250: y -= 20 paddle_a.sety(y)
@ursomrano542
@ursomrano542 2 жыл бұрын
A cool little thing you can add to the code as well is a direction randomizer every time the ball is in the center by importing "random" and then adding something like this: if ball.xcor() == 0 and ball.ycor() == 0: firstDirection = random.randint(0,3) if firstDirection == 1: ball.dx *= -1 ball.dy *= 1 elif firstDirection == 2: ball.dx *= 1 ball.dy *= -1 elif firstDirection == 3: ball.dx *= -1 ball.dy *= -1 in the "#Move the ball" section of the while loop :)
@danielmoreno968
@danielmoreno968 2 жыл бұрын
Thank you!
@thatwholesomeindian3305
@thatwholesomeindian3305 4 жыл бұрын
im having problems every time i try to run it, it says in the terminal invlid syntax
@nowybopes
@nowybopes 4 жыл бұрын
I don't know why I was so happy when the black square appeared on my screen
@rayanking4773
@rayanking4773 4 жыл бұрын
me too xd
@latifasebti7913
@latifasebti7913 4 жыл бұрын
itz becuz u feel u did something great and u didn't do any falt and ur so proud of yourself
@thisthelongestnameonyoutub2190
@thisthelongestnameonyoutub2190 3 жыл бұрын
Me Too!
@hypersound1612
@hypersound1612 3 жыл бұрын
It’s not popping up on mine
@blue_is_cool16
@blue_is_cool16 3 жыл бұрын
@@hypersound1612 make sure to open the python IDLE program too.
@marcfoster715
@marcfoster715 4 жыл бұрын
print("The only winning move is not to play.")
@hillybankok
@hillybankok 2 жыл бұрын
You've... Been.... Trolled! You've been trolled, Yes you've probably been told!, Don't reply to this guy, he's just trying to get a rise.. OUT OF YOU! Yes it's true! You respond, and that's his cue! To start trouble on the double, while he strokes his madly stubble!, You've been trolled, you've been trolled! You should probably just fold! When the only winning move is not to play! And yet, you keep on trying, mindlessly REPLYING! You've been trolled, you've been trolled! Have a nice daaaaaaaaaaay.!!
@IDrive305
@IDrive305 5 жыл бұрын
you should explain that if ball.dx is set too high at 2 use fractions your code should look like this : ball.dx = 1/5 ball.dy = 1/5 adjust bottom half of the fraction to your desired speed
@IDrive305
@IDrive305 5 жыл бұрын
or decimal
@shivamjalotra7919
@shivamjalotra7919 5 жыл бұрын
this thing is self-explanatory
@IDrive305
@IDrive305 5 жыл бұрын
Christian Thompson I like your vids great work
@shivamjalotra7919
@shivamjalotra7919 5 жыл бұрын
@@TokyoEdTech Great work from your side. Love it.
@uahatoxicboi9801
@uahatoxicboi9801 5 жыл бұрын
C R thanks I appreciate
@shalonemadre488
@shalonemadre488 4 жыл бұрын
That was very helpful with my school project, thank you very much for the help.
@_HARAA_
@_HARAA_ 3 жыл бұрын
no one could have made it any easier and motivating, thank you
@annielouise1141
@annielouise1141 3 жыл бұрын
my ball is not moving..
@thatgarryman9400
@thatgarryman9400 6 ай бұрын
No "WHAT'S UP GUYS, BEFORE WE START THIS VIDEO" stuff for 2 minutes, just the real deal. Immediate like.
@publicstaticvoid3224
@publicstaticvoid3224 5 жыл бұрын
Thank you very much for making this tutorial. I appreciate the hard work you put into this bro! Everything worked perfectly ;)
@ebentee
@ebentee 5 жыл бұрын
It dies work for me
@TheBobstar89
@TheBobstar89 5 жыл бұрын
24:35 why is there a 10px offset that causes the ball to go off the screen instead of stopping at the window corner?
@RotemEren
@RotemEren 3 жыл бұрын
Short and to the point. Well done.
@Hilqy
@Hilqy 3 жыл бұрын
way more useful than my teacher, learned more here than I have this month
@TokyoEdTech
@TokyoEdTech 3 жыл бұрын
Thanks - glad you found it useful!
@Berzerker-
@Berzerker- 4 жыл бұрын
hey i got a problem where my ball speed isnt constant even though i have the same exact code as the tutorial, anyone know how to fix this ?
@TheBerkaay
@TheBerkaay 3 жыл бұрын
I have the same problem. Were you able to find a solution?
@kiwan7411
@kiwan7411 3 жыл бұрын
he litterly sedd how to fix it
@kiwan7411
@kiwan7411 3 жыл бұрын
@Waleed في الشلال well its kinda hard to explain just watch the video again or something
@vicfic_
@vicfic_ 3 жыл бұрын
@Waleed في الشلال , @Berksater in the # ball section there are two variables named ball.dx and ball.dy. Lower its values from 2 to 0.1 or something.
@kingannihilator8386
@kingannihilator8386 3 жыл бұрын
this is the most useless reply section i have ever seen
@samshanmukh
@samshanmukh 5 жыл бұрын
I think adding the ampersand (&) at end of the file tells to run the command in the background for unix-based systems.
@mdempse1
@mdempse1 5 жыл бұрын
Great tutorial. Got the sound working in windows and now I just need to figure out how to make the paddles get continuous input from a held down key and make it faster/smoother. Learned a lot. Thanks!
@mdempse1
@mdempse1 5 жыл бұрын
@@TokyoEdTech Nice, I will give it a try.
@RahulRoy-ct7ni
@RahulRoy-ct7ni Жыл бұрын
what is the command for window for the sound?
@IamnotGW
@IamnotGW Жыл бұрын
9:37 I have never seen someone need more effort to write the word Function. Overall a great video for beginners
@elbow3422
@elbow3422 5 жыл бұрын
Hello, I followed through the whole tutorial and now at the end I'm trying to make a timer for the game. I successfully made the timer just how I wanted but it froze everything else in the game. I'm pretty sure the problem is that the loop is waiting for the timer to finish until it goes again, but I want the game and timer to run simultaneously. Any ideas?
@abdurrahman.maricar
@abdurrahman.maricar 4 жыл бұрын
Having issues with sound on Windows, Whenever it touches the wall or the paddle it gives a Windows error sound instead of the bounce sound that I had downloaded
@ogunkayodeoluwaseun9348
@ogunkayodeoluwaseun9348 4 жыл бұрын
Same here and my pad runs off the screen too
@sohitbagga712
@sohitbagga712 4 жыл бұрын
did you save your sound file in .vscode folder?
@ladzsn5314
@ladzsn5314 4 жыл бұрын
@@sohitbagga712 where is the folder
@u4tiwasdead
@u4tiwasdead 4 жыл бұрын
if you still want to know, if you just wrote the filename e.g. "bounce.wav" you need to write the full filepath instead e.g. "C:/Users/files/bounce.wav"
@abdurrahman.maricar
@abdurrahman.maricar 4 жыл бұрын
@@u4tiwasdead Thanks alot
@wesusaa
@wesusaa 4 жыл бұрын
Really good video! I was really happy with how it turned out! I made some adjustments so they paddles didn't go off screen, but the explanation was so well made!
@zackcordle4814
@zackcordle4814 2 жыл бұрын
How did you code them so they don't go off screen?
@mohammedirfan1739
@mohammedirfan1739 4 ай бұрын
broooooo thank you soo much man i was scared that i would fail my test but you saved my 🥺
@luka8966
@luka8966 4 жыл бұрын
This is a very good tutorial and I very recommend it. It was easy to understand and I might actually stand a chance at creating games in the future. After it finished, I managed to: Make it slowly get faster, make it so both players can create there own names and make the game a best of 5 where your paddle gets smaller for every point you get and it even comes up with text at the end saying who won. Thank you!
@spekkio77
@spekkio77 4 жыл бұрын
nice going, I also made it slowly get faster and then reset when the ball goes out. I like the idea of the paddle getting smaller, I may try that. Another fun idea I might try is to change the angles (dx / dy) depending on where the ball hits the paddle
@derpdarko
@derpdarko 3 жыл бұрын
For windows you have to do winsound.Beep(800, 75) (you can change the numbers if you want you should end up with this import winsound winsound.Beep(800, 75) Edit: Only if the first method doesn't work
@twodays8041
@twodays8041 4 жыл бұрын
I can't believe I just programed a game, thank you
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
You're welcome!
@jakubpesko8071
@jakubpesko8071 2 жыл бұрын
for the ones who dont knows how to make borders for the paddles here you re if paddle_a.ycor() > 250: paddle_a.sety(250) if paddle_a.ycor() < - 250: paddle_a.sety(-250) if paddle_b.ycor() > 250: paddle_b.sety(250) if paddle_b.ycor() < - 250: paddle_b.sety(-250)
@ullwor
@ullwor 2 жыл бұрын
thx man, that's exactly what i was looking for :D
@ferax4598
@ferax4598 4 жыл бұрын
Ahh finally I'm done Christian: *AaAAaanDd*
@ferax4598
@ferax4598 4 жыл бұрын
@@TokyoEdTech lol
@itstoufik8410
@itstoufik8410 3 жыл бұрын
thank you for the tutorial!
@TokyoEdTech
@TokyoEdTech 3 жыл бұрын
You're welcome!
@greenbeanmanz
@greenbeanmanz 4 жыл бұрын
This was great!!I had to figure out how to show the turtle window and stuff on windows because the way visual studios was set up. I didn’t add sounds because I didn’t want to mess anything up and I didn’t want to spend any more time. Great tutorial!!!
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
Thanks!
@Galileo3k
@Galileo3k 5 жыл бұрын
Wow! You are really crystallizing many concepts of my early studies of python. I will watch more.
@joost_schiphorst
@joost_schiphorst 4 жыл бұрын
my ball has different speeds, i dont know why, how do i solve it? the best speed on my computer is 0.13
@diegoolivera5261
@diegoolivera5261 4 жыл бұрын
did U find a solution to it, I'm having the same problem
@joost_schiphorst
@joost_schiphorst 4 жыл бұрын
@@diegoolivera5261 nope, I wish I had
@josephreed3287
@josephreed3287 4 жыл бұрын
Joost Schiphorst I’m having the same issue as well. And what I believe is happening is that your pc is using up less processing power at some points and in those moments, the ball moves faster because the ball is set to move based on how quickly your pc can update it. But I’m not 100% sore about that so take it at face value. Lol I do believe there is a way to fix it but it’s currently 2 am for me. I’ll look it up tomorrow and let you know if I’ve found a fix or not.
@ishank7239
@ishank7239 4 жыл бұрын
Has someone found the fix ?
@a.a8720
@a.a8720 4 жыл бұрын
1/2
@jaytea23
@jaytea23 5 жыл бұрын
Great tutorial! Only issue I'm having is with the 'w' key. I can't hold it down and continue to move up like I can with the other keys. Anyone else having this issue?
@Shikigami6
@Shikigami6 5 жыл бұрын
same, but set the movement of the b paddle to o for up and p for down, and here i can only hold-move the up-movement. Have you solved the problem yet?
@a2kvarnstrom80
@a2kvarnstrom80 4 жыл бұрын
here is the code: def paddle_a_up(): y = paddle_a.ycor() y += 20 paddle_a.sety(y) wn.onkeypress(paddle_a_up, "w")
@maxtaylor12
@maxtaylor12 4 жыл бұрын
You are getting this issue because when you did not write your code right. Just copy it line for line. Dont forget to change each var for each function you change it for (a,b)
@vaibhavsharma985
@vaibhavsharma985 4 жыл бұрын
Here is the solution Take two Boolean variable s pressed_up and pressed_down initialised as false Then in game loop place following code If event.type==pygame.KEYFOWN: If event.key==pyame.K_W: pressed_up=True elif event.key==pygame.K_S:pressed_down=True elif event.type==pygame.KEYUP: if event.key==pygame.K_W: pressed_up=False elif event.key==pygame.K_S:pressed_down=False Then outside the event loop write If pressed_up: xcord-=1 elif pressed_down: xcord-+=1
@Nate-er1fb
@Nate-er1fb 3 жыл бұрын
You must have placed it under the "while true loop"
@wasadasa1
@wasadasa1 5 жыл бұрын
For paddle and ball collisions I used absolute value function for the distance between the core of the ball and paddle, it's easier and doesn't cause the ball to stuck behind the paddle.
@chinmayat.s379
@chinmayat.s379 5 жыл бұрын
Please read it full The best tutorial, i ve never come across.... truly amazing... such a clean and clear explanations... step by step detailed explanation made us easy to swallow the whole concept... now i think i can write a new game by own... Thanks for that Sir. But there is a problem sir, When i wrote the program, the game worked fine apart from one thing... ball bounces and returns at a distance from the paddle.. i tried by changing the distance in if loop and setting x value like 340 to 350... and to know whether its entering the loop, i printed something.. now prints the movement it bounces back. that means it is entering the loop... and even the sound is now working in that loop Note: this problem is only with the right paddle, which is in the +ve x direction.... i will be glad if you help me out from this... expecting your reply... thank you... Chinmaya from India...
@sgeasley
@sgeasley 5 жыл бұрын
Yo my dudes, loving this channels 'simple' yet effective tutorials, thank you so much! Having alot of fun here :) Edit: Helps that you guys dont rush things and like to recap before moving onto next!
@AamirKhan-zy5yt
@AamirKhan-zy5yt 5 жыл бұрын
Which text editor he is using?
@alyz2798
@alyz2798 5 жыл бұрын
Microsoft visual studio code, free btw
@jackphillips497
@jackphillips497 5 жыл бұрын
Great video for beginners in python (like me) to learn a simple yet interesting game! I did it on windows and followed this video step by step pretty much and everything works perfectly. I was using python 2 and had to take away a bracket and add a colon on the 'if ' function in 'paddle and ball collisions". Overall amazing Video. :)
@jackphillips497
@jackphillips497 5 жыл бұрын
@@TokyoEdTech Your very welcome.
@julianwilliams2439
@julianwilliams2439 5 жыл бұрын
how do i make it so paddle a is able to be hit by the ball its not working!!!!
@lemoonadee
@lemoonadee 3 жыл бұрын
this was fun to learn
@TokyoEdTech
@TokyoEdTech 3 жыл бұрын
Thanks - glad to hear it!
@sliferslacker6763
@sliferslacker6763 4 жыл бұрын
Personal Time stamp, please ignore. 19:55
@wehavedonuts7767
@wehavedonuts7767 4 жыл бұрын
A. Human no
@goku445
@goku445 4 жыл бұрын
Which kind of browser you use? On Firefox if you quit (closing tab) a video half way and come back, your session is saved where you left it.
@Acidpop
@Acidpop 4 жыл бұрын
@@goku445 thats because of youtube not Firefox
@crunchygs8771
@crunchygs8771 4 жыл бұрын
@@Acidpop lmao ikr i legit hit facepalm when i read that thank you for protecting and serving *massive salute*.
@dominator1699
@dominator1699 5 жыл бұрын
im pretty sure i copied the code correctly but the paddles can go off screen, did i do something wrong or did he not code that part?
@peterkrogh1863
@peterkrogh1863 Жыл бұрын
Great tutorial, easy understandeble and good explaining on what does what, so oneself can improve a bit on the programming like not make the bat go off screen and whatever comes to mind :)
@tinker7722
@tinker7722 2 жыл бұрын
Thank you! Great tutorial! Very good style. It is fun to watch! So professional, so inspiring!👍
@EyiBillion
@EyiBillion 5 жыл бұрын
Thank you for the tutorial. it was mind blowing.
@gabrielchoimet6695
@gabrielchoimet6695 4 жыл бұрын
Thanks I love this without class and difficult code its perfect !
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
Glad you liked it!
@benaronson2410
@benaronson2410 5 жыл бұрын
please help! in the main game loop, where we try to get the ball to move, i keep getting an error that says "instance of turtle has no 'dx' or 'dy' member." How do I fix this???
@CT-qy2up
@CT-qy2up 4 жыл бұрын
at 20:30 i can't get the ball to bonce off the top of the screen it just stays on the y coronet 290 what do i need to do
@nier-mage8669
@nier-mage8669 4 жыл бұрын
having issues with sound on windows and the ball is just to fast for the paddle or whatever to keep up, what can I do to fix this.
@beter1838
@beter1838 4 жыл бұрын
you can change the speed of the ball in 'ball.dx = ?' and 'ball.dy = ?' its in the code where you created the ball i`ve set it to 0.3 and its working fine for me.
@el4f310
@el4f310 4 жыл бұрын
@@beter1838 wow,thank very much man!
@el4f310
@el4f310 4 жыл бұрын
thank you *
@punk199615
@punk199615 5 жыл бұрын
So, I was having trouble with the paddles not showing up and I moved the following code, [while True wn.update] after the paddle codes and then it started working!
@aprameyakannan4291
@aprameyakannan4291 5 жыл бұрын
same here
@jenaal-abbas330
@jenaal-abbas330 4 жыл бұрын
ohhhh so im gonna do that. thanks!
@dolphfps
@dolphfps 4 жыл бұрын
Instead of doing wasd, you can do the arrow keys, but you have to do capital letters, for example, Up, Down, Left, RIght.
@dolphfps
@dolphfps 4 жыл бұрын
@@TokyoEdTech :D you're we,come!
@enazzzz
@enazzzz 11 ай бұрын
he did use the arrow keys you just didn't watch through the whole video@@dolphfps
@dolphfps
@dolphfps 11 ай бұрын
that was 3 years ago-@@enazzzz
@enazzzz
@enazzzz 11 ай бұрын
lol i just saw the time srry@@dolphfps
@k.alipardhan6957
@k.alipardhan6957 5 жыл бұрын
28:00 the giant if statement should be nested if statements, since they are a lot more readable and noob friendly
@viljar_5339
@viljar_5339 5 жыл бұрын
"raw_input" is not defined. Me: Well, that's because there is no "raw_input" in my code
@talhanawaz5486
@talhanawaz5486 5 жыл бұрын
U can use simple "input ( ) " either because raw_input is no longer supported in python 3
@EJStudios17
@EJStudios17 4 жыл бұрын
I noticed that false debug notices can appear if something isn’t completely true, say you said print(‘blah , text_q , blah blah’) And because you don’t put the ‘ after getting python to put input in.
@iamsatyam9689
@iamsatyam9689 4 жыл бұрын
@@TokyoEdTech thanks :)
@Glitch1125
@Glitch1125 4 жыл бұрын
I like my input cooked
@rohanyadav8573
@rohanyadav8573 4 жыл бұрын
hey I'm facing a bug, do you mind helping me out on this, "whenever the ball bounces from the corners it's speed increases for a fraction of time, and gets shot in the direction it's following... "
@saun_sa
@saun_sa 4 жыл бұрын
Looks like turtle module got some weird physics bruh
@notanamehere8355
@notanamehere8355 4 жыл бұрын
Mine too but Ok
@tankytitan1304
@tankytitan1304 4 жыл бұрын
Check your move the ball function
@av465
@av465 4 жыл бұрын
It happened with me too but it was because i used + not * in the if cause
@xxjtoot8764
@xxjtoot8764 5 жыл бұрын
im trying to get the ball to move but an error pops up saying the ball is not defined even though im following along exactly
@dausband79
@dausband79 4 жыл бұрын
Building a Pong game This does put a smile on my face
@snatchbandicoot
@snatchbandicoot 5 жыл бұрын
Just wondering... why do you like using 4 spaces instead of a tab? I have always used tab and the computer automatically puts a tab in certain situations, so why change it up?
@Set_Abominae
@Set_Abominae 5 жыл бұрын
It's because of the PEP8 of Python. Read about it.
@nathansmith3608
@nathansmith3608 5 жыл бұрын
maybe it's because Developers Who Use Spaces Make More Money Than Those Who Use Tabs stackoverflow.blog/2017/06/15/developers-use-spaces-make-money-use-tabs/ half kidding; Python style guide recommends indents using 4 space chars, & Python's hot among data scientists & at Google, which I suspect explains the correlation they found
@johnniegilkerson4724
@johnniegilkerson4724 5 жыл бұрын
Im running this code in visual studio code on windows 10, everything works but the ball goes way too fast?
@leahr.529
@leahr.529 5 жыл бұрын
johnnie gilkerson try using points like 0.2
@k01b01
@k01b01 5 жыл бұрын
Mine also does not work. I tried every speed option and it goes the same fast speed.
@stolencinnamon6230
@stolencinnamon6230 5 жыл бұрын
same here anyone knows why ?
@k01b01
@k01b01 5 жыл бұрын
@@stolencinnamon6230 You still having the problem?
@sevcandincel
@sevcandincel 5 жыл бұрын
First sorry for bad english. johnnie gilkerson its cause of it is performance based move. İ mean, if your computer fast execute the while loop, your ball will move fatser. You should use velocity based moving. For this, you can use time function from time module. This function give time as seconds. So you can calculate how many seconds a loop will last. Then you should multiple this time with ball.dx and ball.dy.
@s.dh29
@s.dh29 3 жыл бұрын
i was so happy when u said u werent using OOP, i cant get my head around it!
@SuperDavedm
@SuperDavedm 4 жыл бұрын
Great tutorial, I was wanting to make a more interesting version of pong and using this a base. How would you suggest dynamically updating the background as the game runs?
@harshitgupta5444
@harshitgupta5444 3 жыл бұрын
adding a controller control or mouse control maybe, simple yet good creativity
@nickw22689
@nickw22689 5 жыл бұрын
Anyone who's built and run this, does the "spin" of the ball change depending on the velocity and placement of the paddles when the ball hits?
@alexshao9916
@alexshao9916 4 жыл бұрын
This version of pong has no spin specifically coded in. In the original game and more complex versions, that would be a feature to add, but this is just a basic overview on the general ideas of the game itself.
@kartavyabagga
@kartavyabagga 4 жыл бұрын
print("Cool Stuff Bro!!! I made my own changes in it Thanks for this tutorial it's very helpful...")
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
Thanks - glad you liked it!
@374O
@374O 3 жыл бұрын
@@TokyoEdTech wrong video Lmfao i just watched your space invader one
@CheatGang
@CheatGang 4 жыл бұрын
ima get back into coding starting today
@TokyoEdTech
@TokyoEdTech 4 жыл бұрын
No time like the present!
@timmithytebow3772
@timmithytebow3772 4 жыл бұрын
I can’t get the paddle to go up when I press w
@yeesquad7196
@yeesquad7196 4 жыл бұрын
i cant either
@Ledinos1
@Ledinos1 5 жыл бұрын
Great tut. I've been trying to improve the game by adding ball speed-up after every paddle hit but i cannot figure it out :/ Can someone help ?
@simonmoberg8906
@simonmoberg8906 5 жыл бұрын
Try playing around with where you have this (in the collision detection with paddles): Instead of: ball.dx() *= -1 do ball.dx() *= -2 This will invert the current direction and also double the speed. For me, I find the increase of 50% (1.5) be quite alright if you start quite slow. You'll need to reset the speed at the instant when you increase the score.
@josephreed3287
@josephreed3287 4 жыл бұрын
Simon Moberg yeah. I did the same thing but had to change it to *= 1.1 because it was a bit too fast to rally for long. Also make sure you reset the dx when you score. Or else it speeds up indefinitely. Lol
@simonmoberg8906
@simonmoberg8906 2 жыл бұрын
@Uzi the fish I'm sorry but I have forgotten about this stuff :(
@buddyruns14
@buddyruns14 4 жыл бұрын
even copy /pasting your code into pyCharm gives me the black window only, the paddle doesn't show up. Any idea why?
@gv6758
@gv6758 4 жыл бұрын
When I press and hold the keys that trigger the movement, they do the movement repeatedly as long as I'm holding the key, which is what I expect but, I don't know why, if I press and hold the key that triggers the down movement on the paddle b, it only does it one time. It's not a keyboard problem if anyone's wondering
@dotcom4204
@dotcom4204 4 жыл бұрын
so i tried to do the sound part but instead of the bounce.wav playing, i just got a windows error sound, which is just as good so im happy
@alimz3134
@alimz3134 4 жыл бұрын
same i got that 2
@Ardeenio
@Ardeenio Жыл бұрын
Thanks to this tutorial, I accidentally made it so the ball jukes you out by going fast and slow. It's not a bug, it's a feature 😁
@davidross1332
@davidross1332 Жыл бұрын
did you figure out why the ball actually goes slow sometimes? haha
@yamatanoorochi3149
@yamatanoorochi3149 11 ай бұрын
What's so different between your code and his? Mine does the same but there is no difference at all maybe it's the python version or your pc model? I'm using py 3.11 He mentioned in the vid that the ideal speed depends on the pc you have so maybe the variation in speed is also because of that
@TLgaming737
@TLgaming737 2 жыл бұрын
awesome! thanks for the help. 😃
@TokyoEdTech
@TokyoEdTech 2 жыл бұрын
You're welcome - keep on codin'!
@krishanujoarder2935
@krishanujoarder2935 5 жыл бұрын
This one works fine. I have tried executing other game codes in KZfaq, it did not work. Awesome tutorial.
@climbingcreeper1609
@climbingcreeper1609 4 жыл бұрын
The ball keeps changing speed... please help
@kindersmith8407
@kindersmith8407 4 жыл бұрын
yeah it happens to me too, but it doesnt impact preformance......... i'lll just deal with it
@TheBerkaay
@TheBerkaay 3 жыл бұрын
Thank you for the tutorial. I found it very useful. I have a question though, when I try to move both paddles at the same time (giving the program two inputs simultaneously) the program gives priority to first input given. Is there any way to fix this? Or this is because the turtle library? I am saying this because in some games, mario for instance, you can jump but you can also jump to left or right by pushing 2 buttons at the same time. Thanks in advance.
@TokyoEdTech
@TokyoEdTech 3 жыл бұрын
You're welcome. That is a limitation of the turtle module - try Pygame instead.
@annielouise1141
@annielouise1141 3 жыл бұрын
my ball is not moving....
@iudizm
@iudizm 5 жыл бұрын
I made it... in 2 hours, but its awesome. Thx for all the wisdom hehe
@vampiriclion1176
@vampiriclion1176 4 жыл бұрын
I come from java and I'm shocked because of the simplicity of py. I began to study Python few days ago and I love it
@samuelmodig2816
@samuelmodig2816 3 жыл бұрын
Thank you for a great tutorial! So, how do I export this as a finished .exe game?
@gokulravi7133
@gokulravi7133 5 жыл бұрын
Dude my ball speed at the game is really high.. After doing the same as u did.. How can i reduce it.. And keep it to a normal
@rafaelperezmederos6958
@rafaelperezmederos6958 5 жыл бұрын
also have the same issue
@AdurxIsd
@AdurxIsd 5 жыл бұрын
dunno if you still have the problem, but reducing ball.dx and ball.dy to something like 0.2 insetad of 2 should help.
@jonastangen4601
@jonastangen4601 5 жыл бұрын
i found a flaw where the game could not register, moving paddle a and b at the same time. only one of the would register once at a time.
@mishaan1791
@mishaan1791 5 жыл бұрын
was fun to do this thanks man
@cesag1329
@cesag1329 5 жыл бұрын
28:49 my ball trespasses the paddle b :(
@ibrah1m
@ibrah1m 4 жыл бұрын
were u able to fix this?
@randmorf
@randmorf 4 жыл бұрын
If the top and bottom parts of your paddle seems not to work, it's because in the code for the ball colliding with the paddle uses +40 and -40 to delimit the paddle. The paddle is 100px tall, and the code above uses only the middle 80px. To make the full paddle workable, the code should use +50 and -50. This change will need to be made in two places (remember those two horribly long if statements? That's where.).
@carboncuber3147
@carboncuber3147 4 жыл бұрын
When I ran the ball moving on my computer for the first time it yeeted itself off the screen.
@starclan2303
@starclan2303 4 жыл бұрын
its a yeetball
@Gesso64
@Gesso64 4 жыл бұрын
turn the speed down
@tess.cantthinkofaname2956
@tess.cantthinkofaname2956 4 жыл бұрын
Yeah that happened to me I ended having to change the speed to 0.1
@Moomoocowmeoww
@Moomoocowmeoww 5 жыл бұрын
Thank you for this practical presentation. Explained alot for me man. Appreciated
@tamassvecz571
@tamassvecz571 Жыл бұрын
Very useful tutorial! Thank you very much from Hungary! 😊
Make Pong With Python!
1:12:42
Tech With Tim
Рет қаралды 115 М.
Pygame Tutorial for Beginners - Python Game Development Course
2:15:49
freeCodeCamp.org
Рет қаралды 2 МЛН
Running With Bigger And Bigger Feastables
00:17
MrBeast
Рет қаралды 157 МЛН
Пройди игру и получи 5 чупа-чупсов (2024)
00:49
Екатерина Ковалева
Рет қаралды 4,1 МЛН
The Joker kisses Harley Quinn underwater!#Harley Quinn #joker
00:49
Harley Quinn with the Joker
Рет қаралды 10 МЛН
12 Beginner Python Projects - Coding Course
3:00:29
freeCodeCamp.org
Рет қаралды 4,3 МЛН
15 Python Projects in Under 15 Minutes (Code Included)
12:37
Tech With Tim
Рет қаралды 2 МЛН
The World's Tallest Pythagoras Cup-Does It Still Drain?
10:05
The Action Lab
Рет қаралды 347 М.
Fullstack Drag & Drop Notes App with React
1:49:28
freeCodeCamp.org
Рет қаралды 40 М.
Python Django Web Framework - Full Course for Beginners
3:45:41
freeCodeCamp.org
Рет қаралды 4,3 МЛН
Python Project Tutorial - Your First Python Project
1:02:35
freeCodeCamp.org
Рет қаралды 190 М.
LEGO Mechanical Speed-Graphing System
22:36
Banana Gear Studios
Рет қаралды 398
Running With Bigger And Bigger Feastables
00:17
MrBeast
Рет қаралды 157 МЛН