

def main():
    MAX_FPS = 20
    time_per_frame = (lambda : (1.0 / MAX_FPS))
    with FullscreenWindow() as window:
        with Input() as input_generator:
            snake = Snake(window.height, window.width)
            while True:
                c = None
                t0 = time.time()
                while True:
                    t = time.time()
                    temp_c = input_generator.send(max(0, (t - (t0 + time_per_frame()))))
                    if (temp_c == '<ESC>'):
                        return
                    elif (temp_c == '+'):
                        MAX_FPS += 1
                    elif (temp_c == '-'):
                        MAX_FPS = max(1, (MAX_FPS - 1))
                    elif (temp_c is not None):
                        c = temp_c
                    if (time_per_frame() < (t - t0)):
                        break
                if snake.tick(c):
                    return
                window.render_to_terminal(snake.render())

dataset/ETHPy150Open thomasballinger/curtsies/examples/snake.py main/original