Skip to content

Instantly share code, notes, and snippets.

@easrng
Last active December 18, 2019 01:08
Show Gist options
  • Save easrng/c73942532bd23fb747bbcf2ab9fd248b to your computer and use it in GitHub Desktop.
Save easrng/c73942532bd23fb747bbcf2ab9fd248b to your computer and use it in GitHub Desktop.
import urllib.request
class Santa:
def draw(self):
currentscreen[self.pos.y][self.pos.x]
santa=Santa()
WIDTH = 68
HEIGHT = 21
def draw():
currentscreen=world;
santa.draw()
def santa_loc(c_day, c_hour, c_minute):
if c_day == 24:
location1 = (WIDTH/27)*(c_hour - 10)
location2 = ((WIDTH/27)/60)*(c_minute)
else:
location1 = (WIDTH/27)*(c_hour + 14)
location2 = ((WIDTH/27)/60)*(c_minute)
santa.pos = (WIDTH - (location1 + location2)), (HEIGHT/2)
def update():
response = urllib.request.urlopen (
'http://just-the-time.appspot.com/')
web_time = (response.read()).decode('utf-8')
c_day = web_time[0:2]
c_month = web_time[3:5]
c_hour = int(web_time[11:13])
c_minute = int(web_time[14:16])
if c_month == 12 and c_day == 24:
if c_hour >= 10:
santa_loc(c_day, c_hour, c_minute)
else:
santa.pos = (WIDTH), (HEIGHT/2)
elif c_month == 12 and c_day == 25:
if c_hour <= 12:
santa_loc(c_day, c_hour, c_minute)
else:
santa.pos = (WIDTH-WIDTH), (HEIGHT/2)
else:
santa.pos = (WIDTH), (HEIGHT/2)
while True:
update()
draw()
print(currentworld)
sleep(1)
world=""" ,_ . ._. _. .
, _-\','|~\~ ~/ ;-'_ _-' ,;_;_, ~~-
/~~-\_/-'~'--' \~~| ', ,' / / ~|-_\_/~/~ ~~--~~~~'--_
/ ,/'-/~ '\ ,' _ , '|,'|~ ._/-, /~
~/-'~\_, '-,| '|. ' ~ ,\ /'~ / /_ /~
.-~ '| '',\~|\ _\~ ,_ , /|
'\ /'~ |_/~\\,-,~ \ " ,_,/ |
| / ._-~'\_ _~| \ ) /
\ __-\ '/ ~ |\ \_ / ~
., '\ |, ~-_ - | \\_' ~| /\ \~ ,
~-_' _; '\ '-, \,' /\/ |
'\_,~'\_ \_ _, /' ' |, /|'
/ \_ ~ | / \ ~'; -,_.
| ~\ | | , '-_, ,; ~ ~\
\, / \ / /| ,-, , -,
| ,/ | |' |/ ,- ~ \ '.
,| ,/ \ ,/ \ |
/ | ~ -~~-, / _
| ,-' ~ /
/ ,' ~
',| ~
~'"""
world=world.split("\n")
newworld=[]
for line in world:
newworld.append(line.rjust(68).split())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment