Advertisement
asweigart

Static TV ASCII Art Animation with Python & Bext

Jun 29th, 2022
933
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.06 KB | None | 0 0
  1. import sys, os, random, time, bext
  2.  
  3.  
  4. TV_IMAGE = r'''               o
  5.          o    |
  6.           \  |
  7.            \ |
  8.             \.|-.
  9.             (\|  )
  10.    .==================.
  11.    | .--------------. |
  12.    | 'XXXXXXXXXXXXXX' |
  13.    | 'XXXXXXXXXXXXXX' |
  14.    | 'XXXXXXXXXXXXXX' |
  15.    | 'XXXXXXXXXXXXXX' |
  16.    | 'XXXXXXXXXXXXXX' |
  17.    | '--------------'o|
  18.    | LI LI """""""   o|
  19.    |==================|
  20. jgs |  .------------.  |
  21.    | /              \ |
  22.    |/                \|
  23.    "                  "'''
  24.  
  25. TOP_BLOCK = chr(9600)
  26. BOTTOM_BLOCK = chr(9604)
  27. FULL_BLOCK = chr(9608)
  28. EMPTY = ' '
  29. STATIC_CHARS = (TOP_BLOCK, BOTTOM_BLOCK, FULL_BLOCK, EMPTY)
  30.  
  31. # Clear the screen:
  32. if sys.platform == 'win32':
  33.     os.system('cls')
  34. else:
  35.     os.system('clear')
  36. print(TV_IMAGE)
  37.  
  38. try:
  39.     while True:
  40.         for y in range(5):
  41.             bext.goto(7, 8 + y)
  42.             for x in range(14):
  43.                 sys.stdout.write(random.choice(STATIC_CHARS))
  44.         sys.stdout.flush()
  45.         #time.sleep(0.1)
  46.  
  47. except KeyboardInterrupt:
  48.     pass
  49.  
  50.  
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement