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 / How can i end it?

Author
Message
Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 18th Feb 2007 20:04
I have been working on a puzzle game for some time now which includes moving ober objects to destroy them and all of a specific object must be destroyed before the level can end. Now the problem is.. i have all of the functioning code working fine my only problem is... i can't seem to figure out how to make it checkif all of the required objects have been destroyed, i have tried the IF OBJECT EXIST command but that doesn't seem to work.

I can see from your smile, you're not here for the sunset.
Silvester
18
Years of Service
User Offline
Joined: 7th Dec 2005
Location: Netherlands
Posted: 18th Feb 2007 20:05
If the object is destroyed,did you delete it?

If not,the If Object Exist returns it still exists.

-Prince Of Darkness
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 18th Feb 2007 21:51
Say the objects which are destroyed are objects numbered say 100 to 150, and as Prince Of Darkness says you are definitely deleting them - not hiding them, then you could use:



TDK_Man

Silvester
18
Years of Service
User Offline
Joined: 7th Dec 2005
Location: Netherlands
Posted: 18th Feb 2007 21:57 Edited at: 18th Feb 2007 21:59


That is a very simple example of what you want.

Hehe,TDK.just wanted to make a more undertandable and easyer Example for him.

-Prince Of Darkness
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 18th Feb 2007 22:16
Quote: "just wanted to make a more undertandable and easyer Example for him."


No problem. If I've interpreted the OP correctly though, we might not be answering the same question...

As I read it, he has a game 'object' which consist of many DB primitive objects and can't get the game/level to end because his program can't detect that all the required DB primitive objects have been destroyed.

My snippet checks the range of DB primitive objects and if NumObjExisting equals 0 (zero) then they have all been destroyed. If not zero, then NumObjExisting contains the number of DB primitives left to be destroyed.

I guess we can only wait until Levanthus returns and clarifies the problem.

TDK_Man

Silvester
18
Years of Service
User Offline
Joined: 7th Dec 2005
Location: Netherlands
Posted: 18th Feb 2007 22:21
Ah,i didnt post that because you are a mod,but i didnt see your message as i left my screen the same for a while and then posted my message.

And yes,yours works different but yet,more complicated for a newcomer(As i dont get it al all,and i'm not new)

Mine checks the same as yours but in more lines.

-Prince Of Darkness
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 18th Feb 2007 23:06
Quote: "Mine checks the same as yours but in more lines."


Not quite. Your example checks to see if a single object (2) exists.

I'm under the impression that he wants to check to see if a group of objects exist - not just one object.

Quote: "more complicated for a newcomer(As i dont get it al all,and i'm not new)"


You're right, I should have explained it - sorry about that.

NumObjExisting is a counting variable and is set to 0 in case the routine is called multiple times. If we don't set it to 0 then subsequent calls to it would simply keep incrementing the value from the last time.

The For Next loop counts from the number of the first DB object in the range to the last. The example I posted assumes that the objects being tested are from 100 to 150.

Each time through the loop, the line:

Inc NumObjExisting, Object Exist(N)

...will check to see if the object being tested exists (No=0 Yes=1) and add the returned value to NumObjExisting.

At the end of the loop, if all the objects tested have been deleted, then NumObjExisting will equal zero.

If NumObjExisting is anything other than zero then it contains the number of objects left. Eg: If NumObjExisting equals 15 then there are 15 DB objects still existing in the range.

It's a bit like having a game of 3D Breakout. The blocks are all DB primitives numbered 100 to 150 and the level ends only when all the blocks have gone.

My snippet would allow you to detect that all the blocks have been deleted and the level complete.

TDK_Man

Levanthus
21
Years of Service
User Offline
Joined: 17th Apr 2003
Location: Cumbria, UK
Posted: 22nd Feb 2007 02:33 Edited at: 22nd Feb 2007 02:35
Awesomly helpful thank you so much^^ thats just what i needed... and it's so simple i can't believe i didn't think of it...lol

and if it helps... TDKs made more sense to me >.>

I can see from your smile, you're not here for the sunset.

Login to post a reply

Server time is: 2024-09-25 17:23:27
Your offset time is: 2024-09-25 17:23:27