private bool CheckWallCollisions(MovableCell movable) { float dx = movable.moveDx; float dy = movable.moveDy; if (dx > 0) { float maxX = GetMaxPx(); if (movable.GetPx() > maxX) { movable.SetPosX(maxX); movable.HandleWallCollision(); return true; } } else if (dx < 0) { float minX = GetMinPx(); if (movable.GetPx() < minX) { movable.SetPosX(minX); movable.HandleWallCollision(); return true; } } if (dy > 0) { float maxY = GetMaxPy(); if (movable.GetPy() > maxY) { movable.SetPosY(maxY); movable.HandleWallCollision(); return true; } } else if (dy < 0) { float minY = GetMinPy(); if (movable.GetPy() < minY) { movable.SetPosY(minY); movable.HandleWallCollision(); return true; } } return false; }