程序理念
做着玩玩而已,娱乐一下,对于刚学python,刚跟世界问好的小伙伴们可以参考借鉴一下_
主程序
import random
import easygui as eg
eg.msgbox("欢迎来到王者农耀^-^")
msg = "发起进攻(1~10)"
title = "王者农耀"
guess = eg.integerbox(msg, title, lowerbound = 1, upperbound = 10)
while True:
if guess == secret:
eg.msgbox("You're winner!")
eg.msgbox("But,没有奖励.")
break
else:
if guess > secret:
eg.msgbox("敌方已使用闪现,继续追吧!")
else:
eg.msgbox("你以使用闪现,逃吧!")
guess = eg.integerbox(msg, title, lowerbound=1, upperbound=10)
eg.msgbox("游戏结束")
程序解释
首先导入模块
import random
import easygui as eg
然后创建窗口
eg.msgbox("欢迎来到王者农耀^-^")
msg = "发起进攻(1~10)"
title = "王者农耀"
guess = eg.integerbox(msg, title, lowerbound = 1, upperbound = 10)
Finaly, 做游戏主体,也就是无限循环部分,用If else 语句完成整个游戏功能。
while True:
if guess == secret:
eg.msgbox("You're winner!")
eg.msgbox("But,没有奖励.")
break
else:
if guess > secret:
eg.msgbox("敌方已使用闪现,继续追吧!")
else:
eg.msgbox("你以使用闪现,逃吧!")
guess = eg.integerbox(msg, title, lowerbound=1, upperbound=10)
eg.msgbox("游戏结束")
This is my game,这就是我做的小游戏,恭候大家的指教。