Skip to content

Instantly share code, notes, and snippets.

@ollybritton
Last active April 16, 2016 19:50
Show Gist options
  • Save ollybritton/17c66c3dc996b1b58aef010f36048d1e to your computer and use it in GitHub Desktop.
Save ollybritton/17c66c3dc996b1b58aef010f36048d1e to your computer and use it in GitHub Desktop.
for (i = 0; i < 1001; i++) {
(function(i){
setTimeout(function(){
var star = stars.create(Math.floor(Math.random() * 20 + 1 + currentX ),
Math.floor(Math.random() * 120 + 100 ), 'star');
// Create Starts That Rain Above Player With A Bit Of 'Noise' (x, y, type)
star.body.gravity.y = 300;
// Set The Gravity To Make Them Fall Faster
star.body.bounce.y = 0.7 + Math.random() * 0.2;
// Make Them Bounce A Bit
}, Math.floor(Math.random() * 400 + 100) /* <-- Adding a bit of 'noise' to the delay. */ * i);
}(i));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment