protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } KeyboardState nowKeyboardState = Keyboard.GetState(); if (nowKeyboardState.IsKeyDown(Keys.W)) { rect1.Y -= speed; } if (nowKeyboardState.IsKeyDown(Keys.S)) { rect1.Y += speed; } if (nowKeyboardState.IsKeyDown(Keys.A)) { rect1.X -= speed; } if (nowKeyboardState.IsKeyDown(Keys.D)) { rect1.X += speed; } if (nowKeyboardState.IsKeyDown(Keys.R)) { rect1.Rotation += rotationSpeed; } result = "Real Origin: " + rect1.RealOrigin.ToString() + "\nPosition: " + rect1.Position + "\nCenter: " + rect1.Center; if (rect1.IsCollision(rect2, out mtv)) { rect1.RectColor = Color.LightPink; rect1.X += mtv.X; rect1.Y += mtv.Y; } else { rect1.RectColor = Color.Red; } if (nowKeyboardState.IsKeyDown(Keys.Up)) { rect2.Y -= speed; } if (nowKeyboardState.IsKeyDown(Keys.Down)) { rect2.Y += speed; } if (nowKeyboardState.IsKeyDown(Keys.Left)) { rect2.X -= speed; } if (nowKeyboardState.IsKeyDown(Keys.Right)) { rect2.X += speed; } if (nowKeyboardState.IsKeyDown(Keys.T)) { rect2.Rotation += rotationSpeed; } if (rect2.IsCollision(rect1, out mtv)) { rect2.RectColor = Color.LightGreen; rect2.X += mtv.X; rect2.Y += mtv.Y; } else { rect2.RectColor = Color.Green; } lastKeyboardState = nowKeyboardState; base.Update(gameTime); }