派手に!
「キ・ヨ・シ!」を派手にできないかと思っていたらちょうどいいのが
peterbrittain/asciimatics: A cross platform package to do curses-like operations and create ASCII art animations
A cross platform package to do curses-like operations and create ASCII art animations
実装
ズンドコ部分は以下から拝借
Pythonでズンドコキヨシ(ジェネレータ) - Qiita
コード
# -*- coding: utf-8 -*-
from asciimatics.effects import Cycle, Stars
from asciimatics.renderers import ColourImageFile
from asciimatics.scene import Scene
from asciimatics.screen import Screen
from collections import deque
import random
import time
z = u'ズン'
d = u'ドコ'
def kiyoshi(screen):
effects = [
Cycle(
screen,
ColourImageFile(screen,"kiyoshi.gif",15),
(screen.height - 15)/ 2)
,Stars(screen, 200)
]
screen.play([Scene(effects)], stop_on_resize=True)
def zndkkys2():
state = 0
while True:
num = random.choice((0, 1, ))
# ズンならカウントアップ
if num:
yield z
state += 1
else:
yield d
# ドコの前に4回以上ズンが連続していたらキ・ヨ・シ!
if state >= 4:
return
# ドコの前のズンが3回以下ならカウントを初期化
else:
state = 0
if __name__ == '__main__':
print ''.join(zndkkys2())
time.sleep(1)
Screen.wrapper(kiyoshi)