Skip to content

Instantly share code, notes, and snippets.

@ewized
Created October 24, 2014 21:47
Show Gist options
  • Save ewized/11686deb4bd4a946c0e6 to your computer and use it in GitHub Desktop.
Save ewized/11686deb4bd4a946c0e6 to your computer and use it in GitHub Desktop.
Sample code to display the new countdown for MC 1.8 titles
#!/usr/bin/python3
import time
# Center the text with the deli
def center_text(header: str, deli: str, size: int) -> str:
half = int(size / 2 - len(header) / 2)
return deli*half + " " + header + " " + deli*half
# Return True or False if index is in the no no spot
def nono(header: str, size: int, pos: int):
half = size / 2 - len(header) / 2
return pos < half or pos - 1 > (half + len(header))
# Print out the display
# .......... 60 ..........
# .......... 59 ..........
# .......... 58 ..........
for i in range(0, 60):
i = 59 - i
size = 60
print(center_text("Midnight Rage", " ", size))
time_text = "0:" + (str(i) if i >= 10 else "0" + str(i))
text = center_text(time_text, ".", size)
half = size / 2 + len(time_text)
if nono(time_text, size, i):
print(text[:i] + "," + text[i:])
else:
print(text)
print("\n" * 5)
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment