LoginSignup
25
18

More than 5 years have passed since last update.

リズムに乗ってズンドコキヨシ♪ with Ruby

Last updated at Posted at 2016-03-14

ふつうの(?)ズンドコキヨシは一瞬で結果が出てキヨシのありがたみが感じられないので、
リズムに乗って表示されるようにした。

最初から"ドコ"が出てきたときの切なさ、
"ズンズンズンズン"と来て最後も"ズン"だったときの絶望感、
"ドコ"始まりがしばらく続いた後にやってきた"ズン"始まりの救世主感、
そして"キ・ヨ・シ!"の爽快感(想像以上に気持ちいい)。

全ては実行した者のみが味わえる極上のひととき。

def zundoko
  loop do
    n = rand(32)
    s = ("%05b" % n).gsub(/0/, 'ズン').gsub(/1/, 'ドコ')
    r = [0, 1.0, 0, 0.5, 0, 0.5, 0, 0.5, 0.25, 0.25]
    print_with_rythm s, r

    if n == 1
      print_with_rythm "キ・ヨ・シ!", [0, 0.25, 0, 0.25, 0, 1.0]
      break
    end

    puts
  end
end

def print_with_rythm(s, r)
  s.split(//).zip(r).each do |c, w|
    print c
    sleep(w)
  end
end

zundoko

リズムに乗る関係上、5個区切りの判定に。
そうなると、"ズン"->0, "ドコ"->1と考えたときに、rand(32)が1を出すのを待つのと意味合い的に同じになるじゃん、ってことで、それっぽくズンドコを作ってみた。

25
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
25
18