/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { this.Exit(); } if (Keyboard.GetState().IsKeyDown(Keys.Enter)) { subCounter = text.Length; } float elapsedTime = (float)gameTime.ElapsedRealTime.TotalSeconds; totalTime += elapsedTime; wordTime += elapsedTime; if (totalTime >= 1) { displayFps = fps; fps = 0; totalTime = 0; counter++; missRate = renderer.MissRate; renderer.ResetCacheCounter(); } if (wordTime >= wordInterval) { if (subCounter < text.Length) { subCounter++; if (subCounter - pageHead > maxWords) { pageHead += maxWords; } } subText = text.Substring(pageHead, subCounter - pageHead); wordTime = 0; } for (int i = 0; i < fontNum; i++) { renderer.PrepareBuffer(subText, fonts[i]); } Window.Title = string.Format("{0} FPS, {1} sec, {2} words, miss rate {3:P}", displayFps, counter, renderer.BufferCount, missRate); base.Update(gameTime); }