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 / Collison Detection which should be right

Author
Message
Yodaman Jer
User Banned
Posted: 31st Oct 2007 22:32 Edited at: 31st Oct 2007 22:33
Sorry to come here again, but this collision detection SHOULD work, but doesn't. It keeps saying RUNTIME ERROR AT LINE 16: OBJECT DOES NOT EXIST., which confuses me. (Line 16 is the "Next X" command). All I want to do is make the sphere NOT FALL THROUGH THE FLOOR AND GO UP MY HILLS IN THE LEVEL. Does it have to do with I copypasted it from different tuts? I modified the code to where it should work. Here's the code:



If someone knows how to get collision detection working, please post!!
Yodaman Jer
User Banned
Posted: 31st Oct 2007 22:36 Edited at: 31st Oct 2007 22:37
In case this helps, I figured by placing the "For X = 1 to 10" command before loading my level, and placing the "next X" command AFTER it was loaded would work.

Keep in mind, the program stops functioning at line 16, the Next X command.
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 31st Oct 2007 23:00
It's what's going on in the For next loop that is causing the problem. You have it counting up to ten and you have set object collision to boxes X but you do not have 10 objects created or loaded. So once X becomes 2, it can't find object 2 that you are setting collision for because object 2 doesn't exist.

So, you either have to get rid of the For Next loop, or you have to create or load 10 objects numbered 1 through 10 before you loop through the collision setting.

Enjoy your day.
demons breath
22
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 1st Nov 2007 01:05
yeah like Latch says, you're only creating the object once. I assume you wanted to change this:

Load Object "C:\Documents and Settings\Jeremy\Desktop\Game Media\Lev1.X",1

to this:

Load Object "C:\Documents and Settings\Jeremy\Desktop\Game Media\Lev1.X",x

TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 1st Nov 2007 01:18
In an attempt to anticipate your next question...

What you actually need is:



But you must have all ten files Lev1.X to Lev10.X present. I also recommend that you copy them into a folder called 'Levels' in the same folder as the program DBA file. This would then only need the line:

Filename$="Levels\Lev"+Str$(X)+".X"

And, you will find that Build Final would then work too!

TDK_Man

Yodaman Jer
User Banned
Posted: 1st Nov 2007 16:52 Edited at: 1st Nov 2007 16:56
ooh...new commands! Actually, Before I do all of this programming, I'm going to finish making the matrix ( which will be two separate Matrixes connected by a bridge, or a hill) and then programmatically place the individual objects, like coins, onto locations in the level, thus leaving me room for making different reactions with the objects ( coins disappear when character walks into them..I know which awesome tutorial will work for that TDK. ) I thank you for your time TDK!!
By the way, I can't get DarkEDIT to work! I downloaded it when I tried out the 30-day DB trial, it worked fine then, but now it won't run code. Weird. I even tried re-downloading it. Any suggestions?

I figured I should ask about it here.
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 1st Nov 2007 18:24
When you first run DarkEdit, you must click on Edit (on the menu bar) and select Edit Options.

Click on the DarkBASIC Options tab and make sure that the top DarkBASIC Program: box is pointing to the DB.Exe file you want to use.

I might be wrong, but there's a possibility that by default it's looking for it in the old 'Program Files\Dark Basic Software\Dark Basic' folder whereas later versions of DBC are installed in the 'Program Files\The Game Creators\Dark Basic' folder.

Just check that it is set correctly and you should find everything working again.

TDK_Man

Yodaman Jer
User Banned
Posted: 1st Nov 2007 18:31 Edited at: 1st Nov 2007 18:31
Oh!
Ok, another (hopefully FINAL)question about the For X loop...

After the Next X command, do I type the second object that I want?
Like:



Is THAT what "Next X" means?
Thanks for your help so far!!
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 1st Nov 2007 19:43 Edited at: 1st Nov 2007 19:48
@Yoda
No, the loop will do this for you
NEXT X increases X by the step value (default is 1), and loops back to the FOR statement; DB checks if X is still within the specified range and if it is, goes through the loop again.
When X exceeds it's target (11 in your case), the loop exits and continues with the rest of program.

FOR loops save you loads of time as you don't have to type the same thing over and over again; imagine if you had 100 objects!

This code will print the value of X each loop.


"You must be someone's friend to make comments about them." - MySpace lied.
Yodaman Jer
User Banned
Posted: 1st Nov 2007 22:25
Well, then, how do I add collision detection not only for the level, but the pipe in my level?
Should I make all the files .X? Lev1.x, pipe.x, coin.x, etc...

Or is there an easier collision detection technique?
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 1st Nov 2007 22:43 Edited at: 1st Nov 2007 22:47
I don't understand
are you confusing the X used as a variable in the FOR loop and the .X which is the suffix of a directX object file?
They aren't related, I probably should have used N in the FOR loop to avoid the confusion

[edit]
Oh I get you now.
The Pipe is a 3DS file... ummm you could you the 3DS2X converter in the tools folder of DB, it will convert all 3DS files on your PC to .X
Dark Basic Software\Dark Basic\tools\dbconv.exe


"You must be someone's friend to make comments about them." - MySpace lied.
Yodaman Jer
User Banned
Posted: 1st Nov 2007 23:39
Sorry, should have said "Should I change all of my 3D object files to..".
I still don't understand..I thought collision detection would be easy, but it's proving to be the most complicated thing right now.




Where exactly would I put that? I have to load all of those objects separately, otherwise nothing would work. Does this mean I simply have to add SEVERAL lines of code for collision detection? Like this:



And so on until all of my objects collide with each other?
Sorry if I'm being newbish..it's just that I can't find anything about thin the help files, and no tutorial I look at helps...in fact, I got this collision detection code from the 3D Monster Hut Tut, ubt it was being used with DB generated media, not external media like I'm trying to do.
Yodaman Jer
User Banned
Posted: 1st Nov 2007 23:41 Edited at: 1st Nov 2007 23:47
Jeeze..I just noticed something, the level I'm trying to load doesn't have it's full name...whoops...

EDIT: Even fixing the typo didn't work, and changing object numbers...WAIT!

I'm trying to make objects 1-2. But the first object is X, not 1!

What I mean is, I'm trying to make object 2 collide with an object that does not exist. I want it to collide with 1, which is X, but since it is called X and not 1, it thinks it doesn't exist, hence the error message:
Runtime error at line 16: Object does not exist!
Is this the problem?
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 2nd Nov 2007 01:18
no that's not the problem.
The variable you use in a FOR loop is the same as any other variable, and you can assign any variable a number and it will respond as that number.
Maybe you should look at TDKs tutorials, he must have one of FOR loops.

Do you understand what a FOR loop does? (sorry for being patronising )

"You must be someone's friend to make comments about them." - MySpace lied.
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 2nd Nov 2007 02:20 Edited at: 2nd Nov 2007 02:20
Quote: "he must have one of FOR loops"


He does.

Judging from the comments you are making Yodaman Jer, you are definitely trying to run before you can walk.

You might understand some of the advanced concepts you are using now, but without the elementary stuff you clearly don't understand you are going nowhere fast. It really is like building a house with no foundations - it will all fall down sooner or later.

Try reading tutorials 1 to 4 here before you go any further:

http://forum.thegamecreators.com/?m=forum_view&t=99497&b=10

Don't worry if they start off telling you things you already know, there are bound to be bits and pieces here and there that you won't which will fill in important pieces of the DB programming puzzle.

After you've read all four, you should be able to follow the one on collision and at the same time, take a quick look at the other tutorial topics for future reference.

I know they are mostly big tutorials and a pain to read, but that's because I go into a lot of detail for beginners. Tutorials that say "to do this you put this" and then give you a line of code and nothing else are not very helpful.

I prefer to say "to do this you put this and here's why..." then tell you some of the things to look out for on the way.

Read them properly until they make sense and you'll soon be asking a lot more advanced questions...

TDK_Man

Yodaman Jer
User Banned
Posted: 2nd Nov 2007 19:14
Thanks TDK. I'll look these over the next few days before trying to run.

Login to post a reply

Server time is: 2026-07-06 03:25:33
Your offset time is: 2026-07-06 03:25:33