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 / help with object management, please

Author
Message
Dracula
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: DBP Recreation of Castle Csejthe
Posted: 2nd Jan 2007 03:24 Edited at: 3rd Jan 2007 01:56
Ok, so what I was really asking is can I do this:



Since I know I can't do this (yes, I tried it), can anyone tell me if there is a way to do something similar?

Thanks for the help!!!

D
GMan
18
Years of Service
User Offline
Joined: 16th Sep 2006
Location: TEXAS
Posted: 3rd Jan 2007 02:10
Yes you can do EXACTLY that.

That should work providing that file.x is the correct name of the file you are loading and that file.x is in the SAME folder as your executable.

If not in the same folder than include the path:
a$=C:\Program Files\Dark Basic Software\Dark Basic Professional\PROJECT\file.x

The right man in the wrong place can make all the difference in the world.
Dracula
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: DBP Recreation of Castle Csejthe
Posted: 3rd Jan 2007 03:31
Thanks G-Man,

I screwed up and forgot to make the string var global for the function.

This just gets better...
dononeton
20
Years of Service
User Offline
Joined: 12th Jun 2004
Location: Tusaloosa, AL : USA
Posted: 3rd Jan 2007 04:54 Edited at: 3rd Jan 2007 04:57
The code below will see if an object number exist in your game. If it is true then it will go to the next line which will increase the variable obj by one and loop again until one does not exist and return that number back to where you called that function


Now you can say


Now for something like bullets you can reserve let say object numbers 100 - 150 so you can reuse those numbers
Code Dragon
18
Years of Service
User Offline
Joined: 21st Aug 2006
Location: Everywhere
Posted: 3rd Jan 2007 19:06 Edited at: 3rd Jan 2007 19:07
Quote: "
Now you can say


"


I would like to note that it's ineffiecent to reload an object like a bullet every time you want to make another one. Instead, load one "dummy" object (and hide/exclude it), and use instance object to make copies of it very fast.

"Did I ever tell you how I got the nickname the Dragon of the West?"
"I'm not interested in a lengthy anecdote, Uncle."
"It's more of a demonstration really."
dononeton
20
Years of Service
User Offline
Joined: 12th Jun 2004
Location: Tusaloosa, AL : USA
Posted: 4th Jan 2007 04:55
@ Code Dragon

So you write
Code Dragon
18
Years of Service
User Offline
Joined: 21st Aug 2006
Location: Everywhere
Posted: 4th Jan 2007 22:34
Well, not really. I'd use a different number for each bullet, because you'd want more than one at a time, right? I would do something more like this:



But that's just the way I code. I would create an array which holds the bullet object numbers, so you can use a loop for bullet moving, and move the value in the current array index. When a new bullet is instanced my custom instance_obj() function finds a free object number, uses it to instance a bullet and return the id number it used into the array. I use gateway functions because I when I create objects I don't want to use numbers when making them, I let the program think of the numbers automatically and I use a variable instead.

"Did I ever tell you how I got the nickname the Dragon of the West?"
"I'm not interested in a lengthy anecdote, Uncle."
"It's more of a demonstration really."

Login to post a reply

Server time is: 2024-09-25 15:20:05
Your offset time is: 2024-09-25 15:20:05