|
|
@ -2,13 +2,16 @@ |
|
|
|
using Microsoft.Xna.Framework.Graphics; |
|
|
|
using Microsoft.Xna.Framework.Input; |
|
|
|
|
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
|
|
|
|
namespace Jumpy { |
|
|
|
public class JumpyGame : Game { |
|
|
|
GraphicsDeviceManager graphics; |
|
|
|
RenderTarget2D renderTarget; |
|
|
|
|
|
|
|
const int numRenderTargets = 1; |
|
|
|
RenderTarget2D[] renderTargets = new RenderTarget2D[numRenderTargets]; |
|
|
|
int renderTargetIdx = 0; |
|
|
|
|
|
|
|
SpriteBatch spriteBatch; |
|
|
|
SpriteFont font; |
|
|
|
KeyboardInput keyboardInput = new KeyboardInput(); |
|
|
@ -29,10 +32,12 @@ namespace Jumpy { |
|
|
|
display = (IDisplay) Services.GetService(typeof(IDisplay)); |
|
|
|
display.Initialize(Window, graphics); |
|
|
|
display.SetFullScreen(fullScreen); |
|
|
|
|
|
|
|
renderTarget = new RenderTarget2D( |
|
|
|
GraphicsDevice, Camera.Width, Camera.Height, false /* mipmap */, |
|
|
|
GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24); |
|
|
|
|
|
|
|
for (int i = 0; i < renderTargets.Length; i++) { |
|
|
|
renderTargets[i] = new RenderTarget2D( |
|
|
|
GraphicsDevice, Camera.Width, Camera.Height, false /* mipmap */, |
|
|
|
GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24); |
|
|
|
} |
|
|
|
|
|
|
|
base.Initialize(); |
|
|
|
} |
|
|
@ -77,8 +82,9 @@ namespace Jumpy { |
|
|
|
fpsCounter.Update(); |
|
|
|
|
|
|
|
// Draw scene to RenderTarget.
|
|
|
|
RenderTarget2D renderTarget = renderTargets[renderTargetIdx]; |
|
|
|
renderTargetIdx = (renderTargetIdx + 1) % renderTargets.Length; |
|
|
|
GraphicsDevice.SetRenderTarget(renderTarget); |
|
|
|
// GraphicsDevice.DepthStencilState = new DepthStencilState() { DepthBufferEnable = true };
|
|
|
|
GraphicsDevice.Clear(Color.CornflowerBlue); |
|
|
|
spriteBatch.Begin(); |
|
|
|
player.Draw(gameTime, spriteBatch); |
|
|
|