When you use discrete tiles and a game object is always exactly on one tile in the center, you can just check collisions on tiles.
If you use tiles to build your map, but free positions for objects, so that a object can be on the border of a tile and might cover multiple tiles, you need something else.
Collision in space is usually either rectangular collision test or circular collision test first. For a bounding rectangle you use the minx, miny and maxx, maxy coordinates of each object and check if two objects overlap. For a bounding circle you need a center coordinate and a radius for each object. The distance between two objects centers must be greater than the sum of their radi. Use pythagoras. Do not us sqare root, better use the square of the radi
mindistance = radius1 + radius2
xdistance = (x1 - x2) * (x1 - x2)
ydistance = (y1 - y2) * (y1 - y2)
if( (xdistance + ydistance) < (mindistance * mindistance) )
{
collision
} else
{
no collision
}
this is based on Pythagoras a^2 + b^2 = c^2
It is cheaper to use c^2 than to calculate the square root of (a^2 + b^2)
If you have a one screen game and few objects, you can just check each object against each other.
On greater areas, you would divide the area into sectors. You can either use tiles, or groups of 5x5 tiles for example as “sector” und you check all objects of a sector against all other objects in the same sector and against the neighbour sectors.
If you make a vertical or horizontal scroller, you can sort objects by x or y coordinate and check an object against all other objects up to 100 pixels away or such. Depends on your greatest object.
Modern games use trees for this. Quadtrees or Octrees, which iteratively divide the whole map in equal parts.
-JAW