【发布时间】:2021-07-31 05:29:20
【问题描述】:
我正在尝试制作一个乌龟键盘游戏,您需要输入正确的字母才能获胜。 这是我到目前为止的代码:
import turtle
from english_words import english_words_lower_alpha_set
import time
import random
wn = turtle.Screen()
wn.setup(width = 1200, height = 800)
wn.title("Keyboard Typer")
wn.bgcolor("#9bf6ff")
floor = turtle.Turtle()
floor.speed(0)
floor.shape("square")
floor.hideturtle()
floor.color("#fdffb6")
floor.penup()
floor.shapesize(stretch_wid = 10, stretch_len = 60)
floor.goto(0, -310)
floor.showturtle()
sun = turtle.Turtle()
sun.speed(0)
sun.shape("circle")
sun.hideturtle()
sun.color("yellow")
sun.penup()
sun.shapesize(stretch_wid = 3, stretch_len = 3)
sun.goto(-500, 270)
sun.showturtle()
text = turtle.Turtle()
text.hideturtle()
text.color("black", "#caffbf")
text.shape("square")
text.speed(0)
text.penup()
text.goto(0, 390)
text.showturtle()
List = list(english_words_lower_alpha_set)
for Numbers in range(0, 5):
text.clear()
text.goto(0, 390)
text.showturtle()
Wordies = random.choice(List)
for i in range(0, 20):
y = text.ycor()
y -= 20
text.sety(y)
time.sleep(0.2)
text.write(Wordies, move = True, align = "center", font = ("Arial", 30, "normal"))
text.hideturtle()
time.sleep(5)
while True:
wn.update()
这是结果:
但是,我希望黄色矩形上有一个文本框或类似的东西。
希望带文本框输入:
有什么办法吗?
【问题讨论】:
标签: python-3.x turtle-graphics python-turtle