using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
namespace game0321
{
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager gr;
SpriteBatch sp;
Texture2D gun;
int x, y;
public Game1()
{
gr = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
gr.PreferredBackBufferHeight = 500;
gr.PreferredBackBufferWidth = 500;
}
protected override void Initialize()
{
x = 0;
y = 400;
base.Initialize();
}
protected override void LoadContent()
{
sp = new SpriteBatch(GraphicsDevice);
gun = Content.Load<Texture2D>("gun");
}
protected override void UnloadContent()
{
}
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
if (x < Mouse.GetState().X) x = x + 10;
if (x > Mouse.GetState().X) x = x - 10;
if (x > 500) x = 500;
if (x < 0) x = 0;
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
sp.Begin();
sp.Draw(gun, new Rectangle(x, y, 50, 50), Color.White);
sp.End();
base.Draw(gameTime);
}
}
}
最終更新:2011年02月21日 05:54