Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Assigning objects in a level editor their own properties

Author
Message
Yodaman Jer
User Banned
Posted: 10th Oct 2010 01:41 Edited at: 10th Oct 2010 01:44
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.




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

Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 10th Oct 2010 18:58
Sounds like you want to verify an array index before you start writing to it?

Matrix Utilities 29 might have something to help you with that. I'm sure there are plenty of ways to do it, so I don't know enough to really recommend one.

And now for the n00b idea part of my post..
You could also consider something like using a Key:Value reference table (Matrix 31) to keep track of your objects as you create them, and use that as a reference to which Array indices they belong to.

At least that was the solution I used for a similar problem I was facing with my Text RPG project.. I decided to just store all rooms in a 1D array, and keep a Key:Value table to identify which Room is at which index based on a unique grid address I assign in the map building phase.

Although it sounds like you just want to make sure whatever you are writing to is blank, and not another object.. Hope I gave you some kind of idea to run with, though. Pretty sure something in Matrix Utilities should help you achieve this easily.

Yodaman Jer
User Banned
Posted: 11th Oct 2010 20:01
Thanks, Neco! I'll check out Matrix Utilities.

BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 11th Oct 2010 22:41
Take a look at this thread, you can pick it up at about 17th February and make sense of it in terms of what you want to do

http://forum.thegamecreators.com/?m=forum_view&t=141494&b=1

Yodaman Jer
User Banned
Posted: 11th Oct 2010 23:32
Thanks BatVink! There's a lot of wonderfully useful information in that thread. I'll definitely be studying it!

Login to post a reply

Server time is: 2026-07-24 23:12:36
Your offset time is: 2026-07-24 23:12:36