r/CodeBullet • • Aug 06 '23

Art I did a thing

58 Upvotes

10 comments sorted by

12

u/One_Nifty_Boi Aug 06 '23

9/10 very seizure inducing, but docking points because the casing is flying with the bullet

1

u/MinosAristos Aug 08 '23

It's just shooting more bullet per bullet. We do efficiency over conventions here.

1

u/Amarthon Aug 09 '23

65% more bullet per bullet

8

u/notsky64 Aug 06 '23

This is a awesome!!

1

u/_agent--47_ Aug 07 '23

Looks cool! Mind sharing your code? I am curious how you made it

1

u/TrojoGaming Aug 07 '23

Feast your eyes on this horrifying code.

It took me 30 minutes to write, and now it'll take me 1 hour to understand.

import random
import time
import os


def main():
    for frame_nr in range(100):
        os.system('cls')

        lines = frame(frame_nr)
        print("\n".join(lines))

        time.sleep(0.1)


def frame(frame_nr):
    line_count = 13
    max_len = 42
    lines = ["" for _ in range(line_count)]

    # d: delay, g: gap

    line_data = {
        0: {"d": 0},
        1: {"d": 0},
        2: {"d": 13, "g": 24},
        3: {"d": 7},
        4: {"d": 4},
        5: {"d": 3},
        6: {"d": 3},
        7: {"d": 3},
        8: {"d": 4},
        9: {"d": 7},
        10: {"d": 13, "g": 24},
        11: {"d": 0},
        12: {"d": 0},
    }

    ld = line_data

    for ln in range(line_count):
        if ld[ln]["d"] == 0:
            continue

        lines[ln] = get_chars(frame_nr - ld[ln]["d"]) if frame_nr >= ld[ln]["d"] else ""

    for ln in range(line_count):
        if ld[ln].get("g") is None:
            continue

        if len(lines[ln]) >= ld[ln]["g"]:
            index = len(lines[ln]) - ld[ln]["g"]
            lines[ln] = lines[ln][:index] + " " + lines[ln][index + 1 :]

    if frame_nr >= max_len:
        for ln in range(line_count):
            lines[ln] = (
                " " * (frame_nr - max_len) + lines[ln][-(max_len - ld[ln]["d"] - 1) :]
            )

    return lines


def get_chars(count):
    lst = [random.choice(["1", "1", "0"]) for _ in range(count)]
    return "".join(lst)


if __name__ == "__main__":
    main()

1

u/519meshif Aug 06 '23

Reminds me of the old telnet Star Wars thing

2

u/joveaaron Aug 07 '23

I tried to connect to it some time ago. is it still on or is it me? (blinkenlights)

1

u/519meshif Aug 07 '23

Works for me. towel.blinkenlights.nl

1

u/imthebestlolyeee Aug 07 '23

I thought it was a dick flying out