I am lost. I don't know how to implement the code you gave me. This is my first java game.
Ok, let's try to make this simpler for you...
According to the pastebin dump you have your "Map" class. It has several pieces of data like the images. And the map itself is defined by an array of the String type. Good so far?
So, I'm assuming you have a "Game" class of some sort, that displays the map. Inside that class:
1 2 3 4
| public class Game { ArrayList<Map> maps = new ArrayList<Map>(); ... } |
This creates an ArrayList (
http://www.java-samples.com/showtutorial.php?tutorialid=234).
This means that the ArrayList can hold objects of the Map class that you created. Now I'm assuming that you have a way of detecting when the game ends, so here's some pseudocode:
1 2 3 4 5 6 7 8 9
| if(gameEnd){ for(int i = 0; i < maps.size(); i++){ if(maps.get(i) == currentMap){ if(i + 1 < maps.size()) currentMap = maps.get(i + 1); else currentMap = maps.get(0); }} } |
So basically, if the game is detected to be ended, then the current map is set to the next map in the list. The "for" loop is just to determine what map is currently running. The current map is set to the next map by using getting the next index (i + 1).