コード例 #1
0
        /// <summary>
        /// Clear the current flock if it exists and randomly generate a new one
        /// </summary>
        public void ResetFlock()
        {
            flock.Clear();
            flock.Capacity = flockSize;

            Follower tempBird;
            Vector2  tempDir;
            Vector2  tempLoc;

            Random random = new Random();

            for (int i = 0; i < flockSize; i++)
            {
                tempLoc = new Vector2((float)
                                      random.Next(boundryWidth), (float)random.Next(boundryHeight));
                tempDir = new Vector2((float)
                                      random.NextDouble() - 0.5f, (float)random.NextDouble() - 0.5f);
                tempDir.Normalize();

                tempBird = new Follower(birdTexture, tempDir, tempLoc,
                                        boundryWidth, boundryHeight);
                flock.Add(tempBird);
            }
        }
コード例 #2
0
ファイル: Flock.cs プロジェクト: Clancey/BMX_MonoGame
        /// <summary>
        /// Clear the current flock if it exists and randomly generate a new one
        /// </summary>
        public void ResetFlock()
        {
            flock.Clear();
            flock.Capacity = flockSize;

            Follower tempBird;
            Vector2 tempDir;
            Vector2 tempLoc;

            Random random = new Random();

            for (int i = 0; i < flockSize; i++)
            {
                tempLoc = new Vector2((float)
                    random.Next(boundryWidth), (float)random.Next(boundryHeight));
                tempDir = new Vector2((float)
                    random.NextDouble() - 0.5f, (float)random.NextDouble() - 0.5f);
                tempDir.Normalize();

                tempBird = new Follower(birdTexture, tempDir, tempLoc,
                    boundryWidth, boundryHeight);
                flock.Add(tempBird);
            }
        }