有人可以帮忙我的Hi-Lo graphics.py游戏吗?

时间:2019-10-03 08:12:13

标签: python

我是编写游戏代码的初学者,需要帮助使我的游戏正常运行。我的输入框需要帮助。我打印了一个问题,说“猜一个介于1到100之间的数字”,玩家需要在我创建的输入框中输入答案。有一些未彩色的向上和向下箭头指示高或低符号。我想做的是,当玩家输入一个介于1到100之间的数字并且他们的猜测较低时,我将把非彩色箭头图片更改为彩色箭头图片,以便玩家可以看到该数字更大。之后,玩家必须输入另一个号码,直到他/她猜对了号码为止。这是我的下面的代码。有人可以帮我怎么做吗?

from graphics import *

#Window for the Game
win = GraphWin('Hi-Lo', 900,600)
win.setBackground('#F9DEC9')

#Arrows for High and Low with Hi-Lo
high_arrow = Image(Point(380,300), 'high arrow.png')
high_arrow.draw(win)

low_arrow = Image(Point(510,300), 'low arrow.png')
low_arrow.draw(win)

hi = Text(Point(383,300), 'Hi')
hi.draw(win)
hi.setFace('courier')
hi.setSize(20)

lo = Text(Point(511,300), 'Lo')
lo.draw(win)
lo.setFace('courier')
lo.setSize(20)

dash = Text(Point(447,300), '-')
dash.draw(win)
dash.setFace('courier')
dash.setSize(25)

#Instruction Box
ins_box = Image(Point(447,500), 'ins box.png')
ins_box.draw(win)

ins = Text(Point(447,501), 'Instructions')
ins.draw(win)
ins.setFace('courier')
ins.setSize(16)

#Guess Box
guess_box = Image(Point(447,100), 'guess box.png')
guess_box.draw(win)

guess = Text(Point(447,20), 'Guess a number between 1 - 100')
guess.draw(win)
guess.setFace('courier')
guess.setSize(15)

guess_entry = Entry(Point(447,100), 3)
guess_entry.setTextColor('Black')
guess_entry.setFill('White')
guess_entry.setSize(30)
guess_entry.draw(win)

#Lives
lives = Text (Point(55,465), 'Lives:')
lives.draw(win)
lives.setFace('courier')
lives.setSize(15)

heart = Image(Point(55,530), 'heart.png')
heart.draw(win)

heart2 = Image(Point(105,530), 'heart.png')
heart2.draw(win)

heart3 = Image(Point(155,530), 'heart.png')
heart3.draw(win)

heart4 = Image(Point(55,580), 'heart.png')
heart4.draw(win)

heart5 = Image(Point(105,580), 'heart.png')
heart5.draw(win)

heart6 = Image(Point(155,580), 'heart.png')
heart6.draw(win)

#Score Box
score_box = Image(Point(790,530), 'score box.png')
score_box.draw(win)

score = Text (Point(710,465), 'Score:')
score.draw(win)
score.setFace('courier')
score.setSize(15)

0 个答案:

没有答案