'can't get rid of arrow in python using turtle
im trying to build a pong game but i cant get rid of a line
import turtle
sc = turtle.Screen()
sc.setup(width=1000, height=1000)
sc.title("pong")
sc.bgcolor("black")
def paddle_a():
paddle = turtle.Turtle()
paddle.color("white")
paddle.shape("square")
paddle.shapesize(stretch_wid=5, stretch_len=2)
paddle.goto(-400, 0)
paddle.speed(0)
paddle.penup()
def paddle_b():
pass
while True:
paddle_a()
sc.update()
ive tried turtle.turtlehide() but no luck
Solution 1:[1]
The problem is that when you move turtle to (-400, 0), the pen is down, it will draw line. Solution is to move penup() method before the movement.
def paddle_a():
paddle.penup() # <--- Move here
paddle.goto(-400, 0)
paddle.speed(0)
Solution 2:[2]
You just needed to lift the pen up at the correct position (before the goto).
I added a penup in the correct place for you (it is commented in the code below).
import turtle
sc = turtle.Screen()
sc.setup(width=1000, height=1000)
sc.title("pong")
sc.bgcolor("black")
def paddle_a():
paddle = turtle.Turtle()
paddle.color("white")
paddle.shape("square")
paddle.shapesize(stretch_wid=5, stretch_len=2)
paddle.penup() # <------------------------- added a penup here
paddle.goto(-400, 0)
paddle.speed(0)
paddle.penup()
def paddle_b():
pass
while True:
paddle_a()
sc.update()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ynjxsjmh |
| Solution 2 | D.L |

