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 / Collision Issues

Author
Message
Satchmo
21
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 22nd Sep 2007 04:46
Hey y'all,
I have been having some collision issues in my pacman clone game.
Basically the code I am using for it is this

The reason I am doing it this way is so every level I can set the wall objects(the objects the player collides with)for every time I start a new level. The problem is, I can only get it to collide with 1 object, by setting it to

Wall_start = 2
Wall_end = 2


I need to know how to have it so I can set what objects are collided with. If anyone can look and find the problem it would be greatly appreciated, thanks!

-Fxgamer

Your about to get pwned.
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 22nd Sep 2007 06:58
i wouldn't call this a Pac-Man clone... it's 3D lol
I think what you want is

This will return the object number object1 is colliding with
with most commands, if you specify 0 DB returns a number instead of 1 or 0.

In programming, nothing exists
Satchmo
21
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 22nd Sep 2007 15:00
No, because I don't want it colliding with all objects, just some.

Your about to get pwned.
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 22nd Sep 2007 15:31
In that case, use 0 as OBese87 says, but then check the value returned with Select..Case to determine what you should do. Remember - you can always do nothing!

TDK_Man

Satchmo
21
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 22nd Sep 2007 16:48
Im not picking up exactly what your saying but I think you mean this

Normally where it said end there would be a collision code, but the collision wasn't working so I tested if it was actually picking up the touch and it rarely ever picks it up, I have to move the player through the object like 10 times before it picks that up and ends, I cant see whats really going on to cause this.

Your about to get pwned.
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 22nd Sep 2007 17:18
Not quite.

That involves lots of time intensive Collision function calls when you only need one.



(This assumes that object 1 is the main computer player).

If you need to ignore collisions between objects 4 and 5 then you don't have 'case 4' and 'case 5' lines - as in the above example.

TDK_Man

Satchmo
21
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 22nd Sep 2007 17:27 Edited at: 22nd Sep 2007 17:28
Alright, but what if I wanted to set different objects for each level without redoing that whole code each time(that's the reason I had wall_start and wall_end for my original code)?

Your about to get pwned.
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 22nd Sep 2007 17:51
Not sure what you mean.

Your walls should have the same object number range on each level. Say your walls were all objects numbered between 100 and 150:



Like the way you were doing it already, but a lot quicker as there's only one collision check.

TDK_Man

Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 22nd Sep 2007 18:55
you can also use

The code inside will be executed if the object colliding with 1 hasn't been specified earlier. (Case Default must be your last case)

In programming, nothing exists
Satchmo
21
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 22nd Sep 2007 19:01
What I mean is each level will be bigger than the last, and there will be more walls, so each level when it checks for collision it will have to check the extra walls also.

Your about to get pwned.
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 22nd Sep 2007 20:58
Obviously you can use variables in the For..Next loop like you did.

The Exit in the loop saves going through all the checks after a collision has been detected.

TDK_Man

Satchmo
21
Years of Service
User Offline
Joined: 29th May 2005
Location:
Posted: 23rd Sep 2007 01:17
How does this look?

I tried and it lets me set the wall objects to collide with, making setting up new levels easy for me. Also should I put the exit in there? Because I can set the exact amount of walls there are per level.

Oh, and just in case you wanted to know, I'm only testing with 2 walls, that's why I set the vars to 2 and 3.

Your about to get pwned.
luke810
19
Years of Service
User Offline
Joined: 4th Sep 2006
Location: United States
Posted: 23rd Sep 2007 02:32
This would be better-

TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 23rd Sep 2007 10:33
Yes, luke810's method would be better if you always know the number of walls on each level. My snippet was assuming that you didn't know that - just the number range wall objects would be in.

The Exit simply drops out of the loop when a wall collision has been detected so doesn't waste time checking any other object numbers in the loop.

TDK_Man

Login to post a reply

Server time is: 2026-07-05 16:07:28
Your offset time is: 2026-07-05 16:07:28