I am designing a side scrolling sort of game. It already has tiles that work A-OK!. However I want to have seperate environment objects that are not static and have individual functions (each of these environmnet objects is its own class).
However, In order to save memory/speed I want to make an array that stores 4 things for each item in said array, organized chronologically by when they appear. (this makes the most sense to me, considering the type of game that it is)
The three things are (bear with me):
Distance at which to create the object (how many tiles have passed since the start of the level)
the objects y coordinate
which type of object (which class) the object is.
Is this confusing?
Basically I am asking... is there a way to say like myArray[0].distance = 250; or myArray[0].type = enemyKnight;
without making them take up alot of memory or making the game slow. If so, how?
Sorry that I am very terrible at explaining things. I really need to figure out the best solution to this problem. I am extremely grateful for any and all replies. Thanks if you took time to read all this.