Skip to content

Instantly share code, notes, and snippets.

@germanrdz
Created May 30, 2014 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save germanrdz/8292ddf5003d9b074805 to your computer and use it in GitHub Desktop.
Save germanrdz/8292ddf5003d9b074805 to your computer and use it in GitHub Desktop.
class App
class << self
def animate(frames, seconds)
frame = 0;
advance = 1;
frames_per_second = frames.size * 2;
total_frames = frames_per_second * seconds;
total_frames.times do
puts "\e[H\e[2J" # clears the screen
puts frames[frame]
frame += advance;
advance *= -1 if frame == 0 or frame == frames.size - 1;
sleep(1.0/(frames.size*2.0))
end
end
def run
animation = [ "8m===D", "8=m==D", "8==m=D", "8===mD" ]
ending = [ "8m===Do", "8=m==D~o", "8==m=D ~o", "8===mD" ]
animate(animation, 4)
animate(ending, 2)
end
end
end
App.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment