Skip to content

Instantly share code, notes, and snippets.

@shrutis22
Created January 15, 2016 07:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shrutis22/6653ebff023f94d06774 to your computer and use it in GitHub Desktop.
Save shrutis22/6653ebff023f94d06774 to your computer and use it in GitHub Desktop.
Function to generate random positions for Divs
function randBlocks() {
var randYellow = parseInt(Math.random() * 10) % 4
var yellow = randYellow * 100;
var randBlue = parseInt(Math.random() * 10) % 4
var blue = randBlue * 100;
var randGreen = parseInt(Math.random() * 10) % 4
var green = randGreen * 100;
opponentPos = [yellow, blue, green];
$(".opponent-1").css("left", yellow);
$(".opponent-2").css("left", blue);
$(".opponent-3").css("left", green);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment