protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
arrow = Content.Load<Texture2D>("SpriteOp1");
Viewport viewport = graphics.GraphicsDevice.Viewport;
origin.X = arrow.Width / 2;
origin.Y = arrow.Height / 2;
screenpos.X = viewport.Width / 2;
screenpos.Y = viewport.Height / 2;
// TODO: use this.Content to load your game content here
}
protected override void Update(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;
// TODO: Add your game logic here.
if (Keyboard.GetState().IsKeyDown(Keys.Left))
{
RotationAngle += (float)(elapsed * 5.0);
float circle = MathHelper.Pi * 2;
RotationAngle = RotationAngle % circle;
}
if (Keyboard.GetState().IsKeyDown(Keys.Right))
{
RotationAngle -= (float)(elapsed * 5.0);
float circle = MathHelper.Pi * 2;
RotationAngle = RotationAngle % circle;
}
// TODO: Add your update logic here
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin();
spriteBatch.Draw(arrow, screenpos, null, Color.White, RotationAngle,
origin, 1.0f, SpriteEffects.None, 0f);
spriteBatch.End();
base.Draw(gameTime);
}