I’m having a bit of a problem with my collision, after finally figuring out how to actually make it collide i could only make the pacman reset into a set position and have no idea how to make him stay where he’s supposed to.
player.update();
for (int y = 0; y < NrOfTilesY; y++)
{
for (int x = 0; x < NrOfTilesX; x++)
{
if (tileArray[x, y] is Nest)
{
Rectangle rectW = tileArray[x, y].Bounds();
Rectangle rectP = Player.pacmanBounds;
if(rectW.Intersects(rectP))
{
Player.pacmanBounds.X = 32;
Player.pacmanBounds.Y = 32;
}
}
}
}
Before you move the player, copy its position.
If it collides after you moved it, re-placed it to the last position.
Also, I think it would be worthy to note that you don’t need to test every tiles of your board, but only the tiles around the player. The position of the player should give you on which tile it is, and should be fairly easy to find the tiles adjacent to that tile.