"""幸运大抽奖小程序,本作品要求安装pygame模块才有声音
按空格键开始抽奖。
"""
# 1、模块导入
import sys
from turtle import *
from random import randint
# 2、屏幕初始化
screen = Screen()
screen.title("幸运大抽奖 by lixingqiu")
screen.setup(800,600)
screen.bgpic("转盘.png")
screen.delay(0)
vertex = ((0,0),(25,0),(25,100),(50,100),(0,150),(-50,100),(-25,100),(-25,0)) # 顶点表
screen.addshape("bigarrow",vertex) # 添加大箭头各顶点到形状列表
class Sprite(Turtle):
def __init__(self,costume_list,x,y):
Turtle.__init__(self,visible=False)
self.up()
self.costume_amount = len(costume_list)
self.costume_list = costume_list # 造型列表
self.costume_index = 0 # 初始造型索引
self.goto(x,y) # 定位
self.showturtle()
sprite1 = Sprite(sprite1_images,-300,200)
sprite2 = Sprite(sprite2_images,300,200)
sprite3 = Sprite(sprite3_images,-300,-200)
sprite4 = Sprite(sprite4_images,300,-200)
# 6、箭头角色与旋转
arrow = Turtle(shape = "bigarrow")
arrow.color("black","purple")
numbers = randint(50,100) # 旋转次数
angle = 30 # 每次旋转的角度
screen.listen()
screen.mainloop()
下载完整源代码与素材,请
需要浏览更多吗?
成为会员后,登陆才能继续浏览!联系微信scratch8即可办理会员。
(会员专属:能浏览所有文章,下载所有带链接的Python资源。)

