Forum Archive

Floats with colors

reefboy1

Ok so I was trying to change the color with

console.set_color()

And it ask for a float. Here it comes;

What is a float and can you please give an example of how to change the color

Thanks!

ccc

Floats are defined here. They are numbers with decimal points. So 3 is an integer (or int) while 3.0 is considered a floating point number (or float).

import console, math
for x in (3, 3.0, math.pi):     # int, float, float
    print(x, type(x))

for i in xrange(10):
    f = i * 0.1                 # i is an int but f is a float!
    console.set_color(f, f, f)  # different shades of grey
    print(f, type(f))           # the last one is barely visible!
console.set_color(0, 0, 0)      # reset the color to black
reefboy1

I see, thanks for the help!