用户:
黑人抬棺sans查看:0 回复:0 评论:0 创建时间:2024-04-20T14:43:54
【作品展示】

【作品介绍】
自己探索
【作品源代码】
import random as r
import turtle as t
import easygui as e
import sys
def start():
t.title("拼单词")
t.penup()
t.goto(-100, 100)
t.pendown()
t.forward(100)
t.right(90)
t.forward(250)
t.right(90)
t.forward(130)
t.forward(-260)
t.penup()
t.goto(-100, 100)
t.setheading(-90)
t.pendown()
t.forward(30)
########################################
def head():
t.fillcolor("lime")
t.begin_fill()
t.setheading(180)
t.circle(30)
t.end_fill()
def body():
t.setheading(-90)
t.penup()
t.forward(60)
t.pendown()
t.forward(100)
def legs():
t.setheading(-135)
t.forward(40)
t.forward(-40)
t.setheading(-45)
t.forward(40)
t.forward(-40)
def arms():
t.setheading(90)
t.forward(50)
t.setheading(-135)
t.forward(40)
t.forward(-40)
t.setheading(-45)
t.forward(40)
t.forward(-40)
def eyes():
t.penup()
t.goto(-115, 45)
t.pendown()
t.setheading(45)
t.forward(10)
t.forward(-20)
t.forward(10)
t.setheading(-45)
t.forward(10)
t.forward(-20)
t.forward(10)
t.penup()
t.goto(-90, 45)
t.pendown()
t.setheading(45)
t.forward(10)
t.forward(-20)
t.forward(10)
t.setheading(-45)
t.forward(10)
t.forward(-20)
t.forward(10)
def mouth():
t.penup()
t.goto(-110, 28)
t.pendown()
t.setheading(0)
t.forward(20)
t.forward(-2)
t.setheading(-90)
t.forward(5)
t.circle(-4, 180)
t.setheading(90)
t.forward(5)
t.setheading(0)
t.forward(4)
t.setheading(-90)
t.forward(6)
def greenhead():
t.penup()
t.goto(-100, 70)
t.speed(0)
t.pendown()
t.fillcolor("lime")
t.begin_fill()
head()
t.end_fill()
eyes()
mouth()
###############################
def quitmsg():
re = e.msgbox("确定退出游戏吗?", title="拼单词")
if re:
sys.exit()
def findletter(letter, Word, hideword):
temp = list(hideword)
tempindex = []
for i in range(len(Word)):
if Word[i] == letter:
tempindex.append(i)
for i in tempindex:
tempword = Word[i]
temp[i] = tempword
string = "".join(temp)
return string
def main():
wordlist = ['player unknown\'s battle grounds', 'counter strike global offensive',
'grand theft auto V', 'naruto', "blibli", 'youtube', 'virtual private network','eggyparty']
translate = ['绝地求生', '反恐精英全球攻势', '侠盗飞车5', '火影忍者', 'B站', "油管", '虚拟专用网(喵)','蛋仔派对']
draw = 0
random_word = r.randint(0, len(wordlist) - 1)
word = wordlist[random_word]
hideword = ''
for i in word:
if i != ' ':
hideword += "*"
else:
hideword += ' '
t.hideturtle()
while draw < 6:
char = e.enterbox(translate[random_word] + "\n" + hideword, title = "拼单词")
if char != None:
Temp_hideword = findletter(char, word, hideword)
if hideword != Temp_hideword:
hideword = Temp_hideword
if hideword == word:
e.msgbox("回答正确,单词为:" + word, title="拼单词")
break
if hideword != word:
continue
draw += 1
if draw == 1:
head()
elif draw == 2:
body()
elif draw == 3:
legs()
elif draw == 4:
arms()
elif draw == 5:
eyes()
else:
mouth()
# else:
# greenhead()
else:
quitmsg()
else:
e.msgbox("单词为:" + word, title="拼单词")
if __name__ == "__main__":
start()
main()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn