import random import time x = int(input("x value: ")) y = int(input("y value: ")) fps = int(input("framerate: ")) # Usually 6 rainfallRatio = int(input("ratio of rainfall: ")) # Usually 10 output = [[] for _ in range(y)] # What character should be displayed for a filled or empty space def drop(): return "\033[38;2;191;127;255m/\033[0m" # Weird ass escape sequence... Only prints text between the m and \033 def empty(): return " " # Create initial data in the lists def startup(): for i in range(y): output[i] = [(drop() if random.randint(1, rainfallRatio) == 1 else empty()) for _ in range(y + (2 * x))] def update(): # Clear terminal print("\033[H\033[2J", end="") # Another weird ass escape sequence... # Create next frame excluding the top line for _i in range(y - 1): i = y - (_i + 1) # i iterates from last value downwards to 1 output[i] = output[i - 1] output[i].pop(0) # Generate new top line nextLine = [(drop() if random.randint(1, rainfallRatio) == 1 else empty()) for _ in range(y + (2 * x))] # Independantly create the top line output[0] = nextLine # Print the output print(f"+{"-" * x}+") for i in range(y): print("|", end="") for j in range(x): print(output[i][j], end="") print("|") print(f"+{"-" * x}+") startup() while True: update() time.sleep(1 / fps)