Advertisement
Guest User

Untitled

a guest
May 21st, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.18 KB | None | 0 0
  1. using Microsoft.Xna.Framework;
  2. using Microsoft.Xna.Framework.Graphics;
  3. using Microsoft.Xna.Framework.Input;
  4. using System;
  5.  
  6. namespace Game1
  7. {
  8. /// <summary>
  9. /// This is the main type for your game.
  10. /// </summary>
  11. public class Game1 : Game
  12. {
  13. GraphicsDeviceManager graphics;
  14. SpriteBatch spriteBatch;
  15. Texture2D hg;
  16. Texture2D fadenkreuz;
  17. Texture2D zielScheibe;
  18. Vector2 zielPos;
  19.  
  20. float timer;
  21. int score;
  22. SpriteFont font;
  23.  
  24. MouseState mState;
  25. bool mReleased;
  26. float distanz;
  27. const int ZIEL_RADIUS = 45;
  28. Random rnd;
  29.  
  30.  
  31. public Game1()
  32. {
  33. graphics = new GraphicsDeviceManager(this);
  34. Content.RootDirectory = "Content";
  35.  
  36.  
  37. }
  38.  
  39. /// <summary>0ΓΌ
  40. /// Allows the game to perform any initialization it needs to before starting to run.
  41. /// This is where it can query for any required services and load any non-graphic
  42. /// related content. Calling base.Initialize will enumerate through any components
  43. /// and initialize them as well.
  44. /// </summary>
  45. protected override void Initialize()
  46. {
  47. // TODO: Add your initialization logic here
  48. //graphics.PreferredBackBufferWidth = 1200;
  49. //graphics.PreferredBackBufferHeight = 800;
  50. //graphics.ApplyChanges();
  51.  
  52. timer = 15.0f;
  53.  
  54. base.Initialize();
  55. }
  56.  
  57. /// <summary>
  58. /// LoadContent will be called once per game and is the place to load
  59. /// all of your content.
  60. /// </summary>
  61.  
  62.  
  63. protected override void LoadContent()
  64. {
  65. // Create a new SpriteBatch, which can be used to draw textures.
  66. spriteBatch = new SpriteBatch(GraphicsDevice);
  67.  
  68. // TODO: use this.Content to load your game content here
  69.  
  70. hg = Content.Load<Texture2D>("himmel");
  71. graphics.PreferredBackBufferWidth = 1200;
  72. graphics.PreferredBackBufferHeight = 800;
  73. graphics.ApplyChanges();
  74.  
  75. fadenkreuz = Content.Load<Texture2D>("fadenkreuz1");
  76. zielScheibe = Content.Load<Texture2D>("ziel");
  77. zielPos = new Vector2(300, 300);
  78. }
  79.  
  80. /// <summary>
  81. /// UnloadContent will be called once per game and is the place to unload
  82. /// game-specific content.
  83. /// </summary>
  84. protected override void UnloadContent()
  85. {
  86. // TODO: Unload any non ContentManager content here
  87. }
  88.  
  89. /// <summary>
  90. /// Allows the game to run logic such as updating the world,
  91. /// checking for collisions, gathering input, and playing audio.
  92. /// </summary>
  93. /// <param name="gameTime">Provides a snapshot of timing values.</param>
  94. protected override void Update(GameTime gameTime)
  95. {
  96. if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
  97. Exit();
  98.  
  99. // TODO: Add your update logic here
  100.  
  101. if (timer > 0)
  102. {
  103. timer -= (float) gameTime.ElapsedGameTime.TotalSeconds;
  104. }
  105.  
  106. base.Update(gameTime);
  107. }
  108.  
  109. /// <summary>
  110. /// This is called when the game should draw itself.
  111. /// </summary>
  112. /// <param name="gameTime">Provides a snapshot of timing values.</param>
  113. protected override void Draw(GameTime gameTime)
  114. {
  115. GraphicsDevice.Clear(Color.CornflowerBlue);
  116.  
  117. // TODO: Add your drawing code here
  118. spriteBatch.Begin();
  119. spriteBatch.Draw(hg, Vector2.Zero, Color.White);
  120.  
  121. if (timer > 0)
  122. {
  123. spriteBatch.Draw(zielScheibe, zielPos, Color.White);
  124. }
  125. //else if (timer <= 0)
  126. //{
  127. // timer = 15.0f;
  128. // zielPos = new Vector2(500, 500);
  129. //}
  130.  
  131. spriteBatch.End();
  132.  
  133.  
  134. base.Draw(gameTime);
  135. }
  136. }
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement