Created
November 20, 2012 01:19
-
-
Save jage/7f7c664ae47478e043b2 to your computer and use it in GitHub Desktop.
Ruby 1.8.7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'curses' | |
include Curses | |
stdscr.keypad c=v=h=1 | |
def w t,*o | |
setpos *o | |
addstr t | |
refresh | |
end | |
l=7 | |
p=0 | |
Thread.new{loop{c+=v=(1..cols-3)===c ?v:-v | |
l+=h=(1..lines-2)===l ?h:-h | |
clear | |
w '| | |
'*4,p,0 | |
w 'o',l,c | |
!((p..p+4)===l)&&c<2&&break | |
sleep 0.05}} | |
loop{e=getch | |
e==259&&p>0&&p-=1 | |
e==258&&p<lines-4&&p+=1} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you use Ruby 2.1.0 or newer, install curses from rubygems.