Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.55 KB | None | 0 0
  1. using Microsoft.Xna.Framework;
  2. using Microsoft.Xna.Framework.Graphics;
  3. using Microsoft.Xna.Framework.Input;
  4. using MonoGame.Extended.Graphics;
  5. using MonoGame.Extended.Tiled;
  6.  
  7. namespace MapTest
  8. {
  9.     public class Game1 : Game
  10.     {
  11.         GraphicsDeviceManager graphics;
  12.         SpriteBatch spriteBatch;
  13.  
  14.         private TiledMap _map;
  15.         private TiledMapRenderer _mapRenderer;
  16.  
  17.         public Game1()
  18.         {
  19.             graphics = new GraphicsDeviceManager(this);
  20.             Content.RootDirectory = "Content";
  21.         }
  22.        
  23.         protected override void Initialize()
  24.         {
  25.             base.Initialize();
  26.  
  27.             _mapRenderer = new TiledMapRenderer(GraphicsDevice);
  28.         }
  29.  
  30.         protected override void LoadContent()
  31.         {
  32.             spriteBatch = new SpriteBatch(GraphicsDevice);
  33.             _map = Content.Load<TiledMap>("mapa");
  34.         }
  35.        
  36.         protected override void UnloadContent()
  37.         {
  38.             _map.Dispose();
  39.         }
  40.  
  41.         protected override void Update(GameTime gameTime)
  42.         {
  43.             if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
  44.                 Exit();
  45.  
  46.             _mapRenderer.Update(_map, gameTime);
  47.  
  48.             base.Update(gameTime);
  49.         }
  50.        
  51.         protected override void Draw(GameTime gameTime)
  52.         {
  53.             GraphicsDevice.Clear(Color.CornflowerBlue);
  54.  
  55.             _mapRenderer.Draw(_map);
  56.  
  57.             base.Draw(gameTime);
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement