I am making a Pong game program using Python. There is a white line in the middle of the screen, which I can't figure out why is there. I am pasting my code and the output (the issue) below.
import turtle
wm = turtle.Screen()
wm.title("Pong by Tharv")
wm.bgcolor("black")
# wm.setup(width=800, hieght=300)
wm.tracer(0)
# Bat A
batA = turtle.Turtle()
batA.speed(0)
batA.shape("square")
batA.shapesize(stretch_wid=5, stretch_len=1)
batA.color("white")
batA.penup()
batA.goto(-350, 0)
# Bat B
batB = turtle.Turtle()
batB.speed(0)
batB.shape("square")
batB.color("white")
batB.shapesize(stretch_wid=5, stretch_len=1)
batB.penup
batB.goto(350, 0)
# Ball
ball = turtle.Turtle()
ball.speed(0)
ball.shape("circle")
ball.color("white")
ball.penup()
ball.goto(0, 0)
# maingameloop
while True:
wm.update()
I have tried commenting out each line of code for the 'batB' (refer to the code please.) , but still can't understand why is there a white line in the middle.
CodePudding user response:
You forgot parentheses in your call to batB.penup
, so the pen isn't actually raised, causing a line to be drawn when you move back to the center.
Add parentheses and it should work.
# Bat B
batB = turtle.Turtle()
batB.speed(0)
batB.shape("square")
batB.color("white")
batB.shapesize(stretch_wid=5, stretch_len=1)
batB.penup # Should be penup()
batB.goto(350, 0)
CodePudding user response:
You didn't add parentheses in Bat B in batB.penup