Guest User

Untitled

a guest
Sep 25th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 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 WindowsGame6
  13. {
  14. /// <summary>
  15. /// This is the main type for your game
  16. /// </summary>
  17. public class Game1 : Microsoft.Xna.Framework.Game
  18. {
  19. GraphicsDeviceManager graphics;
  20. SpriteBatch spriteBatch;
  21. Player player;
  22. Texture2D playerTex;
  23. KeyboardState keyState;
  24. public Game1()
  25. {
  26. graphics = new GraphicsDeviceManager(this);
  27. Content.RootDirectory = "Content";
  28. }
  29.  
  30. /// <summary>
  31. /// Allows the game to perform any initialization it needs to before starting to run.
  32. /// This is where it can query for any required services and load any non-graphic
  33. /// related content. Calling base.Initialize will enumerate through any components
  34. /// and initialize them as well.
  35. /// </summary>
  36. protected override void Initialize()
  37. {
  38. // TODO: Add your initialization logic here
  39. keyState = Keyboard.GetState();
  40. base.Initialize();
  41. }
  42.  
  43. /// <summary>
  44. /// LoadContent will be called once per game and is the place to load
  45. /// all of your content.
  46. /// </summary>
  47. protected override void LoadContent()
  48. {
  49. // Create a new SpriteBatch, which can be used to draw textures.
  50. spriteBatch = new SpriteBatch(GraphicsDevice);
  51. playerTex = Content.Load<Texture2D>("Shuttle");
  52. player = new Player(new Vector2(100, 100), playerTex);
  53.  
  54.  
  55. // TODO: use this.Content to load your game content here
  56. }
  57.  
  58. /// <summary>
  59. /// UnloadContent will be called once per game and is the place to unload
  60. /// all content.
  61. /// </summary>
  62. protected override void UnloadContent()
  63. {
  64. // TODO: Unload any non ContentManager content here
  65. }
  66.  
  67. /// <summary>
  68. /// Allows the game to run logic such as updating the world,
  69. /// checking for collisions, gathering input, and playing audio.
  70. /// </summary>
  71. /// <param name="gameTime">Provides a snapshot of timing values.</param>
  72. protected override void Update(GameTime gameTime)
  73. {
  74. // Allows the game to exit
  75. if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
  76. this.Exit();
  77.  
  78. // TODO: Add your update logic here
  79. player.HandleInput(Keyboard.GetState(), KeyState);
  80. keyState = Keyboard.GetState();
  81. base.Update(gameTime);
  82. }
  83.  
  84. /// <summary>
  85. /// This is called when the game should draw itself.
  86. /// </summary>
  87. /// <param name="gameTime">Provides a snapshot of timing values.</param>
  88. protected override void Draw(GameTime gameTime)
  89. {
  90. GraphicsDevice.Clear(Color.CornflowerBlue);
  91.  
  92. // TODO: Add your drawing code here
  93.  
  94. base.Draw(gameTime);
  95. spriteBatch.Begin();
  96.  
  97. player.Draw(spriteBatch);
  98.  
  99. spriteBatch.End();
  100.  
  101.  
  102.  
  103. }
  104. }
  105. }
Add Comment
Please, Sign In to add comment