Hey everyone,
It has been a while since I've even opened up DBPro. A few months ago I was working on a level editor (I'm restarting the project soon as I lost it all in a hard drive crash), and I came up with a way to give each created object their own set of properties. However, I'm unsure of one (rather important) part working...lemme give you some pseudo code and then explain. I lost the source code months ago so I'll be doing this from memory.
`Create a Type to store object properties
Type Properties
Ghost as Integer
Hide as Integer
Switch as Integer
End Type
`Create an array to store 500 properties for each created object
Dim Properties(500) as Properties rem If I got that backwards please let me know (creating the array after setting the Type up)
REM In the main loop somewhere the user might click an option to "ghost" the currently selected object, so the code would look like this...
If userSelectsGhostOption=1
If Properties(SelObj).Ghost=0
Properties(SelObj).Ghost=1
EndIf
EndIf
That's all fine and dandy. I can even delete the selected object and reset the variables in the Type back to zero. The potential problem?
Every property value for each object is stored in an array. We all know how those work; they're a set of variables all under the same name and can either be one-dimensional or multi-dimensional. The problem I think could occur in my level editor is the following; I delete an object (say object #50), and it resets the values in Properties(49) all back to zero. I even had a chunk of code implemented to check for available object numbers, so if you had 90 objects on screen but deleted object number 50, the next time you created an object its number would be 50 instead of 100. But each time I delete an object and create a new one, how can I check to see if there's an available spot in the Properties array/type and make SURE that there's no way the values could get confused? Basically, I'm afraid that when I save a level out after making/editing one, the values could all somehow get shifted depending on how many objects I deleted and gave certain properties. Is there a way to prevent that, or I'm worrying over nothing?
I can't really think how to put it in better words, but if you need me to I'll certainly try.
Thanks!
-CoffeeCoder