アットウィキロゴ

cs0207

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 game0207
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        int x, y;
        int stage;
        int gtime;
        private Texture2D mizu;

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

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


        protected override void LoadContent()
        {

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


        }


        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();

            gtime = gtime + 1;
            if (gtime > 300) stage = 2;

            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);
            if (stage == 1)
            {
                spriteBatch.Begin();
                spriteBatch.Draw(mizu, new Rectangle(0, 0, 500, 500), Color.LightGray);
                spriteBatch.End();
            }

            if (stage == 2)
            {
                spriteBatch.Begin();
                spriteBatch.Draw(mizu, new Rectangle(x, y, 100, 100), Color.LightGray);
                spriteBatch.End();
            }
            base.Draw(gameTime);
        }
    }
}
最終更新:2011年02月11日 05:35