예제 #1
0
파일: GameOfLife.cs 프로젝트: miintz/cgol
        public GameOfLife()
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferHeight = 750;
            graphics.PreferredBackBufferWidth = 750;

            centerX = graphics.PreferredBackBufferHeight / 2;
            centerY = graphics.PreferredBackBufferWidth / 2;

            height = graphics.PreferredBackBufferHeight;
            width = graphics.PreferredBackBufferWidth;

            cols = 750;
            rows = 750;

            gridSize = 5;

            Content.RootDirectory = "Content";

            LifeMatrix = new int[cols / gridSize, rows / gridSize];

            this.IsMouseVisible = true;

            //lower the framerate
            this.TargetElapsedTime = TimeSpan.FromSeconds(1.0f / 20.0f);

            playing = false;

            Lifer = new ConwayCreatures();

            //add a few gliders
            int[,] glider = Lifer.LWSpaceShip();

            int gx = Lifer.LWSpaceShipX;
            int gy = Lifer.LWSpaceShipY;

            for (int x = 0; x < gx; x++)
            {
                for (int y = 0; y < gy; y++)
                {
                    LifeMatrix[75 + x, 75 + y] = glider[x, y];
                }
            }

            //add a few gliders
            int[,] glider2 = Lifer.GliderGun();

            int gx2 = Lifer.GliderGunX;
            int gy2 = Lifer.GliderGunY;

            for (int x = 0; x < gx2; x++)
            {
                for (int y = 0; y < gy2; y++)
                {
                    LifeMatrix[75 + x, 50 + y] = glider2[x, y];
                }
            }

            //add a few gliders
            int[,] glider3 = Lifer.Glider();

            int gx3 = Lifer.GliderX;
            int gy3 = Lifer.GliderY;

            for (int x = 0; x < gx3; x++)
            {
                for (int y = 0; y < gy3; y++)
                {
                    LifeMatrix[60 + x, 75 + y] = glider3[x, y];
                }
            }
        }
예제 #2
0
        public GameOfLife()
        {
            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferHeight = 750;
            graphics.PreferredBackBufferWidth  = 750;

            centerX = graphics.PreferredBackBufferHeight / 2;
            centerY = graphics.PreferredBackBufferWidth / 2;

            height = graphics.PreferredBackBufferHeight;
            width  = graphics.PreferredBackBufferWidth;

            cols = 750;
            rows = 750;

            gridSize = 5;

            Content.RootDirectory = "Content";

            LifeMatrix = new int[cols / gridSize, rows / gridSize];

            this.IsMouseVisible = true;

            //lower the framerate
            this.TargetElapsedTime = TimeSpan.FromSeconds(1.0f / 20.0f);

            playing = false;

            Lifer = new ConwayCreatures();

            //add a few gliders
            int[,] glider = Lifer.LWSpaceShip();

            int gx = Lifer.LWSpaceShipX;
            int gy = Lifer.LWSpaceShipY;

            for (int x = 0; x < gx; x++)
            {
                for (int y = 0; y < gy; y++)
                {
                    LifeMatrix[75 + x, 75 + y] = glider[x, y];
                }
            }

            //add a few gliders
            int[,] glider2 = Lifer.GliderGun();

            int gx2 = Lifer.GliderGunX;
            int gy2 = Lifer.GliderGunY;

            for (int x = 0; x < gx2; x++)
            {
                for (int y = 0; y < gy2; y++)
                {
                    LifeMatrix[75 + x, 50 + y] = glider2[x, y];
                }
            }

            //add a few gliders
            int[,] glider3 = Lifer.Glider();

            int gx3 = Lifer.GliderX;
            int gy3 = Lifer.GliderY;

            for (int x = 0; x < gx3; x++)
            {
                for (int y = 0; y < gy3; y++)
                {
                    LifeMatrix[60 + x, 75 + y] = glider3[x, y];
                }
            }
        }