Looks like you’ve got a great start! The way I would suggest going about this is not to store multiple objects of different types in one array. This generally leads to bugs when trying to access the array. I suggest you create a level class to store all the elements associated with that level. Also using an ArrayList will help you in some cases. ArrayList is a dynamic sized array so you can add and remove stuff without worrying if there’s enough space. If you want to learn more about ArrayLists check out this video. Here’s a framework for how I’d start to layout a level class:
class Level {
ArrayList<Wall> walls;
ArrayList<Key> keys;
ArrayList<Door> doors;
Level() {
walls = new ArrayList<Wall>();
keys = new ArrayList<Key>();
doors = new ArrayList<Door>();
}
display() { // I suggest using display or show as a name rather than draw
for (int i = 0; i < walls.size(); i++) { // normal for loop
walls.get(i).show(); // use .get() on ArrayLists
}
for (Key k : keys) { // for each loop, effectively the same as above but a little quicker to write once you understand how it works
k.show(); // k is equal to the current key so no need for .get()
}
// loop through doors also
}
}
// In your main program store all the levels in another ArrayList and just key a variable to say what level you're on
ArrayList<Level> levels = new ArrayList<Levels>();
int currentLevel = 1;
// You can start creating level in setup by doing by doing something like this
Level level = new Level();
level.walls.add(new Wall(some parameters));
level.keys.add(new Key(some parameters));
// so on and so forth
// then add level to levels ArrayList and repeat
levels.add(level);
// then in draw you can just say
levels.get(currentLevel).display();
Note: In the future please use control + t to format your code in processing then paste it bettween ``` ``` This will make it much easier to read and follow.