Advertisement
saluxx

monogame

Sep 24th, 2015
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.19 KB | None | 0 0
  1. using Microsoft.Xna.Framework;
  2. using Microsoft.Xna.Framework.Graphics;
  3. using Microsoft.Xna.Framework.Input;
  4.  
  5. namespace Game1
  6. {
  7. /// <summary>
  8. /// This is the main type for your game.
  9. /// </summary>
  10. public class Game1 : Game
  11. {
  12. GraphicsDeviceManager graphics;
  13. SpriteBatch spriteBatch;
  14. Texture2D texture;
  15. Vector2 position;
  16.  
  17. public Game1()
  18. {
  19. graphics = new GraphicsDeviceManager(this);
  20. Content.RootDirectory = "Content";
  21. }
  22.  
  23. /// <summary>
  24. /// Allows the game to perform any initialization it needs to before starting to run.
  25. /// This is where it can query for any required services and load any non-graphic
  26. /// related content. Calling base.Initialize will enumerate through any components
  27. /// and initialize them as well.
  28. /// </summary>
  29. protected override void Initialize()
  30. {
  31. // TODO: Add your initialization logic here
  32. position = new Vector2(0, 0);
  33. texture = new Texture2D(this.GraphicsDevice, 100, 100);
  34. Color[] colorData = new Color[100 * 100];
  35. for (int i = 0; i < 10000; i++)
  36. colorData[i] = Color.Red;
  37. texture.SetData<Color>(colorData);
  38.  
  39. base.Initialize();
  40. }
  41.  
  42. /// <summary>
  43. /// LoadContent will be called once per game and is the place to load
  44. /// all of your content.
  45. /// </summary>
  46. protected override void LoadContent()
  47. {
  48. // Create a new SpriteBatch, which can be used to draw textures.
  49. spriteBatch = new SpriteBatch(GraphicsDevice);
  50.  
  51. // TODO: use this.Content to load your game content here
  52. }
  53.  
  54. /// <summary>
  55. /// UnloadContent will be called once per game and is the place to unload
  56. /// game-specific content.
  57. /// </summary>
  58. protected override void UnloadContent()
  59. {
  60. // TODO: Unload any non ContentManager content here
  61. }
  62.  
  63. /// <summary>
  64. /// Allows the game to run logic such as updating the world,
  65. /// checking for collisions, gathering input, and playing audio.
  66. /// </summary>
  67. /// <param name="gameTime">Provides a snapshot of timing values.</param>
  68. protected override void Update(GameTime gameTime)
  69. {
  70. if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
  71. Exit();
  72.  
  73. // TODO: Add your update logic here
  74.  
  75. base.Update(gameTime);
  76. }
  77.  
  78. /// <summary>
  79. /// This is called when the game should draw itself.
  80. /// </summary>
  81. /// <param name="gameTime">Provides a snapshot of timing values.</param>
  82. protected override void Draw(GameTime gameTime)
  83. {
  84. GraphicsDevice.Clear(Color.CornflowerBlue);
  85.  
  86. // TODO: Add your drawing code here
  87.  
  88. spriteBatch.Begin();
  89. spriteBatch.Draw(texture, position);
  90. spriteBatch.End();
  91. base.Draw(gameTime);
  92. }
  93. }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement