public Person() { this.startPosition = new Position() { X = 112, Y = 12 }; this.position = new Position() { X = startPosition.X, Y = startPosition.Y }; turnPoint = new Position() { X = startPosition.X, Y = startPosition.Y }; //turnPoint = startPosition; //position = startPosition; this.elsaImagePictureBox = new System.Windows.Forms.PictureBox() #region elsaImagePictureBox的初始值 { Image = global::WalkingElsa.Properties.Resources.tumblr_muexn83y6t1s0h0fgo1_500, Location = new System.Drawing.Point(startPosition.X, startPosition.Y), Margin = new System.Windows.Forms.Padding(4, 4, 4, 4), Name = "elsaImagePictureBox", Size = new System.Drawing.Size(80, 111), SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage, TabIndex = 0, TabStop = false }; #endregion elsaImagePictureBox的初始值 this.elsaTrack = new Track(); elsaTrack.points.Add(elsaImagePictureBox.Location); this.animationTimer = new Timer(); }
//public void MoveForward() //{ // Position turnPoint = new Position(); // turnPoint = position; // //Walk(turnPoint); //} public void Rectangular() { ////double distance = 0; //distance = 0; //Position turnPoint = new Position(); //turnPoint = position; //animationTimer.Enabled = true; //distance = Math.Sqrt(Math.Abs(position.X - turnPoint.X) * Math.Abs(position.X - turnPoint.X) + Math.Abs(position.Y - turnPoint.Y) * Math.Abs(position.Y - turnPoint.Y)); //if (distance > endPosition.X) // animationTimer.Enabled = !animationTimer.Enabled; //Walk(turnPoint); animationTimer.Enabled = true; turnPoint = changeDirection(180); //turnPoint = position; //Walk(turnPoint); //for (int i = 0; i < 4; i++) //{ //while (distance < endPosition.X) //{ //Walk(); ////distance = Math.Sqrt(Math.Abs(position.X - turnPoint.X) * Math.Abs(position.X - turnPoint.X) + Math.Abs(position.Y - turnPoint.Y) * Math.Abs(position.Y - turnPoint.Y)); ////}; ////if((Math.Sqrt(Math.Abs(position.X - turnPoint.X) * Math.Abs(position.X - turnPoint.X) + Math.Abs(position.Y - turnPoint.Y) * Math.Abs(position.Y - turnPoint.Y))>endPosition.X) //if (position.X > endPosition.X) // changeDirection(180); //Walk(); //} }