Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Graphics;
- using Microsoft.Xna.Framework.Input;
- using System;
- namespace Game1
- {
- /// <summary>
- /// This is the main type for your game.
- /// </summary>
- public class Game1 : Game
- {
- GraphicsDeviceManager graphics;
- SpriteBatch spriteBatch;
- Texture2D hg;
- Texture2D fadenkreuz;
- Texture2D zielScheibe;
- Vector2 zielPos;
- float timer;
- int score;
- SpriteFont font;
- MouseState mState;
- bool mReleased;
- float distanz;
- const int ZIEL_RADIUS = 45;
- Random rnd;
- public Game1()
- {
- graphics = new GraphicsDeviceManager(this);
- Content.RootDirectory = "Content";
- }
- /// <summary>0ΓΌ
- /// Allows the game to perform any initialization it needs to before starting to run.
- /// This is where it can query for any required services and load any non-graphic
- /// related content. Calling base.Initialize will enumerate through any components
- /// and initialize them as well.
- /// </summary>
- protected override void Initialize()
- {
- // TODO: Add your initialization logic here
- //graphics.PreferredBackBufferWidth = 1200;
- //graphics.PreferredBackBufferHeight = 800;
- //graphics.ApplyChanges();
- timer = 15.0f;
- base.Initialize();
- }
- /// <summary>
- /// LoadContent will be called once per game and is the place to load
- /// all of your content.
- /// </summary>
- protected override void LoadContent()
- {
- // Create a new SpriteBatch, which can be used to draw textures.
- spriteBatch = new SpriteBatch(GraphicsDevice);
- // TODO: use this.Content to load your game content here
- hg = Content.Load<Texture2D>("himmel");
- graphics.PreferredBackBufferWidth = 1200;
- graphics.PreferredBackBufferHeight = 800;
- graphics.ApplyChanges();
- fadenkreuz = Content.Load<Texture2D>("fadenkreuz1");
- zielScheibe = Content.Load<Texture2D>("ziel");
- zielPos = new Vector2(300, 300);
- }
- /// <summary>
- /// UnloadContent will be called once per game and is the place to unload
- /// game-specific content.
- /// </summary>
- protected override void UnloadContent()
- {
- // TODO: Unload any non ContentManager content here
- }
- /// <summary>
- /// Allows the game to run logic such as updating the world,
- /// checking for collisions, gathering input, and playing audio.
- /// </summary>
- /// <param name="gameTime">Provides a snapshot of timing values.</param>
- protected override void Update(GameTime gameTime)
- {
- if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
- Exit();
- // TODO: Add your update logic here
- if (timer > 0)
- {
- timer -= (float) gameTime.ElapsedGameTime.TotalSeconds;
- }
- base.Update(gameTime);
- }
- /// <summary>
- /// This is called when the game should draw itself.
- /// </summary>
- /// <param name="gameTime">Provides a snapshot of timing values.</param>
- protected override void Draw(GameTime gameTime)
- {
- GraphicsDevice.Clear(Color.CornflowerBlue);
- // TODO: Add your drawing code here
- spriteBatch.Begin();
- spriteBatch.Draw(hg, Vector2.Zero, Color.White);
- if (timer > 0)
- {
- spriteBatch.Draw(zielScheibe, zielPos, Color.White);
- }
- //else if (timer <= 0)
- //{
- // timer = 15.0f;
- // zielPos = new Vector2(500, 500);
- //}
- spriteBatch.End();
- base.Draw(gameTime);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement