Example #1
0
        private void SpawnBigCircle()
        {
            int randomLocationX = GetRandomLocation(GameConstants.SPAWN_BORDER_SIZE, GameConstants.WINDOW_WIDTH - 2 * GameConstants.SPAWN_BORDER_SIZE);
            // generate outside window
            int randomLocationY = GameConstants.SPAWN_OUTSIDE_WINDOW + GetRandomLocation(GameConstants.SPAWN_BORDER_SIZE, GameConstants.WINDOW_HEIGHT - 2 * GameConstants.SPAWN_BORDER_SIZE);


            //random velocity
            float speedBigCircle = GameConstants.SPEED_MIN_BIG_CIRCLE + RandomNumberGerator.NextFloat(GameConstants.SPEED_RANGE_CIRCLE);
            float angleBigCircle = RandomNumberGerator.NextFloat((float)(2 * Math.PI));
            // use sin for x and don't use for y
            Vector2 velocity = new Vector2(speedBigCircle * (float)Math.Sin((double)angleBigCircle), speedBigCircle);

            if (velocity.Y == 0)
            {
                velocity.Y = velocity.X;
            }

            if (velocity.Y < 0)
            {
                velocity.Y *= -1;
            }

            string    spriteName   = @"graphics\bigCircle\" + player.ColorEnamy + "BigCircle";
            BigCircle newBigCircle = new BigCircle(Content, spriteName, randomLocationX, randomLocationY, velocity);

            bigCircles.Add(newBigCircle);
        }
Example #2
0
        private void SpawnLittleCircle(Rectangle drawRectangleBigCircle)
        {
            //random x and y
            // i>1 because RandomNumberGerator.Next() spawn from 1 to max
            // possibility that loop does not work
            for (int i = RandomNumberGerator.Next(GameConstants.MAX_COUNT_LITTLE_CIRCLE_AFTER_KILL_BIG_CIRCLE); i >= 1; i--)
            {
                int randomLocationX = GetRandomLocation(drawRectangleBigCircle.X, 60);
                // generate outside window
                int randomLocationY = GetRandomLocation(drawRectangleBigCircle.Y, 60);

                //random velocity
                float speedLittleCircle = GameConstants.SPEED_MIN_LITTLE_CIRCLE_AFTER_KILL_BIG_CIRCLE + RandomNumberGerator.NextFloat(GameConstants.SPEED_RANGE_CIRCLE_AFTER_KILL_BIG_CIRCLE);
                float angleLittleCircle = RandomNumberGerator.NextFloat((float)(2 * Math.PI));

                // use sin for x and don't use for y
                Vector2 velocity = new Vector2(speedLittleCircle * (float)Math.Sin((double)angleLittleCircle), speedLittleCircle);

                if (velocity.Y == 0)
                {
                    velocity.Y = velocity.X;
                }

                if (velocity.Y < 0)
                {
                    velocity.Y *= -1;
                }

                string       spriteName      = @"graphics\littleCircle\" + player.ColorEnamy + "LittleCircle";
                LittleCircle newLittleCircle = new LittleCircle(Content, spriteName, randomLocationX, randomLocationY, velocity);
                littleCircles.Add(newLittleCircle);
            }
        }
Example #3
0
        /// <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()
        {
            RandomNumberGerator.Initialize();

            base.Initialize();
        }
Example #4
0
 // get random location(int)
 private int GetRandomLocation(int min, int range)
 {
     return(min + RandomNumberGerator.Next(range + 1));
 }