Skip to content

Instantly share code, notes, and snippets.

@tana
Created March 13, 2011 11:48
Show Gist options
  • Save tana/868038 to your computer and use it in GitHub Desktop.
Save tana/868038 to your computer and use it in GitHub Desktop.
使い方: 「ruby orz.rb」または「ruby orz.rb -s」
require 'curses'
$mode = ARGV[0] == "-s"
class Orz
def initialize(x, y)
@x = x
@y = y
end
attr_accessor :x, :y
end
$orzs = []
$cnt = 0
def new_orz
y = Math.sin($cnt) * 10 + 10 if $mode == true
y = rand(23) if $mode == false
$orzs << Orz.new(70, y)
$cnt = $cnt + 0.2
end
Curses::init_screen
100.times {|cnt|
Curses::clear
$orzs = $orzs.select {|orz| orz.x > 0}
$orzs.each {|orz|
Curses::setpos(orz.y, orz.x)
Curses::addstr("orz")
orz.x = orz.x - 1
}
new_orz if (if $mode then true else cnt % 2 == 0 end)
Curses::refresh
sleep(0.1)
}
Curses::close_screen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment