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.

Newcomers DBPro Corner / DB Source Codes

Author
Message
FireRaven
18
Years of Service
User Offline
Joined: 24th Nov 2005
Location: Norway
Posted: 28th Nov 2005 16:09
When using DBPro, I have not yet understood how to use the source codes.

If I make several source codes, they all run at the same time.

Wouldn't it be possible to make only the current code run, and call other source codes throughout the game?

I appreciate an answer
John Y
Synergy Editor Developer
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: UK
Posted: 28th Nov 2005 16:16
Quote: "If I make several source codes, they all run at the same time."


How do you mean?

If you type



Then it does

Print "Hello"

first, and when that is finished it does

Print "World"

FireRaven
18
Years of Service
User Offline
Joined: 24th Nov 2005
Location: Norway
Posted: 28th Nov 2005 16:18
I mean like, your project may have several .dba files. They all combine into one code for me. They wont run one apart.

Like if you got two .dba files with different codes, it runs both when running the game.

How can I make it only run like one .dba file at a time and call another one on a key press for example?

I hope this can be done
John Y
Synergy Editor Developer
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: UK
Posted: 28th Nov 2005 16:21 Edited at: 28th Nov 2005 16:22
Quote: "Like if you got two .dba files with different codes, it runs both when running the game"


No, it only runs one, the other include files are for variables and functions only.

Inside your loop do

If Inkey$ = "a" Then doSomething()

Then inside one of your include files you can have something like

Function doSomething()
Print "Hello World"
EndFunction

FireRaven
18
Years of Service
User Offline
Joined: 24th Nov 2005
Location: Norway
Posted: 28th Nov 2005 16:24
But then, does that mean it calls a function from the other .dba files ? Or do you have to call the .dba with the function in it before using the doSomething() function?
super skull
20
Years of Service
User Offline
Joined: 16th Jun 2004
Location: usa
Posted: 28th Nov 2005 16:24
the point of having .dba files included with your main .dba is for functions not another program. if you want this to happen you should have another .exe


i hope this answers some of you questions

Attachments

Login to view attachments
The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 28th Nov 2005 16:26 Edited at: 28th Nov 2005 16:28
But when you have included more .dba files to a project, I though they ALL compiled when compiling the main source. In c++ it dons't compile source codes not changed, which is pretty smart, and gives a faster compile time.

Also be aware of include more .dba files in your project, there is a bug with dbpro, were it will return the wrong line if you got more .dba files included(This is that it will return the wrong line if you got errors in some of the source codes). I'm trying to keep down to only 1 source file for my projects

PanzerGameshere
Free Particle Engine For dbpro :
here
John Y
Synergy Editor Developer
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: UK
Posted: 28th Nov 2005 16:54
Quote: "But then, does that mean it calls a function from the other .dba files ? Or do you have to call the .dba with the function in it before using the doSomething() function?"


No, what actually happens is the include files just get pasted under your other source code by the editor before compilation.

So you have
1). Main source
2). Include 1
3). Include 2

and it just makes it into one file

1). Main source + Include 1 + Include 2

Therefore, don't worry about how other includes get called, you can call doSomething() from anywhere in your game

FireRaven
18
Years of Service
User Offline
Joined: 24th Nov 2005
Location: Norway
Posted: 28th Nov 2005 16:59
Okay, thanks a lot!
super skull
20
Years of Service
User Offline
Joined: 16th Jun 2004
Location: usa
Posted: 28th Nov 2005 17:24
but i think he means like two differant levels of his game one .dba for level one and one for level 2 at least thats what i got out of his post
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 28th Nov 2005 18:46
If you are talking about levels as super nerd suggest then what you do is create a part of your DB program which constructs the level from data.

When you call this code - whether it's a procedure or a function - you simply supply the data for the current level.

For a very simple example, you could have a single procedure which creates a matrix. All you do is set up the parameters before you do the Gosub. Eg:



You can call the same procedure many times to create the correct size matrix for any level by just changing the variables before using the gosub.

Obviously, you would use a lot more data for setting up a proper level in a game, such as matrix heights, textures, object positions and so on, but the principles are the same.

You can even have all of your level data in separate files on the hard disk and call the MakeLevel procedure with the name of the level data file. The procedure then simply opens up the file on disk and uses the data in it to build the level.

TDK_Man

FireRaven
18
Years of Service
User Offline
Joined: 24th Nov 2005
Location: Norway
Posted: 28th Nov 2005 19:37
I tried this command:

But it returned an error at a line that does not exist. It also just removed the code so I had to load the project all over.

What's wrong?
super skull
20
Years of Service
User Offline
Joined: 16th Jun 2004
Location: usa
Posted: 28th Nov 2005 22:11
there is nothing wrong with the command it must be in the fuction please post the code for you function and tell us what the error is
FireRaven
18
Years of Service
User Offline
Joined: 24th Nov 2005
Location: Norway
Posted: 29th Nov 2005 10:56
Nope, I fixed it so it doesn't matter

Login to post a reply

Server time is: 2024-09-24 09:34:33
Your offset time is: 2024-09-24 09:34:33