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 / Certain Object Collision

Author
Message
TheMuslimMamba
12
Years of Service
User Offline
Joined: 16th Jan 2014
Location:
Posted: 3rd Feb 2014 19:25
I am having a problem with the collision in my game. I have the collision working for my buildings just fine, but I wanted to add drops that you can pick up. These would be shperes with the same random generation code as the buildiings. They also have the collision set to polygons. (I normally use collision boxes but Chafari used polygons as he was helping us with the collision on our buildings). The building collision works fine but I want it so that when you collide with the spheres it dissapears and it increases my boost number by 20.

Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 4th Feb 2014 14:08
Wouldn't the OBJECT COLLISION command be able to tell you if you've hit a sphere?

ShellfishGames
13
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 4th Feb 2014 15:53
I don't think you need polygon collision for pickups. They are usually quite small and collision detection doesn't need to be that accurate, hence usual bounding box collision should suit your needs here, and it's most certainly much faster.

Also, you could go a little more into detail regarding your problem. How does the program behave right now, why doesn't it work? Do the spheres interfere with the player's sliding collision? Don't they collide at all?

-Nevermind, I just tested it without the required sounds and music. So the spheres collide with the player. Possibly the simplest way to deal with that is to put your pickup code before the sliding collision part in your main loop.

1. Get new Position of Player ('x# = object position x(1)' etc. in line ~181-183)
2. Check for collision with a pickup ('col = object collision(1,0)', 'if col >= myFirstPickupObjectID and col <= myLastPickupObjectID then delete object col : inc BOOST#, 20' (the first and last object IDs being 16 and 30 if I am not mistaken))
3. Sliding Collision as it is so far

And I think that's it.

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 4th Feb 2014 16:15
ShellfishGames is right . We don't need polygons collision to pick spheres, just check if you collision with them and then just take them away from view.

Example:


I'm not a grumpy grandpa

Login to post a reply

Server time is: 2026-07-06 07:51:31
Your offset time is: 2026-07-06 07:51:31