TilemapGame.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using Microsoft.Xna.Framework;
  3. using Microsoft.Xna.Framework.Graphics;
  4. using Microsoft.Xna.Framework.Input;
  5. namespace Samples.Tilemaps
  6. {
  7. public class TilemapGame : Game
  8. {
  9. GraphicsDeviceManager graphics;
  10. TilemapSampleComponent _tilemapSampleComponent;
  11. public TilemapGame()
  12. {
  13. graphics = new GraphicsDeviceManager(this);
  14. Content.RootDirectory = "Content";
  15. graphics.PreferredBackBufferWidth = 800;
  16. graphics.PreferredBackBufferHeight = 480;
  17. _tilemapSampleComponent = new TilemapSampleComponent(this, graphics);
  18. Components.Add(_tilemapSampleComponent);
  19. }
  20. protected override void LoadContent()
  21. {
  22. }
  23. /// <param name="gameTime">Provides a snapshot of timing values.</param>
  24. protected override void Update(GameTime gameTime)
  25. {
  26. KeyboardState keyState = Keyboard.GetState();
  27. GamePadState gamePadState = GamePad.GetState(PlayerIndex.One);
  28. if (keyState.IsKeyDown(Keys.Escape) || gamePadState.Buttons.Back == ButtonState.Pressed)
  29. Exit();
  30. base.Update(gameTime);
  31. }
  32. protected override void Draw(GameTime gameTime)
  33. {
  34. GraphicsDevice.SetRenderTarget(null);
  35. GraphicsDevice.Clear(Color.Black);
  36. base.Draw(gameTime);
  37. }
  38. }
  39. }