Step 3: Generate a Random Speed
If X Speed value is ever equal to 0, then it will be replaced with a random value. This means we can either assign a speed when we create the Enemy, or we can leave it undefined and have a value generated at random.- X Speed of
= 0
: Set X Speed to 0.75+(Random(6)/10.0)
However, we want a number much smaller than that, so we divide by 10 and the random value is now between 0 and 0.5. Then by adding 0.75, the final result is somewhere between 0.75 and 1.25.
6