Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,17 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
def
|
4 |
-
|
5 |
-
|
|
|
6 |
|
7 |
-
|
8 |
-
max_number: 班級座號的最大值
|
9 |
-
|
10 |
-
Returns:
|
11 |
-
抽出的隨機號碼
|
12 |
-
"""
|
13 |
-
import random
|
14 |
-
return random.randint(1, max_number)
|
15 |
-
|
16 |
-
# 建立使用者介面
|
17 |
demo = gr.Interface(
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
description="輸入班級座號的最大值,點擊抽籤"
|
23 |
)
|
24 |
|
25 |
-
# 啟動伺服器
|
26 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import pygame
|
3 |
|
4 |
+
def start_game(difficulty):
|
5 |
+
# 在這裡初始化 Pygame,根據 difficulty 設定遊戲難度
|
6 |
+
pygame.init()
|
7 |
+
# ... Pygame 遊戲邏輯 ...
|
8 |
|
9 |
+
# Gradio 介面
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
demo = gr.Interface(
|
11 |
+
fn=start_game,
|
12 |
+
inputs="number", # 輸入難度
|
13 |
+
outputs="text", # 可以顯示遊戲狀態
|
14 |
+
title="貪食蛇遊戲"
|
|
|
15 |
)
|
16 |
|
|
|
17 |
demo.launch()
|