genau:
1 2 3 4
|
loop{7.times{|i|puts"\e[2J\e[0;3H_...\n / _ '.\n|.'(@@@@@)\n(*)/ %s \\ | .o. |\n ( %s ) %s"%[i==5?"- -":"e e",(i+3)%7<4?"=":"o",i>0?"-"+ (" Ho"*i)[0,9]+"!":""];puts" ( )\n"*2," ( )\n"*3,' "-"'; sleep([5,3,3,4,5,1,4][i]/6.0)}} |
und wenn dein erminal auch mit mehrereren leerzeichen copy&paste aus browser probleme hat:
1 2 3 4
|
loop{7.times{|i|puts"\e[2J\e[0;3H_...\nZ/Z_ZZ'.\n|.'(@@@@@)\n(*)/Z%sZ\\ ZZZ|Z.o.Z|\nZZZ(ZZ%sZZ)Z%s"%[i==5?"-Z-":"eZe",(i+3)%7<4?"=":"o",i>0?"-"+ ("ZHo"*i)[0,9]+"!":""];puts"ZZZ(ZZZZZ)\n"*2,"ZZZZ(ZZZ)\n"*3,'ZZZZZ"-"'; sleep([5,3,3,4,5,1,4][i]/6.0)}} |
einfach "Z" durch " " ersätzen
und
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
puts "\e[44;1m\e[2J\e[H" class Snowflake attr_reader :x, :y def initialize() @x = rand @y = rand @xspeed = (rand*2-1)/160 @yspeed = (0.5+rand)/40 @color = [33,37][(rand*2).to_i] @type = rand*8 end def step @y+=@yspeed @x+=@xspeed @xspeed+=(rand*2-1)/320 if @x < 0 || @x > 1 || @y > 1 @x = rand @y = 0 @xspeed = (rand*2-1)/160 @yspeed = (0.5+rand)/40 @color = [33,37][(rand*2).to_i] @type = rand*8 end end def draw xchrs = (@x*$width).to_i ychrs = (@y*$height).to_i if @type < 1 "\e[#{ychrs};#{xchrs}H\e[#{@color.to_s}m\\|/\e[B\e[3D/|\\" else "\e[#{ychrs};#{xchrs}H\e[#{@color.to_s}m*" end end end $tty= `stty -g` atexit = proc do print " \e[33;44;1m\e[2J\e[#{$height/2};#{$width/2-11}H* Merry Christmas *\e[#{$height};0HPress Return\e[H" gets puts "\e[0m\e[2J\e[H" system("stty #{$tty}") exit end system("stty -echo") trap "SIGINT", atexit snowflakes = [] 60.times do snowflakes << Snowflake.new end td=0.1 lt = Time.new+td loop do $width=`tput cols`.to_i $height=`tput lines`.to_i if $width < 4 $width=80 end if $height < 4 $height=24 end output = "\e[44;1m\e[2J" snowflakes.each do |snowflake| snowflake.step output << snowflake.draw end print output+"\e[H" $stdout.flush while lt>Time.new end lt=Time.new+td end |
Frohe Weihnachten dann![/code]