2023-05-19 15:45:43 +02:00
|
|
|
from asyncio import sleep
|
|
|
|
|
from pathlib import Path
|
2023-07-27 22:51:36 +02:00
|
|
|
import sys
|
2023-05-19 15:45:43 +02:00
|
|
|
|
|
|
|
|
'''
|
2023-07-27 22:51:36 +02:00
|
|
|
ASCII Art (Star Wars) 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
|
|
|
|
|
|
2023-07-27 22:51:36 +02:00
|
|
|
try:
|
2023-07-27 22:26:44 +02:00
|
|
|
with open(starwars_file_path, 'r') as f:
|
2023-07-27 22:51:36 +02:00
|
|
|
podaci = f.read().split('\n')
|
2023-07-27 22:26:44 +02:00
|
|
|
print('\n' * LPS)
|
2023-07-27 22:51:36 +02:00
|
|
|
except FileNotFoundError:
|
|
|
|
|
print(f"File {starwars_file_path} does not exist. \nMake sure file is in the same directory as this script and try again.")
|
2023-07-27 22:26:44 +02:00
|
|
|
sys.exit(1)
|
2023-05-19 15:45:43 +02:00
|
|
|
|
2023-07-27 22:54:34 +02:00
|
|
|
## Each frame is 67 columns by 14 rows, so interating the file in chunks of LPS lines
|
2023-07-27 22:51:36 +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())
|