コード例 #1
0
        public SnakeForm()
        {
            InitializeComponent();

            Frame = new Frame();

            GameTimer          = new Timer(1000.0 / FramesPerSecond);
            GameTimer.Elapsed += GameTimer_Elapsed;

            Direction         = Direction.Left;
            PreviousDirection = Direction.None;

            FoodPiece   = new FoodPiece(Frame);
            SnakePieces = new List <SnakePiece>
            {
                new SnakePiece(Frame, Color.White, FoodPiece.Random.Next(0, MatrixPanel.Width), FoodPiece.Random.Next(0, MatrixPanel.Height))
            };
        }
コード例 #2
0
 public double DistanceFrom(FoodPiece piece)
 {
     return(Math.Sqrt(Math.Pow(piece.X - X, 2) + Math.Pow(piece.Y - Y, 2)));
 }