Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. using Microsoft.Xna.Framework;
  2. using Microsoft.Xna.Framework.Graphics;
  3. using Microsoft.Xna.Framework.Input;
  4.  
  5. namespace PacmanPrototype
  6. {
  7.  
  8. public class Game1 : Game
  9. {
  10. GraphicsDeviceManager graphics;
  11. SpriteBatch spriteBatch;
  12.  
  13.  
  14. Map map;
  15. Texture2D wand;
  16. Texture2D boden;
  17.  
  18. public Game1()
  19. {
  20. graphics = new GraphicsDeviceManager(this);
  21. Content.RootDirectory = "Content";
  22. }
  23.  
  24.  
  25. protected override void Initialize()
  26. {
  27. // TODO: Add your initialization logic here
  28.  
  29. base.Initialize();
  30. }
  31.  
  32.  
  33. protected override void LoadContent()
  34. {
  35. // Create a new SpriteBatch, which can be used to draw textures.
  36. spriteBatch = new SpriteBatch(GraphicsDevice);
  37.  
  38. // TODO: use this.Content to load your game content here
  39.  
  40. wand = Content.Load<Texture2D>("wand");
  41. boden = Content.Load<Texture2D>("boden");
  42. map = new Map(wand, boden);
  43.  
  44. graphics.PreferredBackBufferWidth = map.map.GetLength(1) * wand.Width;
  45. graphics.PreferredBackBufferHeight = map.map.GetLength(0) * wand.Height;
  46. graphics.ApplyChanges();
  47. }
  48.  
  49.  
  50. protected override void UnloadContent()
  51. {
  52. // TODO: Unload any non ContentManager content here
  53. }
  54.  
  55.  
  56. /// <param name="gameTime">Provides a snapshot of timing values.</param>
  57. protected override void Update(GameTime gameTime)
  58. {
  59. if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
  60. Exit();
  61.  
  62. // TODO: Add your update logic here
  63.  
  64. base.Update(gameTime);
  65. }
  66.  
  67.  
  68. /// <param name="gameTime">Provides a snapshot of timing values.</param>
  69. protected override void Draw(GameTime gameTime)
  70. {
  71. GraphicsDevice.Clear(Color.CornflowerBlue);
  72.  
  73. // TODO: Add your drawing code here
  74. map.Draw(spriteBatch);
  75.  
  76. base.Draw(gameTime);
  77. }
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement