Created
November 3, 2011 01:41
-
-
Save jessbowers/1335536 to your computer and use it in GitHub Desktop.
Javascript loop example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Instead of something like this: | |
level0_obstacle1[100] = "obstacles10.png"; | |
level0_obstacle1[3700] = "obstacles10.png"; | |
level0_obstacle1_add4[3900] = "obstacles10.png"; | |
level0_obstacle1[6600] = "obstacles10.png"; | |
level0_obstacle1[10100] = "obstacles10.png"; | |
level0_obstacle1_add4[10500] = "obstacles10.png"; | |
level0_obstacle1[16000] = "obstacles10.png"; | |
level0_obstacle1[16700] = "obstacles10.png"; | |
level0_obstacle1[22400] = "obstacles10.png"; | |
level0_obstacle1[25400] = "obstacles10.png"; | |
// you can do this: | |
for (var i=550; i < 28000; i += 1100) { | |
level0_obstacle1[i] = "obstacles10.png"; | |
} | |
// the 550 is the starting number, the 1100 is the amount to increment each time | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment