O'Reilly logo

Web Design Blueprints by Benjamin LaGrone

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Spreading the objects

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required