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 Professional Discussion / need help with collision

Author
Message
Shady Simpson
23
Years of Service
User Offline
Joined: 15th Mar 2003
Location: United Kingdom
Posted: 22nd Jul 2003 18:05
hi,

I'm having problems with object collision in my game (it's obviously a pac-man game). Can someone have a look at my source code and tell me how I can make the sphere stop when it hits a box object, like pacman.

I'm sure that this is really simple but I can't figure it out.

thanx.
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 22nd Jul 2003 20:35
I think for this, you don't even need to use the collision function in DBpro. For me, I will just check your map data, in this case is a 2-D grid, and do the following when moving:

1. Get the current map coordinate of your character in the 2-D grid map.
2. Update the screen coordinate of your character.
3. Get the corresponding map coordinate of the new screen coordinate.
4. If the new map coordinate contains an obstacle, i.e. cannot move into that location, rollback to the previous coordinate as in step #1.

I guess it is faster than using the DB Collision functions in this case.

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
Shady Simpson
23
Years of Service
User Offline
Joined: 15th Mar 2003
Location: United Kingdom
Posted: 23rd Jul 2003 00:15
could you please post an example of what you mean?

I'll see if I can crack it while i'm waiting for any replies.

Thanx.

Nilrem
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 23rd Jul 2003 02:31
Try this, edit to your liking, the bulk of it (the collision part) is courtesy of Ian.



I hear and I forget. I see and I remember. I do and I understand.
Shady Simpson
23
Years of Service
User Offline
Joined: 15th Mar 2003
Location: United Kingdom
Posted: 23rd Jul 2003 18:52
Have you ran the code?

I mean 3D Collision, not sprites. How would I make object collision like Pac-Man but in 3d?

Thanx.

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Jul 2003 23:13 Edited at: 23rd Jul 2003 23:14
Try this code.

Sorry, but I couldn't resist changing the way some of it works and generally cleaning it up a bit

Oh, and I didn't use 3D collision - that seems like overkill for a grid-based game
Shady Simpson
23
Years of Service
User Offline
Joined: 15th Mar 2003
Location: United Kingdom
Posted: 25th Jul 2003 17:47
Thanx Ian it worked great!, now it's just a matter of trying to understand it.

thanx.

Login to post a reply

Server time is: 2026-07-23 07:32:56
Your offset time is: 2026-07-23 07:32:56