Python - AttributeError: 'Turtle' object has no attribute 'dx'

 
Vista:
sin imagen de perfil
Val: 49
Ha mantenido su posición en Python (en relación al último mes)
Gráfica de Python

AttributeError: 'Turtle' object has no attribute 'dx'

Publicado por Kid (24 intervenciones) el 17/12/2019 14:35:20
Programando el juego PONG en el módulo turtle, me salta este error:

1
2
3
4
5
6
7
8
9
10
11
12
while True:
	ball.setx(ball.xcor()+ball.dx)
	ball.sety(ball.ycor()+ball.dy)
	if ball.ycor()>290:
		ball.sety(290)
		ball.dy*=-1
 
 
Traceback (most recent call last):
  File "<pyshell#73>", line 2, in <module>
    ball.setx(ball.xcor()+ball.dx)
AttributeError: 'Turtle' object has no attribute 'dx'
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de joel
Val: 3.475
Oro
Ha mantenido su posición en Python (en relación al último mes)
Gráfica de Python

AttributeError: 'Turtle' object has no attribute 'dx'

Publicado por joel (901 intervenciones) el 17/12/2019 16:26:36
Puedes publicar el código entero para poder probarlo?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
sin imagen de perfil
Val: 49
Ha mantenido su posición en Python (en relación al último mes)
Gráfica de Python

AttributeError: 'Turtle' object has no attribute 'dx'

Publicado por Kid (24 intervenciones) el 18/12/2019 02:02:36
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
>>> import turtle
>>> wn=turtle.Screen()
>>> wn.setup(weight=800,height=600)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: setup() got an unexpected keyword argument 'weight'
>>> wn.setup(width=800,height=600)
>>> wn.bgcolor("black")
>>> pad=turtle.Turtle()
>>> pad.penup()
>>> pada=turtle.Turtle()
>>> pada.penup()
>>> pad.color("blue")
>>> pad.shape("square")
>>> pad.speed(0)
>>> pad.shapesize(stretch_wid=5,stretch_len=1)
>>> pad.goto(-350,0)
>>> pada.color("red")
>>> pada.shape("square")
>>> pada.shapesize(stretch_wid=5,stretch=len=1)
  File "<stdin>", line 1
    pada.shapesize(stretch_wid=5,stretch=len=1)
                                            ^
SyntaxError: invalid syntax
>>> pada.shapesize(stretch_wid=5,stretch_len=1)
>>> pada.goto(350,0)
>>>
>>> #FUNCIONES DE MOVIMIENTO DE pad Y pada
...
>>> def pad_up():
... y=paddle.ycor()
  File "<stdin>", line 2
    y=paddle.ycor()
    ^
IndentationError: expected an indented block
>>> def pad_up():
...     y=pad.ycor()
...     y+=20
...     pad.sety(y)
...
>>> def pad_down():
...     y=pad.ycor()
...     y-=20
...     pad.sety(y)
...
>>> wn.listen()
>>> wn.onkeypress(pad_up, "w")
>>> wn.onkeypress(pad_down, "s")
>>>
>>> def pada_up():
...     y=pada.ycor()
...     y+=20
...     pada.sety(y)
...
>>> def pada_down():
...     y=pada.ycor()
...     y-=20
...     pada.sety(y)
...
>>> wn.onkeypress(pada_up, "Up")
>>> wn.onkeypress(pada_down, "Down")
>>>
>>> #BORDES DE LA PANTALLA/LÍMITES
...
>>> ball=turtle.Turtle()
>>> ball.shape("circle")
>>> ball.penup()
>>> ball.color("white")
>>> ball.speed(0)
>>>
>>> While True:
  File "<stdin>", line 1
    While True:
             ^
SyntaxError: invalid syntax
>>> while True:
...     #MOVIMIENTO DE LA BOLA
...     ball.setx(ball.xcor()+ball.dx)
...     ball.sety(ball.ycor()+ball.dy)
...     if ball.ycor()>290:
...             ball.sety(290)
...             ball.dy*=-1
...
Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
AttributeError: 'Turtle' object has no attribute 'dx'
>>>
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil
Val: 49
Ha mantenido su posición en Python (en relación al último mes)
Gráfica de Python

AttributeError: 'Turtle' object has no attribute 'dx'

Publicado por Kid (24 intervenciones) el 18/12/2019 21:40:25
Entendido, muchísimas gracias por la información, las herramientas y por haberte tomado el tiempo de buscarlo y responder. Un saludo!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar