How To

Top-down array based collision?


Jack Sbertox 2021-02-06 09:10

So... I’m back to work to make useless games. I’ve some problems with cell collision in a top-down puzzle game. Any example project?

nathanielbabiak 2021-02-06 23:02 (Edited)

nathanielbabiak 2021-02-06 23:02 (Edited)

was8bit 2021-02-07 05:55

one issue with sprite collision that i think isn't really documented is this...

When you do SPRITE HIT(0) and then use IF HIT=variable THEN do something... BUT the issue is this ... if there are MULTIPLE sprites that are in contact with the HIT(#) then only the SMALLEST #'D sprite will be returned, and any other sprite that are in contact with HIT(#) will NOT be returned with HIT(#)

If you need to know all multiple sprites that are in contact with sprite#, you need to do an individual check with each other sprite..

So, say player is sprite #0, and you want to know each of all possible sprites are touching player...


was8bit 2021-02-07 05:57 (Edited)

If i didn't get the correct issue, then i need further explanation or example of TOP DOWN ARRAY PUZZLE ...what are you trying to achieve...

was8bit 2021-02-07 05:59

One solution might be to convert cells on the background into sprites... which is what i did with Llaftip (pitfall game) ... there were SO many issues that converting everying i needed to register as contact with player from cells into sprites... it made things SO much easier :)

was8bit 2021-02-07 06:03

It is also what i will be doing with my Single Prop Fighter game... specific things on the background (planes, targets) are going to be converted to sprites in real time...

Managing sprite will be the main hurdle, as the code will have to know which sprite #s are not currently in use, asssigne sprite #'s to specific items, and when item is no longer on screen or destroyed, to return the sprite# back to being available...

Log in to reply.