I have a small school project, of which I am required to create a simple game (platformer). I have been messing around with this which I found:
Var
Overlay : Trect;
Begin
If not intersectrect(Overlay, player.boundsrect, shape1.boundsrect) then
//code
end;
This checks if the Player is colliding with shape1 and prevents falling past the shape. My problem is that I am creating the shapes at run time in an array. I can't check for collision against each shape, especially if there are many and could be problematic checking multiple times every timer tick.
Can I somehow do something like this:
If not intersectrect(Overlay, player.boundsrect, arrayShapes[1..20]);
or create an event that only triggers when player collides with a component, then checks if that component is a shape?
If not, is there a better way to accomplish this without checking against each shape?