You definitely helped me understand logically and syntactically how to engage with lists of level objects and how to add other objects to them. This implies to me 2 things, I can either prematurely create every wall for every level rn, so I have walls[0] through walls[50] depending on how I decide to draw the levels out, then simply add the corresponding walls to each level as they should be. This’ll allow me to have multiple level-walls which can be looped through similarly to how u showed me in ur code.
But you added that I can reuse walls, which gave me another idea. When adding a wall to a level object, I just pass parameters for where and how big the wall for the specific level will be (the parameters will go through the wall class and it’ll figure out how to “draw” the wall itself, then return the wall object as a draw-able object.
Problem is I’m overthinking all this… and confusing myself…
Then there’s the notion of the raw syntax of levels[i].walls.add(walls[10]; , which specifically adds walls[10] to the level “i”. the dots represent different increments of classes and objects.
I can assume that all we r currently focusing on rn is having multiple level objects which carry with them all the walls, keys, players, enemies, and goals that correspond with them. “drawing” these things at the level intervals will be next step. Once i can call a level and have it just draw out everything that should exist then I can work on level transitions and player and enemy movement. Once i have my level object I can loop through it "for every wall, draw it, for every key, draw it, " and so on. I may just choose to go with not reusing objects, for simplicity sake.
Can a level list contain walls and keys? can i have:
Level1[] = wall[0 - 4], key[0], player[0], enemies[0-1]; or does it not work that way.
When u wrote levels[7].keys.add(keys[2]); , It means to me that your going inside the level[7] object’s key list and adding a key to it. Ok ye by typing that I understood it more.
levels[7].keys.add(new Key(xLocation, yLocation)); is why I thought of adding walls to the level objects directly instead of prematurely making the wall objects then placing in the respective ones into the levels, but im rambling at this point.
So instead of doing this:
levels[0] = wall[0], wall[1], wall[2];
levels[1] = wall[0], wall[1];
levels[2] = wall[0], wall[1], wall[2], wall[3], wall[4];
imma do this:
wall[0] = wall(parameters);
wall[0] = wall(parameters);
wall[0] = wall(parameters);