Wednesday, October 13, 2010

Getting Started

Well, I've managed to get somewhat motivated to start coding.

Earlier today I was beginning a "test table" for a few things I'd like to try out before I dive head-first into programming a whole game and level editor again. I realized that a feature I want to implement could very well end up not working in the future, so I'm going to test it out now. If it works, yay! If it doesn't work, I'll probably make a face like this one:

I'm so angry! Gaaah!
That image isn't mine. I Google'd it. 

The feature in question is a way to assign an object its own set of properties in my future level editor. This NEEDS to be incorporated into the editor or else my entire project won't be able to work. Basically, what I want to do is somehow, when a user clicks an object (any object), a menu will appear (courtesy of BlueGUI) and display values for various options. Basically it'll look something like this...let's see if my ASCII skills are decent....

| Transparency | 1|
------------------
| Hidden          | 0|
------------------
| Misc. Val      | 0|
------------------

The numbers are flag (or boolean) values, meaning that they only change from 0 to 1 or vice-versa. For example, if the user clicks on an object in the editor and they want the object to be transparent, they must change the 0 to 1, and in the next iteration of the main loop the object will become transparent. 

I'm doing this with the use of an array and a Type set. It looks something like this:

REM Create the Type
Type ObjectProperties
Transparent as Integer
Hidden as Integer
Misc as Integer
EndType

REM Now store the values in an array
Dim ObjectProperties(1000) as ObjectProperties

(Note: It's a right pain to manually highlight the syntax of code here! That's a shame. I need to figure out a way to post code snippets in here.)

I don't feel like going too much more in-depth about it though, although I will say that it works pretty much as it looks. You create a bunch of variables, all contained inside of a Type (which is basically BASIC's version of a class), and then you create an array to store the values in. Since my game isn't going to have more than roughly 500ish platforms in any given level (sometimes I think even that's too many), 1000 array elements should be enough. Since DarkBASIC handles objects by giving them numbers, when I create an object it also assigns the same number from the array all of the values contained in the Type element. So if I create an object at number 50, that will be the same number (50) in the array that it's assigned to, so I can give each object its own set of properties. 

What do you think? Is that how you would go about doing it? 

No comments:

Post a Comment