Skip to content

Instantly share code, notes, and snippets.

@xuboying
Last active February 28, 2016 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xuboying/c5729efc066520a9565f to your computer and use it in GitHub Desktop.
Save xuboying/c5729efc066520a9565f to your computer and use it in GitHub Desktop.
🐐 🐐 🐐 🐐 🐐 🐐 🐐 🐐 🐐 🐐 🐐 🐐 🐐 🐐 🐐 🐐 🐐 🐐 🐐
#!/usr/bin/env python
import curses
import time
import sys
import random
stdscr = curses.initscr()
from curses import wrapper
height, width = stdscr.getmaxyx()
Total = 100000
Num = Total
random.seed()
class caonima:
def __init__(self, y, n, s = 10):
global width
self.m_x = width
self.m_str = u"\U0001F410 " * n
self.m_y = y
self.m_speed = s
self.m_speed1 = 0
def move(self):
self.m_speed1 = self.m_speed1 + 1
if self.m_speed1 < self.m_speed:
return self
self.m_speed1 = 0
global stdscr
if - self.m_x > len(self.m_str):
return None
self.m_x = self.m_x - 1
x = self.m_x
displayscr = self.m_str[0 : width - self.m_x]
if self.m_x < 0:
x = 0
displayscr = self.m_str[abs(self.m_x) : width - self.m_x]
stdscr.addstr(self.m_y, x, displayscr)
return self
def main(stdscr):
global Num
global Total
# Clear screen
stdscr.clear()
screen = [None] * (height - 2)
while True:
for j in range(1, len(screen)):
if not screen[j]:
if random.randint(0, 100) > 50 and Num > 0:
n = random.randint(1, 100) if Num > 100 else Num
Num = Num - n
screen[j] = caonima(j, n, random.randint(1, 10))
else:
screen[j]=screen[j].move()
if Num>0:
continue
for j in screen:
if j:
continue
stdscr.addstr(0, 0,"%d/%dεͺ\U0001F410 εœ¨ε†… \u2764 ι£˜θΏ‡" % (Total - Num, Total))
time.sleep(0.002)
stdscr.refresh()
wrapper(main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment