コード例 #1
0
ファイル: Game1.cs プロジェクト: and0ne808/CodingHW
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            //EXIT APPLICATION
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            //START NEW SEARCH
            if (Keyboard.GetState().IsKeyDown(Keys.Space) && searched == true && pressed == false)
            {
                myGraph = new Graph();
                myGraph.initialize(graphics, gridSize, this, spriteBatch);
                searched = false;
                pressed  = true;
            }
            if (Keyboard.GetState().IsKeyUp(Keys.Space) && pressed == true)
            {
                pressed = false;
            }

            while (searched == false)
            {
                Random rnd = new Random();
                myGraph.AndrewBreadthFirst(myGraph.nodes[rnd.Next(0, 31), rnd.Next(0, 23)], myGraph.nodes[rnd.Next(0, 31), rnd.Next(0, 23)]);
                searched = true;
            }

            base.Update(gameTime);
        }
コード例 #2
0
ファイル: Game1.cs プロジェクト: and0ne808/CodingHW
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            //EXIT APPLICATION
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
                Exit();

            //START NEW SEARCH
            if (Keyboard.GetState().IsKeyDown(Keys.Space) && searched == true && pressed == false)
            {
                myGraph = new Graph();
                myGraph.initialize(graphics, gridSize, this, spriteBatch);
                searched = false;
                pressed = true;
            }
            if (Keyboard.GetState().IsKeyUp(Keys.Space) && pressed == true)
            {
                pressed = false;
            }

            while (searched == false)
            {
                
                Random rnd = new Random();
                myGraph.AndrewBreadthFirst(myGraph.nodes[rnd.Next(0,31), rnd.Next(0,23)], myGraph.nodes[rnd.Next(0,31), rnd.Next(0,23)]);
                searched = true;
            }

                base.Update(gameTime);
        }
コード例 #3
0
ファイル: Game1.cs プロジェクト: and0ne808/CodingHW
        /// <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()
        {
            base.Initialize();

            myGraph = new Graph();
            myGraph.initialize(graphics, gridSize, this, spriteBatch);
        }
コード例 #4
0
ファイル: Game1.cs プロジェクト: and0ne808/CodingHW
        /// <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()
        {
            base.Initialize();

            myGraph = new Graph();
            myGraph.initialize(graphics, gridSize, this, spriteBatch);         
        }