コード例 #1
0
ファイル: Program.cs プロジェクト: GPopov/XNAGameOfLife
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (Life game = new Life())
     {
         game.Run();
     }
 }
コード例 #2
0
ファイル: Main.cs プロジェクト: GPopov/XNAGameOfLife
 public Life()
 {
     graphics = new GraphicsDeviceManager(this);
     Content.RootDirectory = "Content";
     Life._Instance = this;
 }
コード例 #3
0
        // ***********
        // * Methods *
        // ***********

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            // Constructor Testing
            //life = new Life();
            //life = new Life(bWidth, bHeight);
            life = new Life(bWidth, bHeight, texScale, tInterval, go);

            // Make the mouse visible in the game
            // It is not possible to interact with the game (using the mouse) if this is not set to true!
            IsMouseVisible = true;

            // Random 50% starting state
            // Its not perfect - there's no activated cell tracking, so the same cell
            // could potentially be activated (set to alive) two (or more) times.
            int    x          = 0;
            int    y          = 0;
            Random randomCell = new Random();

            for (int i = 0; i < ((life.BoardWidth * life.BoardHeight) / 2); i++)
            {
                x = randomCell.Next(0, (bWidth));
                y = randomCell.Next(0, (bHeight));
                life.TempArray[x, y] = true;
            }


            // *******************
            // * Begin Test Data *
            // *******************

            /*
             * // Checker Board
             * for (y = 0; y < life.BoardHeight; y = y + 2)
             * {
             *  for (x = 0; x < life.BoardWidth; x = x + 2)
             *  {
             *      life.TempArray[x, y] = true;
             *  }
             * }
             * for (y = 1; y < life.BoardHeight; y = y + 2)
             * {
             *  for (x = 1; x < life.BoardWidth; x = x + 2)
             *  {
             *      life.TempArray[x, y] = true;
             *  }
             * }
             */

            /*
             * // Diagonal Line
             * for (x = 0; x < life.BoardWidth && y < life.BoardHeight; x++)
             * {
             *  y = x;
             *  life.TempArray[x, y] = true;
             * }
             */

            /*
             * // Cross or X pattern
             * for (x = 0; x < life.BoardWidth && y < life.BoardHeight; x++)
             * {
             *  y = x;
             *  life.TempArray[x, y] = true;
             * }
             * x = 0;
             * for (y = (life.BoardHeight - 1); y >= 0; y--)
             * {
             *  life.TempArray[x, y] = true;
             *
             *  if (x < (life.BoardWidth - 1) )
             *  {
             *      x++;
             *  }
             * }
             */

            /*
             * // Border Test Square
             * for (x = 0; x < life.BoardWidth; x++)
             * {
             *  life.TempArray[x, 0] = true;
             * }
             * for (y = 0; y < life.BoardHeight; y++)
             * {
             *  life.TempArray[0, y] = true;
             * }
             * for (x = 0; x < life.BoardWidth; x++)
             * {
             *  life.TempArray[x, (life.BoardHeight - 1)] = true;
             * }
             * for (y = 0; y < life.BoardHeight; y++)
             * {
             *  life.TempArray[(life.BoardWidth - 1), y] = true;
             * }
             */

            /*
             * // Block
             * life.TempArray[1, 1] = true;
             * life.TempArray[1, 2] = true;
             * life.TempArray[2, 1] = true;
             * life.TempArray[2, 2] = true;
             */

            /*
             * // Blinker (near top-left)
             * //life.TempArray[2, 2] = true;
             * //life.TempArray[2, 3] = true;
             * //life.TempArray[2, 4] = true;
             */

            /*
             * // Blinker (near bottom-right)
             * life.TempArray[6, 7] = true;
             * life.TempArray[7, 7] = true;
             * life.TempArray[8, 7] = true;
             */

            /*
             * // 3x3 square (top-left)
             * for (y = 0; y < 3; y++)
             * {
             *  for (x = 0; x < 3; x++)
             *  {
             *      life.TempArray[x, y] = true;
             *  }
             * }
             */
            // *****************
            // * End Test Data *
            // *****************

            life.UpdateArrays();

            base.Initialize();
        }
コード例 #4
0
 public Graphic2DVisualizer(Life p)
     : base(p)
 {
     form = new Visualizer2DForm();
 }
コード例 #5
0
 public Viewer(Canvas view, Life grid)
 {
     viewport  = view;
     this.grid = grid;
 }
コード例 #6
0
ファイル: Visualizer.cs プロジェクト: demastri/Simulations
 public Visualization(Life me)
 {
     parent = me;
 }
コード例 #7
0
ファイル: Visualizer.cs プロジェクト: demastri/Simulations
 public Visualization()
 {
     parent = null;
 }
コード例 #8
0
 public Default_2D_Visualizer(Life p)
     : base(p)
 {
 }