Reputation: 127
I'm trying to create the Pong game, and for now I just want to draw the paddles.
import turtle
wn = turtle.Screen()
wn.title("Pong by @Edgedancer3791")
wn.bgcolor("black")
wn.setup(width=800, height=600)
wn.tracer(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)
It instantly crashes, without showing the paddles or anything. I also don't get any error message. I really don't know what to do. I've made a bit of research and found that with turtle.done() it doesn't crash, but it still doesn't draw anything on the screen.
Upvotes: 1
Views: 107
Reputation: 1447
your program is fine, it's not crashing but executing very quickly and then ending. You just need to keep the program active with some sort of while loop. Try adding to the end of your program:
while True: # This is your game loop
wn.update() # Update screen
Then you can add your game logic into the game loop.
Upvotes: 1