Beispiel #1
0
def explode(base_color: Color = Colors.STEELERS_RED,
            explosion_color: Color = Colors.COLD_WHITE,
            in_terminal=False):
    colors = to_n_colors(base_color.r_brightness(20000), n=256)
    cm = ColorMatrix.from_colors(colors, RC(16, 16))
    start, end = RC(7, 7), RC(9, 9)
    cm[start] = cm[end] = explosion_color
    # for rc in start.to(end):
    #     cm[rc] = explosion_color

    # expand
    with suppress(IndexError):
        for _ in range(10):
            set_cm(cm, strip=False, in_terminal=in_terminal)
            propagate(cm, base_color, explosion_color)
            time.sleep(.1)

    if in_terminal:
        return

    # fill white
    for offset in range(8):
        s, e = start - RC(offset, offset), end + RC(offset, offset)
        for rc in s.to(e):
            cm[rc] = explosion_color
        set_cm(cm, strip=False, in_terminal=in_terminal)
        time.sleep(.1)

    # fade to black
    colors = to_n_colors(Colors.OFF, n=256)
    cm = ColorMatrix.from_colors(colors, RC(16, 16))
    set_cm(cm, strip=False, duration_msec=3000)
Beispiel #2
0
def lights_tick(game: SnekGame):
    set_cm(game.cm, strip=False)
Beispiel #3
0
def terminal_tick(game: SnekGame):
    os.system('clear')
    # print(game.cm.color_str)
    set_cm(game.cm, in_terminal=True, strip=False)
    print(game.snek.sneque.maxlen)
Beispiel #4
0
def lights_tick(game: SnekGame):
    set_cm(game.cm, strip=False, with_mini=True)
Beispiel #5
0
 def display(self, in_terminal=True):
     set_cm(self.cm, in_terminal=in_terminal, verbose=False, strip=False)
     time.sleep(.5)