コード例 #1
0
ファイル: Form1.cs プロジェクト: ProgramOwl/SnakeExpansion
        private bool AreHeadbutting()
        {
            String dir1 = Player1.GetCurrentDirection();
            String dir2 = Player2.GetCurrentDirection();
            bool   oppositeDirections = false;

            if (dir1 == "left" && dir2 == "right")
            {
                oppositeDirections = true;
            }

            if (dir1 == "right" && dir2 == "left")
            {
                oppositeDirections = true;
            }

            if (dir1 == "up" && dir2 == "down")
            {
                oppositeDirections = true;
            }

            if (dir1 == "down" && dir2 == "up")
            {
                oppositeDirections = true;
            }

            return(oppositeDirections);
        }