アットウィキロゴ

cs0212x

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 game0212p
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        int x, y;

        private Texture2D mizu;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        protected override void Initialize()
        {
            x = 0;
            y = 0;
            base.Initialize();
        }


        protected override void LoadContent()
        {

            spriteBatch = new SpriteBatch(GraphicsDevice);
            mizu = Content.Load<Texture2D>("kuroki");


        }


        protected override void UnloadContent()
        {
            // TODO: Unload any non ContentManager content here
        }


        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 (y < Mouse.GetState().Y) y = y + 10;
            if (y > Mouse.GetState().Y) y = y - 10;
            if (x > 400) x = 400;
            if (y > 400) y = 400;
            if (x < 0) x = 0;
            if (y < 0) y = 0;


            base.Update(gameTime);
        }


        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin();
            spriteBatch.Draw(mizu, new Rectangle(x, y, 100, 100), Color.LightGray);
            spriteBatch.End();
            base.Draw(gameTime);
        }
    }
}
最終更新:2011年02月13日 01:38