From 5242e4c785ca21fdcc25733ddc36fe629af89ec0 Mon Sep 17 00:00:00 2001 From: Azalea Gui Date: Tue, 7 Mar 2023 23:32:49 -0500 Subject: [PATCH] [O] Calculate snow particle density --- tngame/telnet.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tngame/telnet.py b/tngame/telnet.py index ebc9bd5..ac6d521 100644 --- a/tngame/telnet.py +++ b/tngame/telnet.py @@ -22,6 +22,8 @@ ASCII_CAT = r""" ASCII_HEIGHT = ASCII_CAT.count('\n') ASCII_WIDTH = max(len(line.strip('\n')) for line in ASCII_CAT.splitlines()) +SNOW_DENSITY = 0.05 # Snow particles per pixel on screen + COLORS = [RGB.from_hex(v) for v in { '#FFFFFF', @@ -51,7 +53,11 @@ async def shell(reader: TelnetReaderUnicode, writer: TelnetWriterUnicode): snow: list[SnowParticle] # Create snow particles - def create_snow(count: int) -> list[SnowParticle]: + def create_snow(count: int | None) -> list[SnowParticle]: + # Calculate snow particle count based on screen size and density + if count is None: + count = int(width * height * SNOW_DENSITY) + snow = [] for _ in range(count):