#! /usr/bin/env python

"""
Cited: https://github.com/dannyso16/Gameboy-on-terminal
"""

stand = """
⬜⬜⬜⬜⬜⬜🟥🟥🟥🟥🟥⬜⬜⬜⬜⬜
⬜⬜⬜⬜🟥🟥🟥🟥🟥🟥🟥🟥🟥⬜⬜⬜
⬜⬜⬜⬜🟫🟫🟫🟨🟨🟫🟨⬜⬜⬜⬜⬜
⬜⬜⬜🟫🟨🟫🟨🟨🟨🟫🟨🟨🟨⬜⬜⬜
⬜⬜⬜🟫🟨🟫🟫🟨🟨🟨🟫🟨🟨🟨⬜⬜
⬜⬜⬜🟫🟫🟨🟨🟨🟨🟫🟫🟫🟫⬜⬜⬜
⬜⬜⬜⬜⬜🟨🟨🟨🟨🟨🟨🟨⬜⬜⬜⬜
⬜⬜⬜⬜🟥🟥🟦🟥🟥🟥⬜⬜⬜⬜⬜⬜
⬜⬜⬜🟥🟥🟥🟦🟥🟥🟦🟥🟥🟥⬜⬜⬜
⬜⬜🟥🟥🟥🟥🟦🟦🟦🟦🟥🟥🟥🟥⬜⬜
⬜⬜🟨🟨🟥🟦🟨🟦🟦🟨🟦🟥🟨🟨⬜⬜
⬜⬜🟨🟨🟨🟦🟦🟦🟦🟦🟦🟨🟨🟨⬜⬜
⬜⬜🟨🟨🟦🟦🟦🟦🟦🟦🟦🟦🟨🟨⬜⬜
⬜⬜⬜⬜🟦🟦🟦⬜⬜🟦🟦🟦⬜⬜⬜⬜
⬜⬜⬜🟫🟫🟫⬜⬜⬜⬜🟫🟫🟫⬜⬜⬜
⬜⬜🟫🟫🟫🟫⬜⬜⬜⬜🟫🟫🟫🟫⬜⬜"""

spin_characters = [
    """
⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜🟥🟥🟥🟥🟥⬜⬜⬜⬜⬜
⬜⬜⬜⬜🟥🟥🟥🟥🟥🟥🟥🟥🟥⬜⬜⬜
⬜⬜⬜⬜🟫🟫🟫🟨🟨🟫🟨⬜⬜⬜⬜⬜
⬜⬜⬜🟫🟨🟫🟨🟨🟨🟫🟨🟨🟨⬜⬜⬜
⬜⬜⬜🟫🟨🟫🟫🟨🟨🟨🟫🟨🟨🟨⬜⬜
⬜⬜⬜🟫🟫🟨🟨🟨🟨🟫🟫🟫🟫⬜⬜⬜
⬜⬜⬜⬜⬜🟨🟨🟨🟨🟨🟨🟨⬜⬜⬜⬜
⬜⬜⬜⬜🟥🟥🟥🟦🟥🟥⬜⬜⬜⬜⬜⬜
⬜⬜⬜🟥🟥🟥🟥🟦🟦🟥🟥⬜⬜⬜⬜⬜
⬜⬜⬜🟥🟥🟥🟦🟦🟨🟦🟦⬜⬜⬜⬜⬜
⬜⬜⬜🟥🟥🟥🟥🟦🟦🟦🟦⬜⬜⬜⬜⬜
⬜⬜⬜🟦🟥🟥🟨🟨🟦🟦🟦⬜⬜⬜⬜⬜
⬜⬜⬜⬜🟦🟥🟨🟨🟦🟦⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜🟦🟦🟦🟫🟫🟫⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜🟫🟫🟫🟫⬜⬜⬜⬜⬜⬜⬜""",

    """
⬜⬜⬜⬜⬜⬜🟥🟥🟥🟥🟥⬜⬜⬜⬜⬜
⬜⬜⬜⬜🟥🟥🟥🟥🟥🟥🟥🟥🟥⬜⬜⬜
⬜⬜⬜⬜🟫🟫🟫🟨🟨🟫🟨⬜⬜⬜⬜⬜
⬜⬜⬜🟫🟨🟫🟨🟨🟨🟫🟨🟨🟨⬜⬜⬜
⬜⬜⬜🟫🟨🟫🟫🟨🟨🟨🟫🟨🟨🟨⬜⬜
⬜⬜⬜🟫🟫🟨🟨🟨🟨🟫🟫🟫🟫⬜⬜⬜
⬜⬜⬜⬜⬜🟨🟨🟨🟨🟨🟨🟨⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜🟥🟦🟦🟥⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜🟥🟥🟥🟥🟦🟥🟨🟨⬜⬜⬜
⬜⬜⬜🟨🟨🟥🟥🟥🟥🟥🟥🟨🟨🟨⬜⬜
⬜⬜🟨🟨🟨🟦🟥🟥🟥🟥🟥🟨🟨⬜⬜⬜
⬜⬜⬜🟫🟫🟦🟦🟦🟦🟦🟦🟦⬜⬜⬜⬜
⬜⬜⬜🟫🟦🟦🟦🟦🟦🟦🟦🟦⬜⬜⬜⬜
⬜⬜🟫🟫🟦🟦⬜⬜🟦🟦🟦⬜⬜⬜⬜⬜
⬜⬜🟫⬜⬜⬜⬜🟫🟫🟫⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜⬜⬜🟫🟫🟫⬜⬜⬜⬜⬜""",

    """
⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜🟥🟥🟥🟥🟥⬜⬜⬜⬜⬜
⬜⬜⬜⬜🟥🟥🟥🟥🟥🟥🟥🟥🟥⬜⬜⬜
⬜⬜⬜⬜🟫🟫🟫🟨🟨🟫🟨⬜⬜⬜⬜⬜
⬜⬜⬜🟫🟨🟫🟨🟨🟨🟫🟨🟨🟨⬜⬜⬜
⬜⬜⬜🟫🟨🟫🟫🟨🟨🟨🟫🟨🟨🟨⬜⬜
⬜⬜⬜🟫🟫🟨🟨🟨🟨🟫🟫🟫🟫⬜⬜⬜
⬜⬜⬜⬜⬜🟨🟨🟨🟨🟨🟨🟨⬜⬜⬜⬜
⬜⬜⬜⬜🟥🟥🟥🟦🟥🟥⬜⬜⬜⬜⬜⬜
⬜⬜⬜🟥🟥🟥🟥🟦🟦🟥🟥⬜⬜⬜⬜⬜
⬜⬜⬜🟥🟥🟥🟦🟦🟨🟦🟦⬜⬜⬜⬜⬜
⬜⬜⬜🟥🟥🟥🟥🟦🟦🟦🟦⬜⬜⬜⬜⬜
⬜⬜⬜🟦🟥🟥🟨🟨🟦🟦🟦⬜⬜⬜⬜⬜
⬜⬜⬜⬜🟦🟥🟨🟨🟦🟦⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜🟦🟦🟦🟫🟫🟫⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜🟫🟫🟫🟫⬜⬜⬜⬜⬜⬜⬜""",

    """
⬜⬜⬜⬜⬜⬜🟥🟥🟥🟥🟥⬜⬜⬜⬜⬜
⬜⬜⬜⬜🟥🟥🟥🟥🟥🟥🟥🟥🟥⬜⬜⬜
⬜⬜⬜⬜🟫🟫🟫🟨🟨🟫🟨⬜⬜⬜⬜⬜
⬜⬜⬜🟫🟨🟫🟨🟨🟨🟫🟨🟨🟨⬜⬜⬜
⬜⬜⬜🟫🟨🟫🟫🟨🟨🟨🟫🟨🟨🟨⬜⬜
⬜⬜⬜🟫🟫🟨🟨🟨🟨🟫🟫🟫🟫⬜⬜⬜
⬜⬜⬜⬜⬜🟨🟨🟨🟨🟨🟨🟨⬜⬜⬜⬜
⬜⬜🟥🟥🟥🟥🟦🟥🟥🟥🟦⬜⬜⬜⬜⬜
🟨🟨🟥🟥🟥🟥🟦🟦🟥🟥🟥🟦🟥🟨🟨🟨
🟨🟨🟨⬜🟥🟥🟦🟦🟦🟦🟦🟦🟥🟥🟨🟨
🟨🟨⬜⬜🟦🟦🟦🟨🟦🟦🟦🟨⬜⬜🟫⬜
⬜⬜⬜🟦🟦🟦🟦🟦🟦🟦🟦🟦🟦🟫🟫⬜
⬜⬜🟦🟦🟦🟦🟦🟦🟦🟦🟦🟦🟦🟫🟫⬜
⬜🟫🟫🟦🟦🟦⬜⬜⬜⬜🟦🟦🟦🟫🟫⬜
⬜🟫🟫🟫⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
⬜⬜🟫🟫🟫⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
""",

    """
⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜⬜🟥🟥🟥🟥🟥⬜⬜⬜⬜⬜
⬜⬜⬜⬜🟥🟥🟥🟥🟥🟥🟥🟥🟥⬜⬜⬜
⬜⬜⬜⬜🟫🟫🟫🟨🟨🟫🟨⬜⬜⬜⬜⬜
⬜⬜⬜🟫🟨🟫🟨🟨🟨🟫🟨🟨🟨⬜⬜⬜
⬜⬜⬜🟫🟨🟫🟫🟨🟨🟨🟫🟨🟨🟨⬜⬜
⬜⬜⬜🟫🟫🟨🟨🟨🟨🟫🟫🟫🟫⬜⬜⬜
⬜⬜⬜⬜⬜🟨🟨🟨🟨🟨🟨🟨⬜⬜⬜⬜
⬜⬜⬜⬜🟥🟥🟥🟦🟥🟥⬜⬜⬜⬜⬜⬜
⬜⬜⬜🟥🟥🟥🟥🟦🟦🟥🟥⬜⬜⬜⬜⬜
⬜⬜⬜🟥🟥🟥🟦🟦🟨🟦🟦⬜⬜⬜⬜⬜
⬜⬜⬜🟥🟥🟥🟥🟦🟦🟦🟦⬜⬜⬜⬜⬜
⬜⬜⬜🟦🟥🟥🟨🟨🟦🟦🟦⬜⬜⬜⬜⬜
⬜⬜⬜⬜🟦🟥🟨🟨🟦🟦⬜⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜🟦🟦🟦🟫🟫🟫⬜⬜⬜⬜⬜
⬜⬜⬜⬜⬜🟫🟫🟫🟫⬜⬜⬜⬜⬜⬜⬜""",
]

import time

FPS = 20

rows = spin_characters[0].split("\n")
rows = [r for r in rows if r]
height = len(rows)

during = 50
cycle = len(spin_characters)

for i in range(during):
    rows = spin_characters[i % cycle].split("\n")
    rows = [r for r in rows if r]

    for row in rows:
        print(row)
    time.sleep(1/FPS)
    print("\033[{}A".format(height+1))
else:
    # When all is done, the "standing" state is displayed.
    rows = stand.split("\n")
    rows = [r for r in rows if r]

    for row in rows:
        print(row)
    time.sleep(0.05)
    print("\033[{}A".format(height+1))

# Post Processing
print("\033[{}B".format(height+1))