Random Function • SKILLS CHECK

Instructor: Tiffany Holmes • tholmes@artic.edu • 312.345.3760

 

Lingo functions: random()

Example: This statement produces a random multiple of 5 in the range 5 to 100: x = 5 * random(20)

 

Exercises (single frame movies):

  1. 1. Place a sprite on a stage (500x330 pixels) and make it move randomly in a horizontal direction to one of these locH options: 100, 200, 300, 400.
  2. 2. Place a bitmap sprite on stage, and make its blend change randomly in a range from 75 to 100.
  3. 3. Place a vector rectangular frame (a rectangle outline shape in the vector shape window’s toolkit) on the stage. Using Lingo or the Property Inspector, turn trails on. Now make the shape rotate randomly. (HINT: If you get this working try changing the width and height also.)

 

ADVANCED LINGO:

Lingo properties: the floatPrecision

The floatPrecision is a property; it rounds off the display of floating-point numbers to the number of decimal places specified. The value of floatPrecision must be an integer. The maximum value is 15 significant digits; the default value is 4.

Example: This statement produces a random two-point decimal value:

the floatPrecision = 2

y = random(100)/100.0 - .01

***Useful and interesting background reading: The New York Times, June 12, 2001, Connoisseurs of Chaos Offer a Valuable Product: Randomness, by George Johnson