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 / Level Ending

Author
Message
hpfan273
17
Years of Service
User Offline
Joined: 19th Jan 2007
Location:
Posted: 25th Jan 2007 02:54
Ok.... i am making a 3D platform type game... and i want to know what the code is to make it so that when object 1 (the player) collides with object 483 (finish box thingy)... then the game uses this code
destroy [object 1]
destroy [object 2]
etc...
gosub_level_2

... how would i do that?

THANKS FOR STOPING AT A RED LIGHT... AND LETTING ME CRASH INTO YOU AT 80 MILES AN HOUR!!!
Gil Galvanti
19
Years of Service
User Offline
Joined: 22nd Dec 2004
Location: Texas, United States
Posted: 25th Jan 2007 03:29
if object collision( 1, 483 ) = 1
`do whatever
endif

Pirates of Port Royale
Live the life of a pirate.
hpfan273
17
Years of Service
User Offline
Joined: 19th Jan 2007
Location:
Posted: 25th Jan 2007 03:32
ok..... that works..... but here is the end snippet of my code:



do you know what is wrong with this?

THANKS FOR STOPING AT A RED LIGHT... AND LETTING ME CRASH INTO YOU AT 80 MILES AN HOUR!!!
hpfan273
17
Years of Service
User Offline
Joined: 19th Jan 2007
Location:
Posted: 25th Jan 2007 03:48
ok.... thanx.... but now.... up untill the last part of the first level..... it says something is wrong with my ending thingy... here is the code:


could u tell me what is wrong with this code?

THANKS FOR STOPING AT A RED LIGHT... AND LETTING ME CRASH INTO YOU AT 80 MILES AN HOUR!!!
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 25th Jan 2007 17:13 Edited at: 25th Jan 2007 17:19
Quote: "could u tell me what is wrong with this code?"


You've done some indenting, but not enough.

One good thing about indenting your code is that 'something is wrong with my ending thingy' errors are a lot easier to spot.

Here's what you posted, but correctly indented:



You might not have posted all the code, but you've a stray return in there.

You really shouldn't intermix code between procedures or functions either. For example the following code appears to between two procedures:



Notice that the first If statement has no Endif.

Instead, list all procedures and functions at the end of your program.

In fact, looking more carefully at your code, it does have some more serious layout problems. You are Gosubing to _level2 - which is actually the next executable line! What's that all about?

On return, it will simply execute the procedure again, but have nowhere to return to.

May I suggest that you read parts 1 to 4 of my tutorials for beginners? In particular, part 2 covers the aspects of program layout which will help you avoid the problems you have run into.

(There's a link to the tutorials in the stickies at the top of this board).

I seriously suggest you use the code template from my tutorial and start your program again from scratch - before it gets any bigger and even harder to manage!

TDK_Man

Login to post a reply

Server time is: 2024-11-26 21:35:05
Your offset time is: 2024-11-26 21:35:05