Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 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 WindowsGame1
  13. {
  14. public class Game1 : Microsoft.Xna.Framework.Game
  15. {
  16. GraphicsDeviceManager graphics;
  17. SpriteBatch spriteBatch;
  18. KeyboardState oldstate;
  19. Texture2D whatever;
  20. Vector2 whatpos = Vector2.Zero;
  21.  
  22. public Game1()
  23. {
  24. graphics = new GraphicsDeviceManager(this);
  25. Content.RootDirectory = "Content";
  26. }
  27.  
  28. protected override void Initialize()
  29. {
  30. // TODO: Add your initialization logic here
  31.  
  32. base.Initialize();
  33. oldstate = Keyboard.GetState();
  34. }
  35.  
  36.  
  37. protected override void LoadContent()
  38. {
  39. // Create a new SpriteBatch, which can be used to draw textures.
  40. spriteBatch = new SpriteBatch(GraphicsDevice);
  41. whatever = Content.Load<Texture2D>("whatever");
  42.  
  43. KeyboardState newstate = Keyboard.GetState();
  44.  
  45.  
  46. }
  47.  
  48.  
  49. protected override void UnloadContent()
  50. {
  51.  
  52. }
  53.  
  54.  
  55. protected override void Update(GameTime gameTime)
  56. {
  57.  
  58. if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
  59. this.Exit();
  60.  
  61.  
  62.  
  63. base.Update(gameTime);
  64. }
  65.  
  66. private void updateInput()
  67. {
  68. KeyboardState newstate = Keyboard.GetState();
  69. if (newstate.IsKeyDown(Keys.D))
  70. {
  71. if (oldstate.IsKeyDown(Keys.D))
  72. {
  73. whatpos.X += 1;
  74. }
  75. else if (oldstate.IsKeyDown(Keys.D))
  76. {
  77. }
  78. oldstate = newstate;
  79. }
  80. }
  81.  
  82. protected override void Draw(GameTime gameTime)
  83. {
  84. GraphicsDevice.Clear(Color.CornflowerBlue);
  85.  
  86. spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);
  87. spriteBatch.Draw(whatever, whatpos, Color.White);
  88. spriteBatch.End();
  89.  
  90.  
  91.  
  92. base.Draw(gameTime);
  93. }
  94. }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement