アットウィキロゴ

game0117cs

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 game0117a
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager gr;
        SpriteBatch sp;
        Texture2D om;
        int[,] x = new int[11, 11];
        int[,] y = new int[11, 11];
        int m, n;

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

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



        }

        protected override void Initialize()
        {

            for (m = 1; m < 11; m++)
            {
                for (n = 1; n < 11; n++)
                {
                    x[m, n] = 100 + 20 * m;
                    y[m, n] = 100 + 20 * n;

                }
            }
            base.Initialize();
        }

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


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

        protected override void UnloadContent()
        {

        }


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

            for (m = 1; m < 11; m++)
            {
                for (n = 1; n < 11; n++)
                {
                    x[m, n] = x[m,n]+1;
                    y[m, n] = y[m,n]+1;

                }
            }


            base.Update(gameTime);
        }


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

            sp.Begin();

            for (m = 1; m < 11; m++)
            {
                for (n = 1; n < 11; n++)
                {
                    sp.Draw(om, new Rectangle(x[m, n], y[m, n], 10, 10), Color.White);

                }
            }




            sp.End();

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