コード例 #1
0
        private void AddBackgroundEnemy()
        {
            // Create the animation object
            Animation enemyAnimation = new Animation();

            // Initialize the animation with the correct animation information
            enemyAnimation.Initialize(enemyTexture, Vector2.Zero, 47, 61, 8, 30, Color.Gray, (float)(random.NextDouble() * 0.5 + 0.4), true);
            enemyAnimation.Fade = true;

            // Randomly generate the position of the enemy
            Vector2 position = new Vector2(GraphicsDevice.Viewport.Width + enemyTexture.Width / 2, random.Next(100, GraphicsDevice.Viewport.Height - 100));

            // Create an enemy
            BackgroundEnemy backgroundEnemy = new BackgroundEnemy();

            // Initialize the enemy
            backgroundEnemy.Initialize(enemyAnimation, position);

            // Add the enemy to the active enemies list
            backgroundEnemies.Add(backgroundEnemy);
        }
コード例 #2
0
ファイル: Game1.cs プロジェクト: CharlesMicou/Projects
        private void AddBackgroundEnemy()
        {
            // Create the animation object
            Animation enemyAnimation = new Animation();

            // Initialize the animation with the correct animation information
            enemyAnimation.Initialize(enemyTexture, Vector2.Zero, 47, 61, 8, 30, Color.Gray, (float)(random.NextDouble()*0.5+0.4), true);
            enemyAnimation.Fade = true;

            // Randomly generate the position of the enemy
            Vector2 position = new Vector2(GraphicsDevice.Viewport.Width + enemyTexture.Width / 2, random.Next(100, GraphicsDevice.Viewport.Height - 100));

            // Create an enemy
            BackgroundEnemy backgroundEnemy = new BackgroundEnemy();

            // Initialize the enemy
            backgroundEnemy.Initialize(enemyAnimation, position);

            // Add the enemy to the active enemies list
            backgroundEnemies.Add(backgroundEnemy);
        }