|
@ -2,6 +2,7 @@ |
|
|
using Microsoft.Xna.Framework.Graphics; |
|
|
using Microsoft.Xna.Framework.Graphics; |
|
|
using Microsoft.Xna.Framework.Input; |
|
|
using Microsoft.Xna.Framework.Input; |
|
|
|
|
|
|
|
|
|
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
|
|
|
|
|
|
namespace Jumpy { |
|
|
namespace Jumpy { |
|
@ -14,6 +15,7 @@ namespace Jumpy { |
|
|
bool fullScreen = false; |
|
|
bool fullScreen = false; |
|
|
IDisplay display; |
|
|
IDisplay display; |
|
|
|
|
|
|
|
|
|
|
|
FpsCounter fpsCounter = new FpsCounter(); |
|
|
Player player; |
|
|
Player player; |
|
|
|
|
|
|
|
|
public JumpyGame() { |
|
|
public JumpyGame() { |
|
@ -70,6 +72,10 @@ namespace Jumpy { |
|
|
|
|
|
|
|
|
// Called when the game should draw itself.
|
|
|
// Called when the game should draw itself.
|
|
|
protected override void Draw(GameTime gameTime) { |
|
|
protected override void Draw(GameTime gameTime) { |
|
|
|
|
|
// We need to update the FPS counter in Draw() since Update() might get called more
|
|
|
|
|
|
// frequently, especially when gameTime.IsRunningSlowly.
|
|
|
|
|
|
fpsCounter.Update(); |
|
|
|
|
|
|
|
|
// Draw scene to RenderTarget.
|
|
|
// Draw scene to RenderTarget.
|
|
|
GraphicsDevice.SetRenderTarget(renderTarget); |
|
|
GraphicsDevice.SetRenderTarget(renderTarget); |
|
|
// GraphicsDevice.DepthStencilState = new DepthStencilState() { DepthBufferEnable = true };
|
|
|
// GraphicsDevice.DepthStencilState = new DepthStencilState() { DepthBufferEnable = true };
|
|
@ -87,7 +93,8 @@ namespace Jumpy { |
|
|
Rectangle drawRect = new Rectangle( |
|
|
Rectangle drawRect = new Rectangle( |
|
|
0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height); |
|
|
0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height); |
|
|
spriteBatch.Draw(renderTarget, drawRect, Color.White); |
|
|
spriteBatch.Draw(renderTarget, drawRect, Color.White); |
|
|
spriteBatch.DrawString(font, "FPS: 60", new Vector2(10, 10), Color.White); |
|
|
|
|
|
|
|
|
string fpsText = $"FPS: {fpsCounter.Fps:F1}"; |
|
|
|
|
|
spriteBatch.DrawString(font, fpsText, new Vector2(10, 10), Color.White); |
|
|
spriteBatch.End(); |
|
|
spriteBatch.End(); |
|
|
|
|
|
|
|
|
base.Draw(gameTime); |
|
|
base.Draw(gameTime); |
|
|