jeudi 23 juillet 2015

Put random numbers inline in Ruby

I have two counters with simple animation that puts numbers under each other. How to make them all inline with the same functional? Thanks for watching!

1000.times do

    puts "Press Enter"
    gets

        x = rand (0..5)
        y = rand (0..5)

        # "x" counter
        10.times do |xx|

            meter = rand (0..5)
            if xx < 9
                print meter
                print "\r"
                sleep 0.08
                else print x
            end
        end

    puts

        # "y" counter
        10.times do |yy|

            meter = rand (0..5)
            if yy < 9
                print meter
                print "\r"
                sleep 0.08
                else print y
            end
        end

    puts

end




Aucun commentaire:

Enregistrer un commentaire