class AsciiParadise::AnimatedPacman
Constants
- YELLOW_AND_RESET
#¶ ↑
YELLOW_AND_RESET
¶ ↑#¶ ↑
Public Class Methods
Public Instance Methods
run()
click to toggle source
#¶ ↑
run¶ ↑
#¶ ↑
# File lib/ascii_paradise/animations/animated_pacman.rb, line 36 def run print CLEAR_COMMAND+YELLOW_AND_RESET # This will also turn the stuff to yellow. z = 0.0 dz = 0.05 loop { z += dz # Add the 0.05 difference to z. dz = -dz if ( z < 0.0 || z > 0.2) print "\033[0;0f" (-10..10).each {|y| s = ''.dup # This will be the string that will be displayed. (-39..39).each {|x| s << ((x/2) ** 2 + y ** 2 < 11 ** 2\ && atan2(y,x/2) < PI * (1.0 - z) \ && atan2(y,x/2) > -PI * (1.0 - z) ? '@':' ') } puts s } sleep 0.03 } # ';reset # Get cursor back :) end