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 AppGameKit Corner / Sprite Collision with Large Number of Clones

Author
Message
OpusTheFowl
8
Years of Service
User Offline
Joined: 9th Feb 2016
Location:
Posted: 31st May 2016 19:56
Hello there,

I'm scratching my head on how to do something and am looking for a few pointers.

The scenario is this:
In an open world game, the character walks around. The normal walk speed is 1 but when he walks over mud then his walking speed is reduced to 0.5

The speed part isn't important but what is would be that these little splotches of mud range in the thousands and I can't be doing GetSpriteCollision checks as that's just not efficient plus I have more than just mud to deal with.

What is the method for seeing if there is a collision between a core sprite and a non-specific-high-occurring sprite?

I'm guessing groups might be the answer but the X,Y check doesn't make sense to me as I'd rather have just a normal GetSpriteCollision between (Core_Sprite,Group_Mud) groups...Is there a GetSpriteGroupCollision command that I'm missing?

Thanks in advance...I'm sure the solution is simpler than I appear to be...
BatVink
Moderator
20
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 31st May 2016 21:27
The solution is probably more complicated than you want it to be. You really need to be testing for collision only on nearby sprites. So as your character moves, you need to collate the nearby sprites, and test only for collision on those. Otherwise, it would need to be a snail that you are testing against

There is a simple 2D distance check for the nearest sprites. It is pythagoras theorem, but without the square root. i.e dist = x2 + y2. You don't need the square root, because you are only looking for nearest sprites, not actual distance.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
OpusTheFowl
8
Years of Service
User Offline
Joined: 9th Feb 2016
Location:
Posted: 31st May 2016 21:38
Thanks for the quick reply BatVink.

I understand what you are suggesting and you're right, that's a bit more involved that I thought...but not hard.

Wouldn't a good suggestion to be implemented in a future rev be a GetSpriteGroupCollision command where AppGameKit would do what you're suggesting behind the scenes and us keyboard-banger would just have to enter GetSpriteGroupCollision(group1, group2)[b]? If we're already grouping things together then wouldn't this be a next logical step?

Again though, great tip...you got me pointed in the right direction again...

Cheers....

Login to post a reply

Server time is: 2024-02-25 16:13:52
Your offset time is: 2024-02-25 16:13:52