//this function is called in the game-engine. We first check if the nextmove is possible (the move from userinput) if its possible we set that move, if its impossible //a gamebreaking event has been fired by the CollisionDector or we try the CurrentMove and based on that outcome we move/stop/break te game. public void ProcessMove(MovableObject sprite) { if (CollisionDetecter.ObjectCollision(PlaygroundObjects, sprite, sprite.NextMove) == Collision.Clear) { sprite.CurrentMove = sprite.NextMove; } else if (CollisionDetecter.ObjectCollision(PlaygroundObjects, sprite, sprite.CurrentMove) != Collision.Clear) { sprite.CurrentMove = sprite.NextMove = Move.Stop; } UpdatePosition(sprite); }
//determines if direction is possible private bool PossibleMove(MovableObject enemy, Move move) => CollisionDetecter.ObjectCollision(PlaygroundObjects, enemy, move) == Collision.Clear;