Main forum > GLBasic - en

Not wanting pixel perfect collision

<< < (2/2)


--- Quote from: Moru on 2021-May-17 ---You could also use the array for the map data instead of the sprite/box collision. Just convert the screen coordinates of your player and compare to the map data to decide of there is a collision or not. This should also have the added benefit of being pretty fast compared to sprite collision tests.

Example of what I mean:

--- End quote ---

Ah! Never thought of that!  Checking against the object type in the array would be a really simple check as all objects of a certain type are grouped together ranges.   :booze:

On Burger Lord I check a single player coordinate against the platform array, just like MORU said.
In fact it is very similar to boxcoll but I prefer doing it by hand and in my case it is actually a "line" collision as I donĀ“t need the height of box to collide.

Here is the game I have this system running:

As already mentioned by others, I would use simple array check for map tiles as those are mostly square sized, and rect colisions for all other game objects like enemies/bullets/powerups, pixel perfect collision sound nice but as you already noticed isn't perfect for all situations :) and it's much slower if you will have dozens sprites to check. Depending on game can be using several smaller rect boxes for collision that would cover most of player sprite, let's say you have top down shooter, you can easilly use two rect for palyer aircraft, one for hull second for wings and that's it.

Just answering if anyone would search for similar topic.

alternative uses some pixels around the image. im think im used multiple boxcol collosions on my games. Only in Karma Miwa im used pixel collection by the floor by using a second imagemap.


[0] Message Index

[*] Previous page

Go to full version