[LWJGL] Level system

I successfully have a basic game working properly. I wanted to make other levels for if the player touches the winning flag. when the player touches it, the int level goes up by one. In the game loop it looks to see if the level is equal to 2. Since it is then 2 I tried drawing the images again which failed and kept them still. When I change their location, they shiver because it is in the game loop. I also tried making the if statement make the Boolean Level2 true and initializes them.

How would I make an organized level system?

Basic OO/load them from data.

Have a level class which controls the level layout which is loaded from another class or a file, when the level is complete move to a loading screen while the new level is loaded or return to a level select screen after it is complete and have it load it when the user clicks the button.

Using an int and changing it dynamically in the loop is just going to not only look shite on screen, your code will look messy.

How I would do it:
Have a class called Level. This would hold all the objects and data for that level. For example, you could store object in an ArrayList. The level would handle all updating and drawing (calling something like level.update() and level.render()). In your main class you could then have an ArrayList of Levels. When the user moves onto the next level, you could just set the current level to the next one in the list.

To switch to the level screen, would I dispose everything on the display first somehow? I understand what you mean, but I’m having problems making the textures be destroyed and re drawing them according to the level. I did a tutorial on it but they don’t explain too much.

Are you constantly clearing the screen using [icode]GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);[/icode]? This sets every pixel to the clear color (effectively clearing the screen).

It is called, yes, but can I use it if a certain key is pressed to permanently get rid of all images/textures

I’m not sure I understand your question. Are you asking if you can call this method if a key is pressed? If so, then yes. It would clear the screen whenever you hit that key.

Thanks, I don’t make much sense sometimes but you got the answer. Yes, I wanted to clear the whole screen. :wink: