|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区
您需要 登录 才可以下载或查看,没有账号?立即注册
×
"""勇闯黑暗迷宫,迷宫会停电,仅凭记忆去碰小花!"""from sprites import *from winsound import PlaySound,SND_ASYNCPlaySound('勇闯.wav',SND_ASYNC)screen = Screen()screen.setup(640,480)screen.title('勇闯黑暗迷宫') # 设定标题ball = Sprite(1) # 新建小球角色ball.color('black')ball.bk(300)ball.pensize(20)ball.pendown()ball.fd(400)ball.penup()ball.goto(0,250)ball.pendown()ball.goto(0,100)ball.penup()ball.goto(0,-250)ball.pendown()ball.goto(0,-100)ball.penup()ball.goto(160,100)ball.pendown()ball.goto(160,-100)ball.penup()ball.goto(-310,230) # 定位到这开始画黑色边框ball.pendown()for _ in range(2):ball.fd(610)ball.rt(90)ball.fd(460)ball.rt(90)ball.penup()ball.goto(-200,-150) # 最终定位到这ball.say('按方向箭头\n操作我碰到小花',10,False)flower = Sprite('res/flower.png') # 新建小花角色flower.goto(-200,150) # 小花定位到这里w = Sprite(visible=False) # 写字的角色w.goto(-100,30) # 定位到(-100,30)info = "马上要停电,请立即记住迷宫布局"ft = ('',23,'normal')w.write(info) # 写提示信息w.wait(4) # 等待4秒钟w.goto(0,30) # 定位到(0,30)# 下面是写倒计时3,2,1for x in range(3):w.clear()w.write(3-x,align='center',font=ft)w.wait(1)w.clear()screen.bgcolor('black') # 把背景设为黑色leftkey = Key('Left') # 新建左方向箭头rightkey = Key('Right') # 新建右方向箭头upkey = Key('Up') # 新建上方向箭头downkey = Key('Down') # 新建下方向箭头screen.listen() # 监听屏幕按键flag = None以下代码省略...... |
|