python - 新版python中代码发生了变化
问题描述
我需要一些帮助,因为我现在正在编写一个乒乓球游戏,但是帮助我使用 python 版本的视频是 3.6,我正在用 python 3.8 编写它,我遇到了一个问题,我得到的错误是
"turtle has no attribute dx"
,有人知道我要写什么新版本的python吗?
while True:
wn.update()
ball.setx(ball.xcor() + ball.dx)
ball.sety(ball.ycor() + ball.dy)
这就是让球移动的代码。
解决方案
我从你说的地方得到了代码, http://christianthompson.com/sites/default/files/Pong/pong.py
在这里,在这部分代码中
# Ball
ball = turtle.Turtle()
ball.speed(0)
ball.shape("square")
ball.color("white")
ball.penup()
ball.goto(0, 0)
ball.dx = 2
ball.dy = 2
他定义了 dx 和 dy 的值。这不是版本的错误。
推荐阅读
- vulkan - 是否有一个好的 HLSL 到 SPIR-V 编译器?
- node.js - 无法删除具有指定时间戳的消息
- node.js - 如何在此路由路径中获取此帖子参数 ID?
- spring - 支持多种日期格式的 Kafka JsonDeserializer
- sas - Sas如何在显示器中有2个byvar
- c - 与“for循环”输出混淆
- java - 如何与 bin、conf 等少数目录一起构建战争
- javascript - 无法在 Angular 中访问对象属性
- r - 在 Rscript 中使用从 ShinyApp 获取的变量
- sql-server - Azure 数据同步可以用作主到主数据库复制吗?