Skip to content

Instantly share code, notes, and snippets.

@atduskgreg
Created February 27, 2014 20:46
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 atduskgreg/9259218 to your computer and use it in GitHub Desktop.
Save atduskgreg/9259218 to your computer and use it in GitHub Desktop.
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());
}
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