This week I spent a significant amount of time developing a more efficient creation system. Below you can see the old creation system:
With this method I was “creating” the objects by having them all off screen. Then when the player clicks in the play area, the object appears on the mouse cursor as if it was being created instantaneously.
I’m not able to just create duplicates of one object because each object has to be able to hold different properties. For instance, each bed needs to be able to hold a different message variable. If I were making duplicates of one object, then each bed would always display the same message.
This method of having every bed off screen was incredibly inefficient. If I wanted to have the ability to create 10 of each object per room, then I would have to place 10 objects in each room. If I wanted to have the ability to create 99 rooms in the game, then I would need 990 different bed objects in the game. This is not only a poor use of memory, but also a waste of time in creating 990 of each object.
I needed to come up with a better way of only creating an object off screen when I needed it. I developed the system that you see below:
This new method creates new objects off screen when necessary. If I place bed 0 in the level, then bed 1 is immediately created off screen to be placed next. This method is scalable across rooms, so if I’ve used bed 0 and bed 1 in the first room, then bed 2 will be created off screen in the second room when I begin editing there. Additionally, instead of having to create 990 of each object in the game, I can simple create 99 of each object and limit the amount of objects the player can place per game to 99; (99 beds, 99 nightstands, etc.).
This week I hope to develop a system to create multiple rooms within the game. I’ll start with a basic prototype to get it working and then implement the final system later on.