Hello
I enjoyed reading Shane Duggan’s tutorial on building a pong game using turtle.
However, i want to understand it before I code along, and I cant see in the code where the movement of the ball is coming from. dx and dy are not set for the ball. there is a ‘ball_speed’ value in game_rules, but it is never used. Is there a section missing, or am I missing something?
Thanks for responding.
So paddle1.dy is set when the paddle object is defined, but ball.dy is not set when the ball is defined, so it looks like ball.sety(ball.ycor() + ball.dy) would set y to ball.ycor() + an undefined value.
I suspect it has something to do with ‘ball_speed’, which is defined under game rules but never referenced.
I am pretty new to python, so I’m happy to be told i’m misunderstanding something!
Thanks again
thanks Randell, I’m glad i was reading it correctly. So I can see how I could set ball.dx based on ball_speed, but I’m unclear how movement would be achieved on the y axis. Seems like the ball would just ping left to right.
I remember the original game introduced y axis movement if the paddle was moving when it made contact with the ball.
yeah, annoying right! I’m sure it’s not that hard, and surely educational, to figure it out though. I dont have any spare time just now, but if you do get anywhere with it please share! setting dx would be easy i think, but see my comment abovr about introducing y movement. good luck
and then putting all the conditionals in a while True loop. But it’s still got a lot of bugs to work out. This tutorial was not vetted at all. Now the program runs but nothing works. Github solution using Turtle Here is a much better example.