VehiclesFashionRecipesBlogsHuntTravelsSportFunHandmadeITEducation
Mini-Games
x

x
zakruti.com » IT - Software » freeCodeCamp.org
Python Game Tutorial: Pong

Python Game Tutorial: Pong

FBTwitterReddit

video description

Rating: 4.0; Vote: 1
A Pong clone game tutorial for beginners using Python 3. --Course contents -- -- (00:00) Part I: Introduction and the basic window setup Code: http://christianthompson.com/sites/default/files/Pong/Pong1.py -- (03:32) Part II: Add game objects to the screen (Paddles and Ball) Code: http://christianthompson.com/sites/default/files/Pong/Pong2.py -- (09:15) Part III: Moving the Paddles Code: http://christianthompson.com/sites/default/files/Pong/Pong3.py -- (15:06) Part IV: Moving the ball Code: http://christianthompson.com/sites/default/files/Pong/Pong4.py -- (24:10) Part V: Colliding with the Paddles Code: http://christianthompson.com/sites/default/files/Pong/Pong5.py -- (30:47) Part VI: Scoring Code: http://christianthompson.com/sites/default/files/Pong/Pong6.py -- (37:57) Part VII: Adding Sound Code: http://christianthompson.com/sites/default/files/Pong/Pong7.py - Sound file: http://christianthompson.com/sites/default/files/Pong/bounce.wav - Finished Code: http://christianthompson.com/sites/default/files/Pong/pong.py Tutorial from Christian Thompson. Check out his YouTube channel: https://www.youtube.com/channel/UC2vm-0XX5RkWCXWwtBZGOXg
Date: 2022-03-14

Comments and reviews: 10


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

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

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

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

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

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

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

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

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