Calculate the path along which the piece is moving and check to see if that place is empty (I'd suggest integer math because it gets rid of all floating math guess-work). In the case of the knight...