# Trying to add a feature to my (basic) level parsing algorithm - not sure how to (JAVA)

Right now this method goes through a list of GameObjects (e.g. JetPack, Platform) with their respective x and y positions in a text file called level1.txt:

platform 840 280
platform 1130 280
coin 900 300
coin 950 300
coin 1000 300
coin 1000 400
jetpack 1090 400
platform 650 500
platform 500 400
platform 200 400
NEXT
platform 200 200
coin 250 300
coin 350 700


What currently happens is whenever my Player reaches the end of the screen, he goes back to the start (x = 0). When he does reach the end of the screen, I want all the objects BEFORE NEXTto disappear and all the objects AFTER NEXT to be drawn. I know why my algorithm doesn't work as it should but I'm unsure how to fix it. Can anyone have a look at it and tell me how I can modify it to do what I want it to? listis a list of GameObjects in the text file btw.

public void loadLevel(String level) {
list.clear();
FileHandle file = Gdx.files.internal(level);
while (tokens.hasMoreTokens()) {
String type = tokens.nextToken();

if (type.equals("platform")) {
Integer.parseInt(tokens.nextToken())));
}
else if (type.equals("coin")) {
.parseInt(tokens.nextToken())));
} else if (type.equals("flag")) {
.parseInt(tokens.nextToken())));
} else if (type.equals("jetpack")) {
Integer.parseInt(tokens.nextToken())));
} else if (type.equals("pipe")) {
.parseInt(tokens.nextToken())));
} else if (type.equals("NEXT") && player.getxPos() > SCREEN_WIDTH) {
list.clear();
}
}
}


Any help is highly appreciated, many thanks in advance.

} else if (type.equals("NEXT") && player.getxPos() > SCREEN_WIDTH) {