//checks if a particular X and Y pair is inside the obstruction, inclusive public bool isColliding(Obstruction obj) { if (originX + width + 20 < obj.originX || originX > obj.originX + obj.width + 20 || originY > obj.originY + obj.height + 20 || obj.originY > originY + height + 20) { return(false); } else { return(true); } }
private bool checkCollisions(float X, float Y, float W, float H, float startX, float startY, float endX, float endY) { Obstruction checkObs = new Obstruction(X, Y, H, W); //obviously we don't want our start and end points intersecting with any obstructions if (checkObs.isInside(startX, startY)) { return(true); } if (checkObs.isInside(endX, endY)) { return(true); } //check if we are also intersecting anything that is already established foreach (Obstruction obj in objList) { if (obj.isColliding(checkObs)) { return(true); } } return(false); }