海龟画图版漂亮的猜数小游戏

"""猜数小游戏.py"""

from random import randint
from turtle import *
from tkinter import messagebox

game_title = "猜数小游戏_作者:李兴球"
max_number = 100
min_number = 1 
number = randint(min_number,max_number)

screen = Screen()
screen.setup(800,533)
screen.bgpic("th.png")
screen.title(game_title)

messagebox.showinfo(game_title, "Hello,我是计算机,欢迎来到猜数小游戏。")
messagebox.showinfo(game_title, "我会生成一个从1到100以内的整数,你猜猜它是多少吧。")

while True:
    answer = screen.numinput(game_title,"请输入整数:",minval =min_number,maxval = max_number)
    if answer == None : continue 
    if int(answer) == number :
        messagebox.showinfo(game_title, "恭喜,你猜对了!这个数就是:" + str(number))         
        break
    if int(answer) < number:
        messagebox.showinfo(game_title, "小了!") 
        
    if int(answer) > number:
         messagebox.showinfo(game_title, "大了!") 

messagebox.showinfo(game_title, "游戏结束了。再见!!")
screen.bye()