Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Graphics;
- using Microsoft.Xna.Framework.Input;
- using Retro2D;
- namespace StarterGame
- {
- public class Game1 : Game
- {
- Window _window = new Window();
- FrameCounter _frameCounter = new FrameCounter();
- MouseState _mouseState;
- int _relMouseX;
- int _relMouseY;
- int _screenW = 960;
- int _screenH = 540;
- public int _finalScreenW = 960;
- public int _finalScreenH = 540;
- public Game1()
- {
- _window.Setup(this, Mode.RETRO, "StarterGame", _screenW, _screenH, 2, 0, false, true, false);
- Content.RootDirectory = "Content";
- }
- protected override void Initialize()
- {
- _window.Init();
- _window.SetScale(2);
- _window.SetFinalScreenSize(_finalScreenW, _finalScreenH);
- base.Initialize();
- }
- protected override void LoadContent()
- {
- }
- protected override void UnloadContent()
- {
- }
- protected override void Update(GameTime gameTime)
- {
- _window.GetMouse(ref _relMouseX, ref _relMouseY, ref _mouseState);
- if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
- Exit();
- _window.UpdateStdWindowControl();
- _frameCounter.Update(gameTime);
- Window.Title = "FPS :" + _frameCounter.Fps();
- base.Update(gameTime);
- }
- protected override void Draw(GameTime gameTime)
- {
- // Set Target to MainRenderTarget !
- _window.SetRenderTarget(_window.NativeRenderTarget);
- _window.Batch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp); //, DepthStencilState.None, RasterizerState.CullCounterClockwise );
- // Draw something here !
- _window.Batch.GraphicsDevice.Clear(new Color(20, 40, 60));
- Retro2D.Draw.Grid(_window.Batch, 0, 0, _screenW, _screenH, 16, 16, Color.Gray * .4f);
- Retro2D.Draw.Sight(_window.Batch, _relMouseX, _relMouseY, _screenW, _screenH, Color.RoyalBlue, 1);
- _window.Batch.End();
- // Render MainTarget in FinalTarget
- _window.SetRenderTarget(_window.FinalRenderTarget);
- _window.Batch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.AnisotropicClamp);
- _window.RenderMainTarget(Color.White);
- _window.Batch.End();
- // Flip to FinalRenderTarget !
- _window.SetRenderTarget(null);
- _window.Batch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.AnisotropicClamp);
- _window.RenderFinalTarget(Color.White);
- _window.Batch.End();
- base.Draw(gameTime);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement