示例#1
0
 //public void DrawMe(object sender, PaintEventArgs e)
 //{
 //    e.Graphics.DrawRectangle(Pens.Black, m_position.X, m_position.Y, 0.9f , 0.9f);
 //}
 //public Rectangle InvalidRect
 //{
 //    get
 //    {
 //        //return new Rectangle(prevpos.X, prevpos.Y, Position.X - prevpos.X + 2, Position.Y - prevpos.Y + 2);
 //        return new Rectangle(Position.X, Position.Y, 2, 2);
 //    }
 //}
 //public Boolean Step(int milisec)
 //{
 //    prevpos = Position;
 //    m_position.X += m_velocity.X * 20 / 1000.0f*speedUp;
 //    m_position.Y += m_velocity.Y * 20 / 1000.0f*speedUp;
 //    if (temp_prevpos != Position)
 //    {
 //        temp_prevpos = Position;
 //        return true;
 //    }
 //    else
 //        return false;
 //}
 public void Step(Shape.Directions direction)
 {
     switch (direction)
     {
         case Shape.Directions.Left:
             {
                 m_position.X -= m_rectangle.Width;
                 m_rectangle.X -= m_rectangle.Width;
                 break;
             }
         case Shape.Directions.Right:
             {
                 m_position.X += m_rectangle.Width;
                 m_rectangle.X += m_rectangle.Width;
                 break;
             }
         case Shape.Directions.Down:
             {
                 m_position.Y += m_rectangle.Height;
                 m_rectangle.Y += m_rectangle.Height;
                 break;
             }
         case Shape.Directions.Turn:
             {
                 m_position.Y -= m_rectangle.Height;
                 m_rectangle.Y -= m_rectangle.Height;
                 break;
             }
     }
 }
示例#2
0
 private void Form1_Load(object sender, EventArgs e)
 {
     MustChooseSerialPort();
     shape = new Shape();
 }