Created
February 27, 2014 20:46
-
-
Save atduskgreg/9259218 to your computer and use it in GitHub Desktop.
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
LoopingFile loop1; | |
LoopingFile loop2; | |
LoopingFile loop3; | |
void setup() { | |
loop1 = new LoopingFile("level1_map.txt"); | |
loop2 = new LoopingFile("level2_map.txt"); | |
loop3 = new LoopingFile("level3_map.txt"); | |
} | |
void draw() { | |
println("loop1: " + loop1.currentLineNum() + loop1.nextLine()); | |
println("loop2: " + loop2.currentLineNum() +loop2.nextLine()); | |
println("loop3: " + loop3.currentLineNum() +loop3.nextLine()); | |
} | |
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
class LoopingFile { | |
String[] lines; | |
int currentLine = -1; | |
LoopingFile( String nameOfFile){ | |
lines = loadStrings(nameOfFile); | |
} | |
int currentLineNum(){ | |
return currentLine; | |
} | |
String nextLine(){ | |
currentLine++; | |
if(currentLine > lines.length - 1){ | |
currentLine = 0; | |
} | |
return lines[currentLine]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment