Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #----------------------------------------------
- # Animated Banner Program
- #----------------------------------------------
- #allows us to clear the console screen.
- import os
- import time
- #the width of the display
- #(the windows console is 153 characters wide).
- WIDTH = 153
- #the message we wish to print
- message = "hello! vcksquare!!!".upper()
- #the printed banner version of the message
- #this is a 20-line display, stored as 20 strings
- #initially, these are empty.
- printedMessage = [ "","","","","","","","","","","","","","","","","","","","","","" ]
- #a dictionary mapping letters to their 20-line
- #banner display equivalents. each letter in the dictionary
- #maps to 20 strings, one for each line of the display.
- characters = { " " : [ " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " "],
- "C" : [ " ***",
- " * ",
- "* ",
- "* ",
- "* ",
- " * ",
- " ***" ],
- "E" : [ "*****",
- "* ",
- "* ",
- "*****",
- "* ",
- "* ",
- "*****" ],
- "H" : [ "* *",
- "* *",
- "* *",
- "*****",
- "* *",
- "* *",
- "* *" ],
- "O" : [ "*****",
- "* *",
- "* *",
- "* *",
- "* *",
- "* *",
- "*****" ],
- "L" : [ "* ",
- "* ",
- "* ",
- "* ",
- "* ",
- "* ",
- "*****" ],
- "!" : [ " * ",
- " * ",
- " * ",
- " * ",
- " * ",
- " ",
- " * " ],
- "V" : [ "* *",
- "* *",
- "* *",
- " * * ",
- " * * ",
- " * * ",
- " * " ],
- "Q" : [ "***** ",
- "* * ",
- "* * ",
- "* * ",
- "* * * ",
- "* ** ",
- "****| "],
- "U" : [ "* *",
- "* *",
- "* *",
- "* *",
- "* *",
- "* *",
- "*****" ],
- "R" : [ "***** ",
- "* * ",
- "* * ",
- "*--* ",
- "* '' ",
- "* '' ",
- "* ''"],
- "K" : ["* / ",
- "* / ",
- "* / ",
- "*** ",
- "* '' ",
- "* '' ",
- "* ''"],
- "S" : [ "*****",
- "* ",
- "* ",
- "*****",
- " *",
- " *",
- "*****" ],
- "A" : [ " *** ",
- "* *",
- "* *",
- "*****",
- "* *",
- "* *",
- "* *" ]
- }
- #build up the printed banner. to do this, the 1st row of the
- #display is created for each character in the message, followed by
- #the second line, etc..
- for row in range(7):
- for char in message:
- printedMessage[row] += (str(characters[char][row]) + " ")
- #the offset is how far to the right we want to print the message.
- #initially, we want to print the message just off the display.
- offset = WIDTH
- while True:
- os.system("cls")
- #print each line of the message, including the offset.
- for row in range(7):
- print(" " * offset + printedMessage[row][max(0,offset*-1):WIDTH - offset])
- #move the message a little to the left.
- offset -=1
- #if the entire message has moved 'through' the display then
- #start again from the right hand side.
- if offset <= ((len(message)+2)*6) * -1:
- offset = WIDTH
- #take out or change this line to speed up / slow down the display
- time.sleep(0.05)
Add Comment
Please, Sign In to add comment