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 Discussion / Tricky Question [DBC]

Author
Message
dlefik 2008
20
Years of Service
User Offline
Joined: 28th Apr 2005
Location: Spencerville, OH
Posted: 28th Apr 2005 17:08
Let's say I have a matrix, and I randomly generate 10 cube objects and lay these cubes out in random spots on the matrix. How would one be able to determine the object "number" for each randomly generated cube ? To take it a step further, could I label each randomly generated cube with it's own name? Is this even possible? Hope someone can help with this one because I'm stumped Hope I made sense in this question.
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 28th Apr 2005 20:20
Clickable SMiley,

When are you needing to determine the object number? When collision happens? Or, are you needing the program to create a random object at a random moment, and you need to know what object number to place within the make object command?

If the question is the last, then there is two methods to figure the object number, the first being the most efficient. First, you could create a variable and assign it the last known object number plus one. Then, as random objects are created, the variable should be incremented.

The other method is to simply do a repeat until loop to search for existing object numbers. When the loop finds that the next number is not an existing object, then code is ran.




+NanoBrain+
ShadowCentaur 2
20
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Free Country USA
Posted: 29th Apr 2005 10:39
well, to name an object, you could create an array like
objectname$(object) and assign a string name to it that way. for example: dim objectname$(10)
objectname$(10)="eduardo"
hope i helped

Truth suffers from too much analysis.
-Ancient Fremen Saying
dlefik 2008
20
Years of Service
User Offline
Joined: 28th Apr 2005
Location: Spencerville, OH
Posted: 29th Apr 2005 15:22
Well it's more like this. Say I have the matrix, I generate 10 different cubes using a command such as:

for cube=1 to 10
make object cube cube,30
next cube

and then I randomly place these 10 cubes throughout the matrix. Now, I have a sphere that I can move over the matrix, kinda like an indicator showing where on the matrix I'm pointing at. Now remember these are 10 randomly placed cubes, but as I move the sphere/marker over the matrix and it comes in contact with any of the 10 randomly placed cubes, I'd want it to display a text message for example saying, "Currently there is collision between object 11" which 11 represents the object number of the sphere I'm using to indicate where I'm at "and object x" where X represents any one of the randomly placed cubes I have created. Hope this makes sense once again.
ShadowCentaur 2
20
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Free Country USA
Posted: 30th Apr 2005 05:45
oooohhhh!!!!! thats so simple now that youve explained yourself
simply put this in

print object collision(sphereid#,0)

so, that way it prints the number of object your colliding with. it explains how to use the object collision command like that in the built in help

Truth suffers from too much analysis.
-Ancient Fremen Saying
dlefik 2008
20
Years of Service
User Offline
Joined: 28th Apr 2005
Location: Spencerville, OH
Posted: 30th Apr 2005 15:29
@ShadowCentaur 2

Sweet! That was soo simple I never even thought of using that method. And it definitely gives me something that I can build on even more. Thank you soo much for your help!

Login to post a reply

Server time is: 2025-05-22 23:44:51
Your offset time is: 2025-05-22 23:44:51