Skip to content

Instantly share code, notes, and snippets.

@jage
Created November 20, 2012 01:19
Show Gist options
  • Save jage/7f7c664ae47478e043b2 to your computer and use it in GitHub Desktop.
Save jage/7f7c664ae47478e043b2 to your computer and use it in GitHub Desktop.
Ruby 1.8.7
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}
@jage
Copy link
Author

jage commented Aug 26, 2015

If you use Ruby 2.1.0 or newer, install curses from rubygems.

gem install curses
ruby -rcurses unipong.rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment