Пример #1
0
        protected override void Update(GameTime gameTime)
        {
            KeyMouseReader.Update();
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            car.Update(gameTime);
            if (KeyMouseReader.KeyPressed(Keys.Left))
            {
                car.Start(new Point(55, 10), speedbox.GetValue(), gameTime, curvePath.GetInnerRadius(), 0.75f);
            }
            else if (KeyMouseReader.KeyPressed(Keys.Right))
            {
                car.Start(new Point(55, 10), speedbox.GetValue(), gameTime, curvePath.GetOuterRadius(), 2f);
            }
            speedbox.Update();
            base.Update(gameTime);
        }
Пример #2
0
 public void Update()
 {
     if (KeyMouseReader.LeftClick())
     {
         if (rectangle.Contains(KeyMouseReader.mouseState.Position))
         {
             value     = "";
             selected  = true;
             fontColor = Color.Yellow;
         }
         else
         {
             if (value == "")
             {
                 value = "0";
             }
             selected  = false;
             fontColor = Color.White;
         }
     }
     if (selected)
     {
         try
         {
             Keys[] key = KeyMouseReader.KeyPressed();
             if (KeyMouseReader.KeyPressed(Keys.Back))
             {
                 try
                 {
                     value     = value.Remove(value.Length - 1);
                     rectangle = new Rectangle((int)position.X, (int)position.Y, (int)font.MeasureString(name + ": " + value).X, (int)font.MeasureString(name + ": " + value).Y);
                 }
                 catch (Exception e)
                 {
                 }
             }
             else if (KeyMouseReader.KeyPressed().Length > 0)
             {
                 foreach (Keys k in key)
                 {
                     if (KeyMouseReader.KeyPressed(k))
                     {
                         if (k == Keys.D0 || k == Keys.NumPad0)
                         {
                             value += "0";
                         }
                         if (k == Keys.D1 || k == Keys.NumPad1)
                         {
                             value += "1";
                         }
                         if (k == Keys.D2 || k == Keys.NumPad2)
                         {
                             value += "2";
                         }
                         if (k == Keys.D3 || k == Keys.NumPad3)
                         {
                             value += "3";
                         }
                         if (k == Keys.D4 || k == Keys.NumPad4)
                         {
                             value += "4";
                         }
                         if (k == Keys.D5 || k == Keys.NumPad5)
                         {
                             value += "5";
                         }
                         if (k == Keys.D6 || k == Keys.NumPad6)
                         {
                             value += "6";
                         }
                         if (k == Keys.D7 || k == Keys.NumPad7)
                         {
                             value += "7";
                         }
                         if (k == Keys.D8 || k == Keys.NumPad8)
                         {
                             value += "8";
                         }
                         if (k == Keys.D9 || k == Keys.NumPad9)
                         {
                             value += "9";
                         }
                         if (k == Keys.OemComma)
                         {
                             value += ",";
                         }
                         if (k == Keys.OemPeriod)
                         {
                             value += ".";
                         }
                         rectangle = new Rectangle((int)position.X, (int)position.Y, (int)font.MeasureString(name + ": " + value).X, (int)font.MeasureString(name + ": " + value).Y);
                     }
                 }
             }
         }
         catch (Exception e)
         {
         }
     }
 }