How To

Top-down array based collision?

2

BlockHead 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)

https://lowresnx.inutilis.com/topic.php?id=1636


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

https://lowresnx.inutilis.com/topic.php?id=1572


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...

IF SPRITE HIT(0,1) THEN
IF SPRITE HIT(0,2) THEN
etc...





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.