mirror of
https://github.com/mgracanin/ASCIIStarWars.git
synced 2026-04-24 11:16:22 +02:00
Update __init__.py
This commit is contained in:
parent
287d3ba560
commit
893225f247
1 changed files with 8 additions and 7 deletions
15
__init__.py
15
__init__.py
|
|
@ -1,9 +1,9 @@
|
|||
from asyncio import sleep
|
||||
from pathlib import Path
|
||||
import os, sys
|
||||
import sys
|
||||
|
||||
'''
|
||||
ASCII Art from https://www.asciimation.co.nz/
|
||||
ASCII Art (Star Wars) from https://www.asciimation.co.nz/
|
||||
'''
|
||||
|
||||
starwars_file_path = (f"{Path(__file__).parent}/starwars.txt")
|
||||
|
|
@ -11,15 +11,16 @@ starwars_file_path = (f"{Path(__file__).parent}/starwars.txt")
|
|||
async def main():
|
||||
LPS = 14 ## Lines per frame
|
||||
|
||||
if os.path.exists(starwars_file_path):
|
||||
try:
|
||||
with open(starwars_file_path, 'r') as f:
|
||||
podaci = f.read().split('\n')
|
||||
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.")
|
||||
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.")
|
||||
sys.exit(1)
|
||||
|
||||
for i in range(0, len(podaci), LPS):
|
||||
## Each frame is 67 columns by 14 rows
|
||||
for i in range(0, len(podaci), LPS):
|
||||
print("\x1b[{}A\x1b[J{}".format(LPS, '\n'.join(podaci[i + 1:i + LPS]))) # \x1b[{}A\x1b[J move ESC char 14 lines
|
||||
await sleep(int(podaci[i]) * 67 / 1000) ## Delay = 67
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue