ASCIIStarWars/__init__.py

29 lines
839 B
Python
Raw Normal View History

2023-05-19 15:45:43 +02:00
from asyncio import sleep
from pathlib import Path
2023-07-27 22:27:28 +02:00
import os, sys
2023-05-19 15:45:43 +02:00
'''
2023-05-19 15:53:26 +02:00
ASCII Art from https://www.asciimation.co.nz/
2023-05-19 15:45:43 +02:00
'''
starwars_file_path = (f"{Path(__file__).parent}/starwars.txt")
async def main():
2023-07-27 22:26:44 +02:00
LPS = 14 ## Lines per frame
if os.path.exists(starwars_file_path):
with open(starwars_file_path, 'r') as f:
podaci = f.read().split('\n')
print('\n' * LPS)
else:
print(f"File {starwars_file_path} does not exist. Make sure file is in the same directory as this script.")
sys.exit(1)
2023-05-19 15:45:43 +02:00
for i in range(0, len(podaci), LPS):
2023-07-27 22:26:44 +02:00
print("\x1b[{}A\x1b[J{}".format(LPS, '\n'.join(podaci[i + 1:i + LPS]))) # \x1b[{}A\x1b[J move ESC char 14 lines
2023-05-19 15:45:43 +02:00
await sleep(int(podaci[i]) * 67 / 1000) ## Delay = 67
if __name__ == '__main__':
import asyncio
asyncio.run(main())