from turtle import *
import turtle
from random import randint
import sys
#屏幕初始化
screen = turtle.Screen()
screen.title("幸运大转盘 转转转~")
screen.setup(480,450)
screen.bgpic("转盘.png") #背景图片
screen.delay(0)
#制定点位置
list1 = ((8,30),(20,50),(0,120),(-20,50),(-8,30))
screen.addshape("myarrow",list1) #添加自定义形状
#绘制箭头
arrow = Turtle(shape = "myarrow")
arrow.color("purple") #定义箭头颜色
arrow.rt(0) #初始化箭头位置
rotateNumber = randint(50,100) #随机产生旋转次数50-100之间
angle = 45 #定义每次旋转45度
def rotate():
global rotateNumber,angle
screen.onkeypress(None,"space") #按空格键启动转盘
if rotateNumber>0: #rotateNumber非0时转动
if rotateNumber<20:
angle = rotateNumber #rotateNumber小于20旋转角度变小(减速)
arrow.rt(angle) #向右旋转angle度
rotateNumber = rotateNumber - 1
screen.ontimer(rotate,20) #计时器(每隔20秒调用一次rotate)
else: #rotateNumber为0停止转动
rotateNumber = randint(50,100) #随机产生旋转次数50-100之间
angle = 45 #定义每次旋转45度
screen.onkeypress(rotate,"space") #按空格键启动转盘
screen.onkeypress(rotate,"space")
screen.listen() #开启监听,将鼠标定位到画布
screen.mainloop()
没有合适的资源?快使用搜索试试~ 我知道了~
使用海龟(turtle)模块实现幸运大转盘.zip
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共2个文件
py:1个
png:1个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 102 浏览量
2024-02-22
17:22:00
上传
评论
收藏 359KB ZIP 举报
温馨提示
使用海龟(turtle)模块实现幸运大转盘.zip
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 2 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/7be31534d5d34df890f6ea820718b8ed_liaozp88.jpg!1)
徐浪老师
- 粉丝: 6532
- 资源: 6880
![benefits](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-1.c8e153b4.png)
下载权益
![privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-2.ec46750a.png)
C知道特权
![article](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-3.fc5e5fb6.png)
VIP文章
![course-privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-4.320a6894.png)
课程特权
![rights](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-icon.fe0226a8.png)
开通VIP
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)