cxong / cdogs-sdl

Classic overhead run-and-gun game
https://cxong.github.io/cdogs-sdl/
GNU General Public License v2.0
895 stars 115 forks source link

Support larger-than-tile-size object collisions #743

Closed cxong closed 2 years ago

cxong commented 2 years ago

The collision system currently checks for collisions within the same tile plus all neighbouring tiles. For objects larger than tile size, it needs to check a larger area.

For now we can go with a simple fix - extend the search area based on the object size. For example if the object is 64x64 (i.e. covers 4x6 tiles), extend the search around the current tile by 2 tiles to the left / right, and 3 tiles above / below.

This doesn't work for large object vs large object collisions, but a proper fix would be preferred, e.g. #472 , or using a space-partitioning collision system, rather than a tile based one.

cxong commented 2 years ago

megagun