Hi
It's a run time error (no compiler error because the compiler can't guess that maybe the player will atempt to access out of the maze image bounds)
. Usually they are the most difficult to detect because of that, there is no message.
I had thought about this possibility before, but then I believed that the maze image borderlines would be 'wall' color so that you would lose before step outside the image bounds
To prevent this you could check, before the player scrolls to another position, if it would step outside (for example, if the maze image is 800x600, no part of the player can be at (805, 347). No part, not only the (left, top), because the collision function will be accessing the image's region that is occupied by all the player's area, and if in a call to GetPixel() X or Y are < 0 or > (800, 600) it will throw an "Out of range" Exception)
public bool CheckStepOutside(newPosX, newPosY)
{
if (newPosX < 0 || newPosY < 0 || newPosX + 20 > 800 || newPosY + 20 > 600)
return true;
return false;
}
You can get the (x, y) where the player will be on next frame, and just allow it to scroll if the function (passing x and y to it) returns false.