Guest User

Untitled

a guest
Jan 21st, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. require 'io/console'
  2. console_xy = IO.console.winsize
  3. SIZEY = console_xy[0]
  4. COLWIDTH = 3#self explanatory, each bar will have this width in chars
  5. SEPARATOR = 1#number of cols separating two bars
  6. SIZEX =console_xy[1]/(COLWIDTH+SEPARATOR)
  7. count = []
  8. SIZEX.times do
  9. o = rand(SIZEY)
  10. count << o
  11. end
  12. loop do
  13. a = []
  14. SIZEX.times do |i|
  15. o2 = count[i] + rand(-1..1)
  16. count[i] = o2 > SIZEY ? SIZEY : (o2 < 0 ? 0 : o2)
  17. COLWIDTH.times do
  18. a << ([" "]*count[i] + ["♪"]*(SIZEY-count[i]))
  19. end
  20. SEPARATOR.times{ a << [" "]*SIZEY}
  21. end
  22. sleep 0.1
  23. system('clear') || system('cls')
  24. puts a.transpose.map(&:join).join("\n")
  25. end
Add Comment
Please, Sign In to add comment