Guest User

Untitled

a guest
Jan 20th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.15 KB | None | 0 0
  1. #----------------------------------------------
  2. # Animated Banner Program
  3. #----------------------------------------------
  4.  
  5. #allows us to clear the console screen.
  6. import os
  7.  
  8. import time
  9.  
  10. #the width of the display
  11. #(the windows console is 153 characters wide).
  12. WIDTH = 153
  13.  
  14. #the message we wish to print
  15. message = "hello! vcksquare!!!".upper()
  16. #the printed banner version of the message
  17. #this is a 20-line display, stored as 20 strings
  18. #initially, these are empty.
  19. printedMessage = [ "","","","","","","","","","","","","","","","","","","","","","" ]
  20.  
  21. #a dictionary mapping letters to their 20-line
  22. #banner display equivalents. each letter in the dictionary
  23. #maps to 20 strings, one for each line of the display.
  24. characters = { " " : [ " ",
  25. " ",
  26. " ",
  27. " ",
  28. " ",
  29. " ",
  30. " ",
  31. " ",
  32. " ",
  33. " ",
  34. " ",
  35. " ",
  36. " ",
  37. " ",
  38. " ",
  39. " ",
  40. " ",
  41. " ",
  42. " ",
  43. " ",
  44. " "],
  45.  
  46. "C" : [ " ***",
  47. " * ",
  48. "* ",
  49. "* ",
  50. "* ",
  51. " * ",
  52. " ***" ],
  53.  
  54. "E" : [ "*****",
  55. "* ",
  56. "* ",
  57. "*****",
  58. "* ",
  59. "* ",
  60. "*****" ],
  61.  
  62. "H" : [ "* *",
  63. "* *",
  64. "* *",
  65. "*****",
  66. "* *",
  67. "* *",
  68. "* *" ],
  69.  
  70. "O" : [ "*****",
  71. "* *",
  72. "* *",
  73. "* *",
  74. "* *",
  75. "* *",
  76. "*****" ],
  77.  
  78. "L" : [ "* ",
  79. "* ",
  80. "* ",
  81. "* ",
  82. "* ",
  83. "* ",
  84. "*****" ],
  85.  
  86. "!" : [ " * ",
  87. " * ",
  88. " * ",
  89. " * ",
  90. " * ",
  91. " ",
  92. " * " ],
  93.  
  94. "V" : [ "* *",
  95. "* *",
  96. "* *",
  97. " * * ",
  98. " * * ",
  99. " * * ",
  100. " * " ],
  101.  
  102. "Q" : [ "***** ",
  103. "* * ",
  104. "* * ",
  105. "* * ",
  106. "* * * ",
  107. "* ** ",
  108. "****| "],
  109.  
  110. "U" : [ "* *",
  111. "* *",
  112. "* *",
  113. "* *",
  114. "* *",
  115. "* *",
  116. "*****" ],
  117.  
  118. "R" : [ "***** ",
  119. "* * ",
  120. "* * ",
  121. "*--* ",
  122. "* '' ",
  123. "* '' ",
  124. "* ''"],
  125.  
  126. "K" : ["* / ",
  127. "* / ",
  128. "* / ",
  129. "*** ",
  130. "* '' ",
  131. "* '' ",
  132. "* ''"],
  133.  
  134. "S" : [ "*****",
  135. "* ",
  136. "* ",
  137. "*****",
  138. " *",
  139. " *",
  140. "*****" ],
  141.  
  142. "A" : [ " *** ",
  143. "* *",
  144. "* *",
  145. "*****",
  146. "* *",
  147. "* *",
  148. "* *" ]
  149.  
  150. }
  151.  
  152. #build up the printed banner. to do this, the 1st row of the
  153. #display is created for each character in the message, followed by
  154. #the second line, etc..
  155. for row in range(7):
  156. for char in message:
  157. printedMessage[row] += (str(characters[char][row]) + " ")
  158.  
  159. #the offset is how far to the right we want to print the message.
  160. #initially, we want to print the message just off the display.
  161. offset = WIDTH
  162. while True:
  163. os.system("cls")
  164. #print each line of the message, including the offset.
  165. for row in range(7):
  166. print(" " * offset + printedMessage[row][max(0,offset*-1):WIDTH - offset])
  167. #move the message a little to the left.
  168. offset -=1
  169. #if the entire message has moved 'through' the display then
  170. #start again from the right hand side.
  171. if offset <= ((len(message)+2)*6) * -1:
  172. offset = WIDTH
  173. #take out or change this line to speed up / slow down the display
  174. time.sleep(0.05)
Add Comment
Please, Sign In to add comment