Advertisement
Guest User

Untitled

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