The untaught lesson
"""
* Creator: Nighthawk Coding Society
Sailing Ship Animation (programatic method)
"""
import time # used for delay
from IPython.display import clear_output # jupyter specific clear
# ANSI Color Codes
OCEAN_COLOR = u"\u001B[34m\u001B[2D"
SHIP_COLOR = u"\u001B[32m\u001B[2D"
RESET_COLOR = u"\u001B[0m\u001B[2D"
def ship_print(position): # print ship with colors and leading spaces according to position
clear_output(wait=True)
print(RESET_COLOR)
sp = " " * position
print(sp + " |\ ")
print(sp + " |/ ")
print(SHIP_COLOR, end="")
print(sp + "\__ |__/ ")
print(sp + " \____/ ")
print(OCEAN_COLOR + "--"*35 + RESET_COLOR)
def ship(): # ship function, loop/controller for animation speed and times
# loop control variables
start = 0 # start at zero
distance = 60 # how many times to repeat
step = 2 # count by 2
# loop purpose is to animate ship sailing
for position in range(start, distance, step):
ship_print(position) # call to function with parameter
time.sleep(.2)
ship() # activate/call ship function
import time
from IPython.display import clear_output
top = [" ", "o ", " "]
middle = ["/", "|", "\ "]
bottom = ["/", " ", "\ "]
def mash():
global top
global middle
global bottom
x = top[0] + top[1] + top[2]
y = middle[0] + middle[1] + middle[2]
z = bottom[0] + bottom[1] + bottom[2]
clear_output()
time.sleep(.2)
print(x)
print(y)
print(z)
mash()
def reset():
global top
global middle
global bottom
top = [" ", "o ", " "]
middle = ["/", "|", "\ "]
bottom = ["/", " ", "\ "]
x = top[0] + top[1] + top[2]
y = middle[0] + middle[1] + middle[2]
z = bottom[0] + bottom[1] + bottom[2]
clear_output(wait=True)
time.sleep(.2)
print(x)
print(y)
print(z)
def pritn():
x = top[0] + top[1] + top[2]
y = middle[0] + middle[1] + middle[2]
z = bottom[0] + bottom[1] + bottom[2]
clear_output(wait=True)
time.sleep(.2)
print(x)
print(y)
print(z)
def bash():
top[2] = "/"
middle[2] = "/"
def cash():
top[2] = "|"
def rash():
top[2] = "_"
i = 0
while i < 5:
bash()
pritn()
cash()
pritn()
bash()
pritn()
rash()
pritn()
i += 1
reset()
def back():
top[0] = " "
bottom[0] = " /"
middle[0] = "--"
middle[2] = "--"
def sack():
middle[2] = "~~"
middle[0] = "--"
def rack():
middle[0] = "~~"
middle[2] = "--"
i = 0
back()
pritn()
while i < 5:
sack()
pritn()
rack()
pritn()
i += 1
reset()