Data in Dark Basic Pro


What’s going on in this image? There’s a lot actually going on. When coding a game it’s always worth thinking about using external data files to make up your game’s data, as for a start it saves on compile times and makes things more manageable. Here in Dark Basic Pro I’ve got a system where you acquire ‘spell’ and ‘class’ data from external .dat files. All that data above has been edited externally. I have 2 project files for this, the game engine (read data) and a project dedicated just to writing the above data(write data), kind of like scripting. You can find a code snippet here. 

So this means, I could make changes to things like classes without having to recompile the whole project.

You’ll also notice in that screenshot, a little menu. That menu was created from reading class data, in code it is reading ‘class number 1’, which happens to be Scholar. But lets change that to class 3 (Dark Knight).


The list changes as the player’s class is different. What about if I am using ‘null’? As you’ll see under ‘Blue Mage’ there is a null value.


The menu size changes and doesn’t read any data that is set to null.

To create that menu, you may wish to use this code (uses this code snippet):

        h = 1
    cNumber = 2
    if Player.class = class(cNumber).name

        Border_Text(1, x, y + gap*h , 0, “Attack”)
        inc h, 1
        Border_Text(1,x,y+gap*h, 0, “Ranged Attack”)
        inc h, 1
        if class(cNumber).magic1 <> “null”
            Border_Text(1,x,y+gap*h, 0, class(cNumber).magic1)
            inc h,1
        if class(cNumber).magic2 <> “null”
            Border_Text(1,x,y+gap*h, 0, class(cNumber).magic2)
            inc h,1
        if class(cNumber).skill <> “null”
            Border_Text(1,x,y+gap*h, 0, class(cNumber).skill)
            inc h, 1
        Border_Text(1,x,y+gap*h,0, “Defend”)
        inc h, 1
        Border_Text(1,x,y+gap*h, 0, “Items”)


Better you copy and paste it as WordPress won’t keep the formatting.

Variables you’ll need to define yourself:

Player.class = class(3).name  (the variable ‘player.class’, acquired the name of class number 3)

X = 30 | Y = 30 | Gap = 15



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s