
Python Game Tutorial: Pong
video description
Date: 2022-03-14
Related videos
Comments and reviews: 10
tcrmnk
Great tutorial! I'm having some trouble though. When my ball goes to the top or bottom border it doesn't bounce, it just moves along the top border and flashes until it goes off screen. Here is that part of my code:
if ball.ycor()>290:
ball.sety(290)
ball.dy -= -1
if ball.ycor() < -290:
ball.sety(-290)
ball.dy -= -1
if ball.xcor() > 365:
ball.goto(0,0)
ball.dx -= -1
if ball.xcor() < -365:
ball.goto(0,0)
ball.dx -= -1
reply
Great tutorial! I'm having some trouble though. When my ball goes to the top or bottom border it doesn't bounce, it just moves along the top border and flashes until it goes off screen. Here is that part of my code:
if ball.ycor()>290:
ball.sety(290)
ball.dy -= -1
if ball.ycor() < -290:
ball.sety(-290)
ball.dy -= -1
if ball.xcor() > 365:
ball.goto(0,0)
ball.dx -= -1
if ball.xcor() < -365:
ball.goto(0,0)
ball.dx -= -1
reply
Numb
Great lesson!
I don't know why, but every time I run the program my PC box starts screaming, literally ;-;.
My PC is 32 GB RAM so it's perfect for programming. I created a voice assistant and a few simple AIs and never experienced that trouble, even with GUI. (yes, I create AIs and I'm learning how to create basic games, we all have to start somewhere).
Maybe someone experienced this issue or know something about it?
reply
Great lesson!
I don't know why, but every time I run the program my PC box starts screaming, literally ;-;.
My PC is 32 GB RAM so it's perfect for programming. I created a voice assistant and a few simple AIs and never experienced that trouble, even with GUI. (yes, I create AIs and I'm learning how to create basic games, we all have to start somewhere).
Maybe someone experienced this issue or know something about it?
reply
MOHD
bro what is thy thing that thy are typing the code on, because I want to know what that is because I am using trinket, which is like a free to use website that lets thy create code, and its showing me an error that says -NameError: name 'turtle' is not defined on line 5 in main.py--, and I don't know what's going on because I have done everything thy has on thy screen, yet my code refuses to work.
reply
bro what is thy thing that thy are typing the code on, because I want to know what that is because I am using trinket, which is like a free to use website that lets thy create code, and its showing me an error that says -NameError: name 'turtle' is not defined on line 5 in main.py--, and I don't know what's going on because I have done everything thy has on thy screen, yet my code refuses to work.
reply
Marco
Hello I am new on Python and i have a question about the Paddle and Ball Collision. My code looks the same as yours.The ball collided with the right paddle and flies then to left paddle. The Problem is, that the ball flies through the left paddle like it isn't here. Does anybody have the same problem and know an answer for that?
thx ;D
reply
Hello I am new on Python and i have a question about the Paddle and Ball Collision. My code looks the same as yours.The ball collided with the right paddle and flies then to left paddle. The Problem is, that the ball flies through the left paddle like it isn't here. Does anybody have the same problem and know an answer for that?
thx ;D
reply
Jakub
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)
reply
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)
reply
Sergio
So I keep getting a TypeError: unsupported operand type(s) for +: 'method' and 'int' when the ball hits the -border- please help i did everything exactly.... Only having this issue after I tried to get the ball to hit the paddles......
reply
So I keep getting a TypeError: unsupported operand type(s) for +: 'method' and 'int' when the ball hits the -border- please help i did everything exactly.... Only having this issue after I tried to get the ball to hit the paddles......
reply
HzA
Just wanted to make this comment to anyone trying this tutorial recently and is finding the issue where the graphics screen will not stay open. To fix this, you need to add the line at the end of your code which is turtle.done()
reply
Just wanted to make this comment to anyone trying this tutorial recently and is finding the issue where the graphics screen will not stay open. To fix this, you need to add the line at the end of your code which is turtle.done()
reply
Isaac
When adding:
while True():
wn.update()
Ball.setx(Ball.xcor() + Ball.dx)
Ball.sety(Ball.xcor() + Ball.dy)
It gives me a error code:
TypeError: -bool- object is not callable
Any help with this
reply
When adding:
while True():
wn.update()
Ball.setx(Ball.xcor() + Ball.dx)
Ball.sety(Ball.xcor() + Ball.dy)
It gives me a error code:
TypeError: -bool- object is not callable
Any help with this
reply
BlackViperCat
at 13:06 when i try to test that and then press w it wont work i dont know if the programm im using is blocking that w key or something but it wont move Im using pycharm by the way
reply
at 13:06 when i try to test that and then press w it wont work i dont know if the programm im using is blocking that w key or something but it wont move Im using pycharm by the way
reply
Marcus
I need help when try to set the background color to black it says bad color string. I am on windows 11. And when I change the height and width it says application has been DESTROYED. WHY?
reply
I need help when try to set the background color to black it says bad color string. I am on windows 11. And when I change the height and width it says application has been DESTROYED. WHY?
reply
Add a review, comment
Other channel videos















