アットウィキロゴ

cs0213

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 game0213
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager gr;
        SpriteBatch sp;
        Texture2D om;
        int mode,mx, x, y;
        int h;

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

            gr.PreferredBackBufferHeight = 500;
            gr.PreferredBackBufferWidth = 500;



        }

        protected override void Initialize()
        {
            mode = 1;
            x = 200;
            y = 100;
            base.Initialize();
        }

        protected override void LoadContent()
        {
            sp = new SpriteBatch(GraphicsDevice);


            om = Content.Load<Texture2D>("7432");
        }

        protected override void UnloadContent()
        {

        }


        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            if (mode == 1) x = x + 10;
            if (mode == 2) y = y + 10;
            if (mode == 3) x = x - 10;
            if (mode == 4) y = y + 10;

            mx = mode;

            h = 0;
            if (mode == 1) h=h+1;
            if (x>400) h=h+1;
            if (h == 2) mx = 2;
            
            if (mode == 2) mx = 3;
            
            h = 0;
            if (mode == 3) h = h + 1;
            if (x < 100) h = h + 1;
            if (h == 2) mx = 4;
            
            if (mode==4) mx = 1;
            
            
            mode = mx;


            base.Update(gameTime);
        }


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

            sp.Begin();
            sp.Draw(om, new Rectangle(x, y, 100, 100), Color.White);
            sp.End();

            base.Draw(gameTime);
        }
    }
}
最終更新:2011年02月13日 01:20