24| 0
|
[M10项目] -----------------行空板小游戏----------------- |
本帖最后由 刘睿鹏 于 2025-1-18 21:02 编辑 本周给大家分享一个小游戏 【项目效果】 包括两个小游戏,玩家在主界面选择游戏。1、蛇年刮奇:1~9的按钮,若玩家选的号码和计算机生成的号码一样,则玩家可获得随机奖励 否则显示“真遗憾,没抽中”,显示结果后返回主界面。 2、灵蛇抽福:大转盘共6个格子,4个啥也没有,转盘随机转7-18次,若最终停在“中奖”的格子上,则玩家可获得随机奖励,否则显示“真遗憾,没抽中”,显示结果后返回主界面。 【所需材料】 硬件:行空板M10 软件:Mind+ Mind+ 【制作步骤】 1.打开Mind+,选择Python模式 2.点击左下角扩展按钮,选择官方库中的行空板。 3.打开“文件管理”,把背景拖进“项目中的文件” 编写程序 分为mainmenu,game1,game2三个函数程序,由主程序控制,当玩家点击第一个按钮时,停止mainmenu,启动game1;当玩家点击第二个按钮时,停止mainmenu,启动game2; (1)导入库 import time import random import threading from unihiker import GUI (2)mainmenu函数 def u_main_menu_function(): global a0,a1,a2,a3 a0=u_gui.draw_image(image="背景.jpeg",x=0,y=0) a1=u_gui.draw_text(text="小游戏",x=60,y=0,font_size=30, color="#FFFFFF") a2=u_gui.add_button(text="蛇年刮奇",x=85,y=100,w=80,h=30,onclick=button_click1) a3=u_gui.add_button(text="灵蛇抽福",x=85,y=200,w=80,h=30,onclick=button_click2) (3)按钮1的回调函数及game1函数 def button_click1(): global game1,main_menu game1=u_gui.start_thread(u_game1_function) u_gui.stop_thread(main_menu) def u_game1_function(): global number,b0,b1,b2,b3,b4,b5,b6,b7,b8,b9 number = (random.randint(1, 9)) a1.config(x=1000) a2.config(x=1000) a3.config(x=1000) b0=u_gui.draw_text(text="请选择一个号码",x=20,y=0,font_size=20, color="#0000FF") b1=u_gui.add_button(text="1",x=20,y=100,w=40,h=30,onclick=button_click5) b2=u_gui.add_button(text="2",x=100,y=100,w=40,h=30,onclick=button_click6) b3=u_gui.add_button(text="3",x=180,y=100,w=40,h=30,onclick=button_click7) b4=u_gui.add_button(text="4",x=20,y=150,w=40,h=30,onclick=button_click8) b5=u_gui.add_button(text="5",x=100,y=150,w=40,h=30,onclick=button_click9) b6=u_gui.add_button(text="6",x=180,y=150,w=40,h=30,onclick=button_click10) b7=u_gui.add_button(text="7",x=20,y=200,w=40,h=30,onclick=button_click11) b8=u_gui.add_button(text="8",x=100,y=200,w=40,h=30,onclick=button_click12) b9=u_gui.add_button(text="9",x=180,y=200,w=40,h=30,onclick=button_click13) def button_click5(): if (number == 1): b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="恭喜您中奖",x=10,y=150,font_size=20, color="#0000FF") b11=u_gui.draw_digit(text=(random.randint(10, 100)),x=150,y=160,font_size=20, color="#0000FF") b12=u_gui.draw_text(text="元",x=185,y=150,font_size=20, color="#0000FF") time.sleep(5) else: b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="真遗憾,没抽中",x=20,y=150,font_size=20, color="#0000FF") time.sleep(5) u_gui.stop_thread(game1) main_menu=u_gui.start_thread(u_main_menu_function) def button_click6(): if (number == 2): b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="恭喜您中奖",x=10,y=150,font_size=20, color="#0000FF") b11=u_gui.draw_digit(text=(random.randint(10, 100)),x=150,y=160,font_size=20, color="#0000FF") b12=u_gui.draw_text(text="元",x=185,y=150,font_size=20, color="#0000FF") time.sleep(5) else: b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="真遗憾,没抽中",x=20,y=150,font_size=20, color="#0000FF") time.sleep(5) u_gui.stop_thread(game1) main_menu=u_gui.start_thread(u_main_menu_function) def button_click7(): if (number == 3): b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="恭喜您中奖",x=10,y=150,font_size=20, color="#0000FF") b11=u_gui.draw_digit(text=(random.randint(10, 100)),x=150,y=160,font_size=20, color="#0000FF") b12=u_gui.draw_text(text="元",x=185,y=150,font_size=20, color="#0000FF") time.sleep(5) else: b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="真遗憾,没抽中",x=20,y=150,font_size=20, color="#0000FF") time.sleep(5) u_gui.stop_thread(game1) main_menu=u_gui.start_thread(u_main_menu_function) def button_click8(): if (number == 4): b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="恭喜您中奖",x=10,y=150,font_size=20, color="#0000FF") b11=u_gui.draw_digit(text=(random.randint(10, 100)),x=150,y=160,font_size=20, color="#0000FF") b12=u_gui.draw_text(text="元",x=185,y=150,font_size=20, color="#0000FF") time.sleep(5) else: b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="真遗憾,没抽中",x=20,y=150,font_size=20, color="#0000FF") time.sleep(5) u_gui.stop_thread(game1) main_menu=u_gui.start_thread(u_main_menu_function) def button_click9(): if (number == 5): b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="恭喜您中奖",x=10,y=150,font_size=20, color="#0000FF") b11=u_gui.draw_digit(text=(random.randint(10, 100)),x=150,y=160,font_size=20, color="#0000FF") b12=u_gui.draw_text(text="元",x=185,y=150,font_size=20, color="#0000FF") time.sleep(5) else: b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="真遗憾,没抽中",x=20,y=150,font_size=20, color="#0000FF") time.sleep(5) u_gui.stop_thread(game1) main_menu=u_gui.start_thread(u_main_menu_function) def button_click10(): if (number == 6): b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="恭喜您中奖",x=10,y=150,font_size=20, color="#0000FF") b11=u_gui.draw_digit(text=(random.randint(10, 100)),x=150,y=160,font_size=20, color="#0000FF") b12=u_gui.draw_text(text="元",x=185,y=150,font_size=20, color="#0000FF") time.sleep(5) else: b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="真遗憾,没抽中",x=20,y=150,font_size=20, color="#0000FF") time.sleep(5) u_gui.stop_thread(game1) main_menu=u_gui.start_thread(u_main_menu_function) def button_click11(): if (number == 7): b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="恭喜您中奖",x=10,y=150,font_size=20, color="#0000FF") b11=u_gui.draw_digit(text=(random.randint(10, 100)),x=150,y=160,font_size=20, color="#0000FF") b12=u_gui.draw_text(text="元",x=185,y=150,font_size=20, color="#0000FF") time.sleep(5) else: b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="真遗憾,没抽中",x=20,y=150,font_size=20, color="#0000FF") time.sleep(5) u_gui.stop_thread(game1) main_menu=u_gui.start_thread(u_main_menu_function) def button_click12(): if (number == 8): b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="恭喜您中奖",x=10,y=150,font_size=20, color="#0000FF") b11=u_gui.draw_digit(text=(random.randint(10, 100)),x=150,y=160,font_size=20, color="#0000FF") b12=u_gui.draw_text(text="元",x=185,y=150,font_size=20, color="#0000FF") time.sleep(5) else: b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="真遗憾,没抽中",x=20,y=150,font_size=20, color="#0000FF") time.sleep(5) u_gui.stop_thread(game1) main_menu=u_gui.start_thread(u_main_menu_function) def button_click13(): if (number == 9): b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="恭喜您中奖",x=10,y=150,font_size=20, color="#0000FF") b11=u_gui.draw_digit(text=(random.randint(10, 100)),x=150,y=160,font_size=20, color="#0000FF") b12=u_gui.draw_text(text="元",x=185,y=150,font_size=20, color="#0000FF") time.sleep(5) else: b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="真遗憾,没抽中",x=20,y=150,font_size=20, color="#0000FF") time.sleep(5) u_gui.stop_thread(game1) main_menu=u_gui.start_thread(u_main_menu_function) (4)按钮2的回调函数及game2函数 def button_click2(): global game2,main_menu game2=u_gui.start_thread(u_game2_function) u_gui.stop_thread(main_menu) def u_game2_function(): global number a1.config(x=1000) a2.config(x=1000) a3.config(x=1000) number = 0 for index in range((random.randint(7, 18))): if (((int(number) % int(6))) == 0): a0.config(image="转盘1.png") time.sleep(0.1) elif (((int(number) % int(6))) == 1): a0.config(image="转盘2.png") time.sleep(0.1) elif (((int(number) % int(6))) == 2): a0.config(image="转盘3.png") time.sleep(0.1) elif (((int(number) % int(6))) == 3): a0.config(image="转盘4.png") time.sleep(0.1) elif (((int(number) % int(6))) == 4): a0.config(image="转盘5.png") time.sleep(0.1) elif (((int(number) % int(6))) == 5): a0.config(image="转盘6.png") time.sleep(0.1) number = (number + 1) if ((((int(number) % int(6))) == 1) or (((int(number) % int(6))) == 4)): x=u_gui.draw_text(text="恭喜您中奖",x=10,y=150,font_size=20, color="#FFFFFF") y=u_gui.draw_digit(text=(random.randint(10, 100)),x=150,y=160,font_size=20, color="#FFFFFF") z=u_gui.draw_text(text="元",x=185,y=150,font_size=20, color="#FFFFFF") time.sleep(5) x.config(x=1000) y.config(x=1000) z.config(x=1000) else: x=u_gui.draw_text(text="真遗憾,没抽中",x=20,y=150,font_size=20, color="#FFFFFF") time.sleep(5) x.config(x=1000) main_menu=u_gui.start_thread(u_main_menu_function) u_gui.stop_thread(game2) (5)主程序 u_gui=GUI() main_menu=u_gui.start_thread(u_main_menu_function) while True: pass 完整代码 # -*- coding: UTF-8 -*- # MindPlus # Python import time import random import threading from unihiker import GUI # 事件回调函数 def u_main_menu_function(): global a0,a1,a2,a3 a0=u_gui.draw_image(image="背景.jpeg",x=0,y=0) a1=u_gui.draw_text(text="小游戏",x=60,y=0,font_size=30, color="#FFFFFF") a2=u_gui.add_button(text="蛇年刮奇",x=85,y=100,w=80,h=30,onclick=button_click1) a3=u_gui.add_button(text="灵蛇抽福",x=85,y=200,w=80,h=30,onclick=button_click2) def button_click1(): global game1,main_menu game1=u_gui.start_thread(u_game1_function) u_gui.stop_thread(main_menu) def u_game1_function(): global number,b0,b1,b2,b3,b4,b5,b6,b7,b8,b9 number = (random.randint(1, 9)) a1.config(x=1000) a2.config(x=1000) a3.config(x=1000) b0=u_gui.draw_text(text="请选择一个号码",x=20,y=0,font_size=20, color="#0000FF") b1=u_gui.add_button(text="1",x=20,y=100,w=40,h=30,onclick=button_click5) b2=u_gui.add_button(text="2",x=100,y=100,w=40,h=30,onclick=button_click6) b3=u_gui.add_button(text="3",x=180,y=100,w=40,h=30,onclick=button_click7) b4=u_gui.add_button(text="4",x=20,y=150,w=40,h=30,onclick=button_click8) b5=u_gui.add_button(text="5",x=100,y=150,w=40,h=30,onclick=button_click9) b6=u_gui.add_button(text="6",x=180,y=150,w=40,h=30,onclick=button_click10) b7=u_gui.add_button(text="7",x=20,y=200,w=40,h=30,onclick=button_click11) b8=u_gui.add_button(text="8",x=100,y=200,w=40,h=30,onclick=button_click12) b9=u_gui.add_button(text="9",x=180,y=200,w=40,h=30,onclick=button_click13) def button_click5(): if (number == 1): b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="恭喜您中奖",x=10,y=150,font_size=20, color="#0000FF") b11=u_gui.draw_digit(text=(random.randint(10, 100)),x=150,y=160,font_size=20, color="#0000FF") b12=u_gui.draw_text(text="元",x=185,y=150,font_size=20, color="#0000FF") time.sleep(5) else: b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="真遗憾,没抽中",x=20,y=150,font_size=20, color="#0000FF") time.sleep(5) u_gui.stop_thread(game1) main_menu=u_gui.start_thread(u_main_menu_function) def button_click6(): if (number == 2): b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="恭喜您中奖",x=10,y=150,font_size=20, color="#0000FF") b11=u_gui.draw_digit(text=(random.randint(10, 100)),x=150,y=160,font_size=20, color="#0000FF") b12=u_gui.draw_text(text="元",x=185,y=150,font_size=20, color="#0000FF") time.sleep(5) else: b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="真遗憾,没抽中",x=20,y=150,font_size=20, color="#0000FF") time.sleep(5) u_gui.stop_thread(game1) main_menu=u_gui.start_thread(u_main_menu_function) def button_click7(): if (number == 3): b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="恭喜您中奖",x=10,y=150,font_size=20, color="#0000FF") b11=u_gui.draw_digit(text=(random.randint(10, 100)),x=150,y=160,font_size=20, color="#0000FF") b12=u_gui.draw_text(text="元",x=185,y=150,font_size=20, color="#0000FF") time.sleep(5) else: b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="真遗憾,没抽中",x=20,y=150,font_size=20, color="#0000FF") time.sleep(5) u_gui.stop_thread(game1) main_menu=u_gui.start_thread(u_main_menu_function) def button_click8(): if (number == 4): b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="恭喜您中奖",x=10,y=150,font_size=20, color="#0000FF") b11=u_gui.draw_digit(text=(random.randint(10, 100)),x=150,y=160,font_size=20, color="#0000FF") b12=u_gui.draw_text(text="元",x=185,y=150,font_size=20, color="#0000FF") time.sleep(5) else: b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="真遗憾,没抽中",x=20,y=150,font_size=20, color="#0000FF") time.sleep(5) u_gui.stop_thread(game1) main_menu=u_gui.start_thread(u_main_menu_function) def button_click9(): if (number == 5): b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="恭喜您中奖",x=10,y=150,font_size=20, color="#0000FF") b11=u_gui.draw_digit(text=(random.randint(10, 100)),x=150,y=160,font_size=20, color="#0000FF") b12=u_gui.draw_text(text="元",x=185,y=150,font_size=20, color="#0000FF") time.sleep(5) else: b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="真遗憾,没抽中",x=20,y=150,font_size=20, color="#0000FF") time.sleep(5) u_gui.stop_thread(game1) main_menu=u_gui.start_thread(u_main_menu_function) def button_click10(): if (number == 6): b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="恭喜您中奖",x=10,y=150,font_size=20, color="#0000FF") b11=u_gui.draw_digit(text=(random.randint(10, 100)),x=150,y=160,font_size=20, color="#0000FF") b12=u_gui.draw_text(text="元",x=185,y=150,font_size=20, color="#0000FF") time.sleep(5) else: b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="真遗憾,没抽中",x=20,y=150,font_size=20, color="#0000FF") time.sleep(5) u_gui.stop_thread(game1) main_menu=u_gui.start_thread(u_main_menu_function) def button_click11(): if (number == 7): b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="恭喜您中奖",x=10,y=150,font_size=20, color="#0000FF") b11=u_gui.draw_digit(text=(random.randint(10, 100)),x=150,y=160,font_size=20, color="#0000FF") b12=u_gui.draw_text(text="元",x=185,y=150,font_size=20, color="#0000FF") time.sleep(5) else: b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="真遗憾,没抽中",x=20,y=150,font_size=20, color="#0000FF") time.sleep(5) u_gui.stop_thread(game1) main_menu=u_gui.start_thread(u_main_menu_function) def button_click12(): if (number == 8): b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="恭喜您中奖",x=10,y=150,font_size=20, color="#0000FF") b11=u_gui.draw_digit(text=(random.randint(10, 100)),x=150,y=160,font_size=20, color="#0000FF") b12=u_gui.draw_text(text="元",x=185,y=150,font_size=20, color="#0000FF") time.sleep(5) else: b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="真遗憾,没抽中",x=20,y=150,font_size=20, color="#0000FF") time.sleep(5) u_gui.stop_thread(game1) main_menu=u_gui.start_thread(u_main_menu_function) def button_click13(): if (number == 9): b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="恭喜您中奖",x=10,y=150,font_size=20, color="#0000FF") b11=u_gui.draw_digit(text=(random.randint(10, 100)),x=150,y=160,font_size=20, color="#0000FF") b12=u_gui.draw_text(text="元",x=185,y=150,font_size=20, color="#0000FF") time.sleep(5) else: b0.config(x=1000) b1.config(x=1000) b2.config(x=1000) b3.config(x=1000) b4.config(x=1000) b5.config(x=1000) b6.config(x=1000) b7.config(x=1000) b8.config(x=1000) b9.config(x=1000) b10=u_gui.draw_text(text="真遗憾,没抽中",x=20,y=150,font_size=20, color="#0000FF") time.sleep(5) u_gui.stop_thread(game1) main_menu=u_gui.start_thread(u_main_menu_function) def button_click2(): global game2,main_menu game2=u_gui.start_thread(u_game2_function) u_gui.stop_thread(main_menu) def u_game2_function(): global number a1.config(x=1000) a2.config(x=1000) a3.config(x=1000) number = 0 for index in range((random.randint(7, 18))): if (((int(number) % int(6))) == 0): a0.config(image="转盘1.png") time.sleep(0.1) elif (((int(number) % int(6))) == 1): a0.config(image="转盘2.png") time.sleep(0.1) elif (((int(number) % int(6))) == 2): a0.config(image="转盘3.png") time.sleep(0.1) elif (((int(number) % int(6))) == 3): a0.config(image="转盘4.png") time.sleep(0.1) elif (((int(number) % int(6))) == 4): a0.config(image="转盘5.png") time.sleep(0.1) elif (((int(number) % int(6))) == 5): a0.config(image="转盘6.png") time.sleep(0.1) number = (number + 1) if ((((int(number) % int(6))) == 1) or (((int(number) % int(6))) == 4)): x=u_gui.draw_text(text="恭喜您中奖",x=10,y=150,font_size=20, color="#FFFFFF") y=u_gui.draw_digit(text=(random.randint(10, 100)),x=150,y=160,font_size=20, color="#FFFFFF") z=u_gui.draw_text(text="元",x=185,y=150,font_size=20, color="#FFFFFF") time.sleep(5) x.config(x=1000) y.config(x=1000) z.config(x=1000) else: x=u_gui.draw_text(text="真遗憾,没抽中",x=20,y=150,font_size=20, color="#FFFFFF") time.sleep(5) x.config(x=1000) main_menu=u_gui.start_thread(u_main_menu_function) u_gui.stop_thread(game2) u_gui=GUI() main_menu=u_gui.start_thread(u_main_menu_function) while True: pass 大功告成! ------------------------------------------ 【程序附件】 |
© 2013-2025 Comsenz Inc. Powered by Discuz! X3.4 Licensed