Let's continue. Next, we will want to create a function that will spread the objects randomly up and down each row. It will be used on the stars in the space row, the clouds in the sky row, and the buildings and trees at the bottom. The next function will need you to create a new function called spreadObjects()
and have it receive the variables x
, vm
, hm
, ha
, p
, and e
.
These variable names represent the data they will receive: x
for an array of objects, vm
for the vertical multiplier, hm
for the horizontal multiplier, va
for vertical addition, ha
for horizontal addition, p
for position type, and e
for the extension (px
or %
).
With x
, we will loop through the array of objects and, for each object in the loop, set its style position to the variable p
, the style to be a random number multiplied by vm
with va
added to it, and finally, the e
added to the end. We will do the same for the object style left property and vm
, vh
, and e
. Look at this code for the function:
function...