用户:
今天嘉然。。额。。让我想想查看:0 回复:0 评论:0 创建时间:2021-08-17T20:55:49
【作品展示】

【作品介绍】
抛硬币模拟器--欧气测试器!!!希望它能给你们带来好运气!!
NBGLASS©版权所有,希望你们在不抄袭的同时也开心地赞赏本创作者哦~
(此作费了作者5个半小时的创作心血,希望你们能够喜欢!)
么么哒~
【作品源代码】
import turtle
import random
import time
myscreen = turtle.Screen()
mypen = turtle.Pen()
mypen.speed(0)
mypen.pensize(5)
mypen.hideturtle()
mypen.penup()
mypen.backward(350)
myscreen.bgcolor("lightskyblue")
mypen.write("此游戏为NBGLASS©版权所有,请勿抄袭本作,否则后果自负。",font = ("文泉驿正黑",20))
time.sleep(1)
mypen.clear()
mypen.goto(-125, 150)
mypen.write("健康游戏忠告:",font = ("文泉驿正黑",30))
mypen.goto(-225, 50)
mypen.write("喵不良游戏,拒绝盗版游戏。",font = ("文泉驿正黑",25))
mypen.goto(-225, 0)
mypen.write("注意自我保护,谨防受喵上当。",font = ("文泉驿正黑",25))
mypen.goto(-225, -50)
mypen.write("适度游戏益脑,沉迷游戏伤身。",font = ("文泉驿正黑",25))
mypen.goto(-225, -100)
mypen.write("合理安排时间,享受健康生活。",font = ("文泉驿正黑",25))
time.sleep(2)
mypen.clear()
mypen.penup()
mypen.goto(0, 0)
already_played = 0
option = turtle.textinput('准备好了吗?', '准备好了按Enter ;没有,要重来按任意字符或数字~')
if option == '':
rounds = (turtle.textinput('你要玩几回?', '请输入你想玩的回合数~'))
def is_number(s):
try:
float(s)
return True
except ValueError:
pass
try:
import unicodedata
unicodedata.numeric(s)
return True
except (TypeError, ValueError):
pass
return False
panduan = (is_number(rounds))
if panduan == True:
rounds = int(rounds)
while already_played < rounds:
价值 = random.randint(1, 100)
mypen.clear()
mypen.goto(-25,-25)
computer = random.randint(1, 2)
mypen.pencolor('purple')
mypen.write("3",font = ("文泉驿正黑",100))
time.sleep(1)
mypen.clear()
mypen.write("2",font = ("文泉驿正黑",100))
time.sleep(1)
mypen.clear()
mypen.write("1",font = ("文泉驿正黑",100))
time.sleep(1)
mypen.clear()
mypen.pencolor("red")
mypen.goto(0,0)
if (computer == 1):
mypen.dot(110)
mypen.goto(0,-50)
mypen.fillcolor('gold')
mypen.begin_fill()
mypen.circle(50)
mypen.end_fill()
mypen.pencolor('skyblue')
mypen.penup()
mypen.left(90)
mypen.forward(25)
mypen.left(90)
mypen.forward(40)
mypen.pendown()
mypen.write("WIN", font=("Times New Roman", 30))
mypen.penup()
mypen.right(90)
mypen.forward(40)
mypen.right(90)
mypen.forward(20)
mypen.write("Front Of", font=("Arial",10))
mypen.penup()
mypen.right(90)
mypen.forward(50)
mypen.right(270)
mypen.forward(10)
mypen.write("Coin", font=("Arial",10))
print('硬币正面')
else:
mypen.dot(110)
mypen.goto(0, -50)
mypen.fillcolor('gold')
mypen.begin_fill()
mypen.circle(50)
mypen.end_fill()
mypen.pencolor('skyblue')
mypen.penup()
mypen.left(90)
mypen.forward(37.5)
mypen.left(90)
mypen.forward(40)
mypen.pendown()
mypen.write("NBGLASS", font=("Times New Roman", 15))
mypen.penup()
mypen.right(90)
mypen.forward(30)
mypen.right(90)
mypen.forward(20)
mypen.write("Back Of", font=("Arial",10))
mypen.penup()
mypen.right(90)
mypen.forward(50)
mypen.right(270)
mypen.forward(10)
mypen.write("Coin", font=("Arial",10))
print('硬币反面')
print('价值=', 价值, '人民币')
already_played = already_played + 1
print("你已经玩了",already_played,"局")
print("----------------------")
if_ct = turtle.textinput('还想继续吗?', 'OK按Enter ;不想了按任意键')
if if_ct == '':
continue
else:
break
turtle.done()
else:
print("输入内容有误,请重新开始游戏!")
pass
else:
pass
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn