Game1.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.Xna.Framework;
  4. using Microsoft.Xna.Framework.Audio;
  5. using Microsoft.Xna.Framework.Content;
  6. using Microsoft.Xna.Framework.Graphics;
  7. using Microsoft.Xna.Framework.Input;
  8. using Microsoft.Xna.Framework.Media;
  9. namespace MonoTest
  10. {
  11. public class Game1 : Microsoft.Xna.Framework.Game
  12. {
  13. static GraphicsDeviceManager graphics;
  14. SpriteBatch spriteBatch;
  15. public static Texture2D BlankTexture;
  16. public static SpriteFont FontCalibri14;
  17. public Game1()
  18. {
  19. graphics = new GraphicsDeviceManager(this);
  20. Content.RootDirectory = "Content";
  21. graphics.PreferredBackBufferWidth = 640;;
  22. graphics.PreferredBackBufferHeight = 480;
  23. graphics.IsFullScreen = false;
  24. }
  25. protected override void Initialize()
  26. {
  27. base.Initialize();
  28. }
  29. /// <summary>
  30. /// LoadContent will be called once per game and is the place to load
  31. /// all of your content.
  32. /// </summary>
  33. protected override void LoadContent()
  34. {
  35. spriteBatch = new SpriteBatch(GraphicsDevice);
  36. FontCalibri14 = Content.Load<SpriteFont>("FontCalibri14");
  37. BlankTexture = Content.Load<Texture2D>("Blank");
  38. // BlankTexture = new Texture2D(GraphicsDevice,1,1);
  39. // BlankTexture.SetData(new Color[] {Color.White});
  40. }
  41. protected override void Update(GameTime gameTime)
  42. {
  43. base.Update(gameTime);
  44. }
  45. protected override void Draw(GameTime gameTime)
  46. {
  47. GraphicsDevice.Clear(Color.Black);
  48. base.Draw(gameTime);
  49. spriteBatch.Begin();
  50. spriteBatch.Draw(BlankTexture,
  51. new Vector2(100,100),
  52. null,
  53. Color.Green,
  54. 0,
  55. Vector2.Zero,
  56. new Vector2(400,240),
  57. SpriteEffects.None,
  58. 0);
  59. spriteBatch.DrawString(FontCalibri14, "There should be no\n transparency near the corners...\n\nThis box should be solid green.", new Vector2(150,150), Color.Silver, 0, Vector2.Zero, 1, SpriteEffects.None, 1);
  60. spriteBatch.End();
  61. }
  62. }
  63. }