support other modes
This commit is contained in:
+2
-7
@@ -1,8 +1,8 @@
|
|||||||
import requests
|
import requests
|
||||||
import utils.logos as logos
|
import utils.logos as logos
|
||||||
from PIL import Image, ImageDraw
|
from PIL import Image
|
||||||
from rgbmatrix import graphics
|
from rgbmatrix import graphics
|
||||||
from utils.vars import Colors, font, font_small
|
from utils.vars import Colors, font, font_small, PANEL_WIDTH, PANEL_HEIGHT, GAME_WIDTH, DIVIDER_COLOR
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
# --- State ---
|
# --- State ---
|
||||||
@@ -25,11 +25,6 @@ _tick = 0
|
|||||||
_virtual_canvas = None # PIL Image of the full wide render
|
_virtual_canvas = None # PIL Image of the full wide render
|
||||||
_virtual_dirty = True # rebuild the virtual canvas on next frame
|
_virtual_dirty = True # rebuild the virtual canvas on next frame
|
||||||
|
|
||||||
PANEL_WIDTH = 256 # 4 × 64px panels
|
|
||||||
PANEL_HEIGHT = 32
|
|
||||||
GAME_WIDTH = 128 # each game slot is one panel wide
|
|
||||||
DIVIDER_COLOR = (40, 40, 40)
|
|
||||||
|
|
||||||
# --- Color helpers ---
|
# --- Color helpers ---
|
||||||
def _rbg(color_tuple):
|
def _rbg(color_tuple):
|
||||||
"""Convert an (R, G, B) tuple to a graphics.Color with G and B swapped
|
"""Convert an (R, G, B) tuple to a graphics.Color with G and B swapped
|
||||||
|
|||||||
+14
-2
@@ -167,10 +167,22 @@ def draw_pil_image(canvas, img):
|
|||||||
# --- Main loop ---
|
# --- Main loop ---
|
||||||
def run():
|
def run():
|
||||||
global canvas
|
global canvas
|
||||||
|
times_ran = 0
|
||||||
|
supported_modes = ["score", "fantasy"]
|
||||||
|
current_mode = 0
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
canvas_ref = score_mode.draw_frame(canvas)
|
if times_ran >= 3:
|
||||||
canvas = matrix.SwapOnVSync(canvas_ref)
|
times_ran = 0
|
||||||
|
|
||||||
|
++current_mode
|
||||||
|
if current_mode > len(supported_modes):
|
||||||
|
current_mode = 0
|
||||||
|
|
||||||
|
if supported_modes[current_mode] == "score":
|
||||||
|
canvas_ref = score_mode.draw_frame(canvas)
|
||||||
|
canvas = matrix.SwapOnVSync(canvas_ref)
|
||||||
|
++times_ran
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
run()
|
run()
|
||||||
@@ -15,6 +15,11 @@ SCRIPT_DIR = Path(__file__).parent.resolve()
|
|||||||
ASSET_DIR = os.path.join(SCRIPT_DIR, "../assets")
|
ASSET_DIR = os.path.join(SCRIPT_DIR, "../assets")
|
||||||
LOGO_DIR = os.path.join(ASSET_DIR, "logos")
|
LOGO_DIR = os.path.join(ASSET_DIR, "logos")
|
||||||
|
|
||||||
|
PANEL_WIDTH = 256
|
||||||
|
PANEL_HEIGHT = 32
|
||||||
|
GAME_WIDTH = 128
|
||||||
|
DIVIDER_COLOR = (40, 40, 40)
|
||||||
|
|
||||||
font = graphics.Font()
|
font = graphics.Font()
|
||||||
font_small = graphics.Font()
|
font_small = graphics.Font()
|
||||||
font_big = graphics.Font()
|
font_big = graphics.Font()
|
||||||
|
|||||||
Reference in New Issue
Block a user