Esempio n. 1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>

        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y +
                                                 GraphicsDevice.Viewport.TitleSafeArea.Height / 2);
            Animation playerAnimation = new Animation();
            Texture2D playerTexture   = Content.Load <Texture2D>("shipAnimation");

            playerAnimation.Initialize(playerTexture, Vector2.Zero, 115, 69, 8, 30, Color.White, 1f, true);
            player.Initialize(playerAnimation, playerPosition);
            mainBackground = Content.Load <Texture2D>("mainbackground");
            bgLayer1.Initialize(Content, "bgLayer1", -1, GraphicsDevice.Viewport.Width);
            bgLayer2.Initialize(Content, "bgLayer2", -2, GraphicsDevice.Viewport.Width);
            enemyTexture      = Content.Load <Texture2D>("mineAnimation");
            endScreen         = Content.Load <Texture2D>("endMenu");
            projectileTexture = Content.Load <Texture2D>("laser");
            explosionTexture  = Content.Load <Texture2D>("explosion");
            gameplayMusic     = Content.Load <Song>("sounds/gameMusic");
            laserSound        = Content.Load <SoundEffect>("sounds/laserFire");
            explosionSound    = Content.Load <SoundEffect>("sounds/explosion");
            font = Content.Load <SpriteFont>("gameFont");
            PlayMusic(gameplayMusic);
            powerUp.Initialize(Content.Load <Texture2D>("spriteSheet"), new Vector2(random.Next(100, GraphicsDevice.Viewport.Width),
                                                                                    random.Next(100, GraphicsDevice.Viewport.Height)), 300 / 5, 360 / 6, 30, 20, Color.White, 1.0f, true, 6, 5, random.Next(1, 5));

            // TODO: use this.Content to load your game content here
        }
Esempio n. 2
0
        protected override void LoadContent()
        {
            explosionTexture = Content.Load <Texture2D>("explosion");
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            // Load the player resources
            Animation playerAnimation = new Animation();
            Texture2D playerTexture   = Content.Load <Texture2D>("shipAnimation");

            playerAnimation.Initialize(playerTexture, Vector2.Zero, 115, 69, 8, 30, Color.White, 1f, true);


            Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y + GraphicsDevice.Viewport.TitleSafeArea.Height / 2);

            player.Initialize(playerAnimation, playerPosition);

            // Load the parallaxing background
            bgLayer1.Initialize(Content, "bgLayer1", GraphicsDevice.Viewport.Width, -1);
            bgLayer2.Initialize(Content, "bgLayer2", GraphicsDevice.Viewport.Width, -2);

            enemyTexture      = Content.Load <Texture2D>("mineAnimation");
            projectileTexture = Content.Load <Texture2D>("laser");
            mainBackground    = Content.Load <Texture2D>("mainbackground");

            // Load the music
            gameplayMusic = Content.Load <Song>("sound/gameMusic");

            // Load the laser and explosion sound effect
            laserSound     = Content.Load <SoundEffect>("sound/laserFire");
            explosionSound = Content.Load <SoundEffect>("sound/explosion");
            // Load the score font
            font = Content.Load <SpriteFont>("gameFont");
            // Start the music right away
            PlayMusic(gameplayMusic);
        }
Esempio n. 3
0
        private void LoadAssets()
        {
            // Load the player resources
            Animation playerAnimation = new Animation();
            Texture2D playerTexture   = Content.Load <Texture2D>("shipAnimation");

            playerAnimation.Initialize(playerTexture, Vector2.Zero, 115, 69, 8, 30, Color.White, 1f, true);

            Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y
                                                 + GraphicsDevice.Viewport.TitleSafeArea.Height / 2);

            player.Initialize(playerAnimation, playerPosition);
            // Load the parallaxing background
            bgLayer1.Initialize(Content, "bgLayer1", GraphicsDevice.Viewport.Width, -1);
            bgLayer2.Initialize(Content, "bgLayer2", GraphicsDevice.Viewport.Width, -2);
            enemyTexture      = Content.Load <Texture2D>("mineAnimation");
            projectileTexture = Content.Load <Texture2D>("laser");
            explosionTexture  = Content.Load <Texture2D>("explosion");

            mainBackground = Content.Load <Texture2D>("mainbackground");
            // Load the music
            gameplayMusic = Content.Load <Song>("Sounds\\gameMusic");

            // Load the laser and explosion sound effect
            laserSound     = Content.Load <SoundEffect>("Sounds\\laserFire");
            explosionSound = Content.Load <SoundEffect>("Sounds\\explosion");

            // Start the music right away
            PlayMusic(gameplayMusic);


            loading = false;
        }
Esempio n. 4
0
File: Game1.cs Progetto: Xe3d/Main
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // Load the player resources
            Animation playerAnimation = new Animation();
            Texture2D playerTexture   = Content.Load <Texture2D>("shipAnimation");

            playerAnimation.Initialize(playerTexture, Vector2.Zero, 115, 69, 8, 30, Color.White, 1f, true);


            Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y
                                                 + GraphicsDevice.Viewport.TitleSafeArea.Height / 2);

            player.Initialize(playerAnimation, playerPosition);

            // Load the parallaxing background
            bgLayer1.Initialize(Content, "bgLayer1", GraphicsDevice.Viewport.Width, -2.1f);
            bgLayer2.Initialize(Content, "bgLayer2", GraphicsDevice.Viewport.Width, -3.9f);

            mainBackground = Content.Load <Texture2D>("mainbackground");

            enemyTexture = Content.Load <Texture2D>("mineAnimation");
        }
Esempio n. 5
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here

            // Load the player resources
            Animation playerAnimation = new Animation();
            Texture2D playerTexture   = Content.Load <Texture2D>("shipAnimation");

            playerAnimation.Initialize(playerTexture, Vector2.Zero, 115, 69, 8, 30, Color.White, 1f, true);

            Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y
                                                 + GraphicsDevice.Viewport.TitleSafeArea.Height / 2);

            player.Initialize(playerAnimation, playerPosition);

            // Load the parallaxing background
            bgLayer1.Initialize(Content, "bgLayer1", GraphicsDevice.Viewport.Width, -1);
            bgLayer2.Initialize(Content, "bgLayer2", GraphicsDevice.Viewport.Width, -2);

            mainBackground = Content.Load <Texture2D>("mainbackground");

            enemyTexture = Content.Load <Texture2D>("mineAnimation");

            explosionAnim = new Animation();
            Texture2D explosionTexture = Content.Load <Texture2D>("explosion");

            explosionAnim.Initialize(explosionTexture, Vector2.Zero, 134, 134, 12, 30, Color.White, 1f, false);
            explosionAnim.Active = false;

            explosionSoundEffect = Content.Load <SoundEffect>(@"Audio\explosion");
        }
Esempio n. 6
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // Load the player resources
            Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y + GraphicsDevice.Viewport.TitleSafeArea.Height / 2);

            // Load the player resources
            Animation playerAnimation = new Animation();
            Texture2D playerTexture   = Content.Load <Texture2D>("shipAnimation");

            playerAnimation.Initialize(playerTexture, Vector2.Zero, 115, 69, 8, 30, Color.White, 1f, true);

            player.Initialize(playerAnimation, playerPosition);

            // Load the parallaxing background
            bgLayer1.Initialize(Content, "bgLayer1", GraphicsDevice.Viewport.Width, -1);
            bgLayer2.Initialize(Content, "bgLayer2", GraphicsDevice.Viewport.Width, -2);

            mainBackground = Content.Load <Texture2D>("mainbackground");
            enemyTexture   = Content.Load <Texture2D>("mineAnimation");

            projectileTexture = Content.Load <Texture2D>("laser");

            explosionTexture = Content.Load <Texture2D>("explosion");

            // Load the music
            gameplayMusic = Content.Load <Song>("sound/gameMusic");

            // Load the laser and explosion sound effect and initialize to a soundInstance, and then set volume
            try
            {
                soundInstanceExplosion        = Content.Load <SoundEffect>("sound/explosion").CreateInstance();
                soundInstanceExplosion.Volume = 0.15f;
            }
            catch { }

            try
            {
                soundInstanceLaser        = Content.Load <SoundEffect>("sound/laserFire").CreateInstance();
                soundInstanceLaser.Volume = 0.7f;
            }
            catch { }

            //PlayMusic(gameplayMusic); //Start the music right away

            font = Content.Load <SpriteFont>("gameFont");       //load game font

            combatFont = Content.Load <SpriteFont>("gameFont"); //load combat font
        }
Esempio n. 7
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            //Load Player Resources
            explosionTexture = Content.Load <Texture2D>("explosion");
            Animation playerAnimation = new Animation();
            Texture2D playerTexture   = Content.Load <Texture2D>("shipAnimation");

            playerAnimation.Initialize(playerTexture, Vector2.Zero, 115, 69, 8, 30, Color.White, 1f, true);
            Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y
                                                 + GraphicsDevice.Viewport.TitleSafeArea.Height / 2);

            player.Initialize(playerAnimation, playerPosition);
            //Enemy Resoursces
            enemyTexture = Content.Load <Texture2D>("mineAnimation");

            //Set a constant player move speed
            playerMoveSpeed = 8.0f;

            //Projectiles
            projectileTexture = Content.Load <Texture2D>("laser");

            //Set player movement keys
            movingDown  = Keys.Down;
            movingUp    = Keys.Up;
            movingRight = Keys.Right;
            movingLeft  = Keys.Left;

            //Audio
            gameplayMusic = Content.Load <Song>("sound/gameMusic");

            laserSound     = Content.Load <SoundEffect>("sound/laserFire");
            explosionSound = Content.Load <SoundEffect>("sound/explosion");

            PlayMusic(gameplayMusic);

            //Load UI content
            ui.Initialize(player, Content, "gameFont");

            //Enable freedrag gesture
            TouchPanel.EnabledGestures = GestureType.FreeDrag;

            // Load background textures
            bgLayer1.Initialize(Content, "bgLayer1", GraphicsDevice.Viewport.Width, -1);
            bgLayer2.Initialize(Content, "bgLayer2", GraphicsDevice.Viewport.Width, -2);
            mainBackground = Content.Load <Texture2D>("mainbackground");
            // TODO: use this.Content to load your game content here
        }
        public override void LoadContent()
        {
            //////******************* INIT

            player = new Player();

            // Set a constant player move speed
            playerMoveSpeed = 8.0f;

            //Enable the FreeDrag gesture.
            TouchPanel.EnabledGestures = GestureType.FreeDrag;

            bgLayer1 = new ParallaxingBackground();
            bgLayer2 = new ParallaxingBackground();

            // Initialize the enemies list
            enemies = new List<Enemy>();

            // Set the time keepers to zero
            previousSpawnTime = TimeSpan.Zero;

            // Used to determine how fast enemy respawns
            enemySpawnTime = TimeSpan.FromSeconds(1.0f);

            // Initialize our random number generator
            random = new Random();

            projectiles = new List<Projectile>();

            // Set the laser to fire every quarter second
            fireTime = TimeSpan.FromSeconds(.25f);

            explosions = new List<Animation>();

            score = 0;

            //////////******************* LOAD
            if (Content == null)
                Content = new ContentManager(ScreenManager.Game.Services, "Content");

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = ScreenManager.SpriteBatch;

            //player.Initialize(Content.Load<Texture2D>("player"), playerPosition);
            // Load the player resources
            Animation playerAnimation = new Animation();
            Texture2D playerTexture = Content.Load<Texture2D>("shipAnimation");
            playerAnimation.Initialize(playerTexture, Vector2.Zero, 115, 69, 8, 30, Color.White, 1f, true);

            Vector2 playerPosition = new Vector2(ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.X, ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.Y + ScreenManager.GraphicsDevice.Viewport.TitleSafeArea.Height / 2);
            player.Initialize(playerAnimation, playerPosition);

            // Load the parallaxing background
            bgLayer1.Initialize(Content, "bgLayer1", ScreenManager.GraphicsDevice.Viewport.Width, -1);
            bgLayer2.Initialize(Content, "bgLayer2", ScreenManager.GraphicsDevice.Viewport.Width, -2);

            mainBackground = Content.Load<Texture2D>("mainbackground");
            enemyTexture = Content.Load<Texture2D>("mineAnimation");
            projectileTexture = Content.Load<Texture2D>("laser");
            explosionTexture = Content.Load<Texture2D>("explosion");
            // Load the score font
            font = Content.Load<SpriteFont>("gameFont");

            // Load the music
            gameplayMusic = Content.Load<Song>("sound/gameMusic");

            // Load the laser and explosion sound effect
            laserSound = Content.Load<SoundEffect>("sound/laserFire");
            explosionSound = Content.Load<SoundEffect>("sound/explosion");
            SoundEffect.MasterVolume = (float)Game1.VolumeSound / 100;

            // Start the music right away
            PlayMusic(gameplayMusic);
        }
Esempio n. 9
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            LoadPlayer();

            bgLayer1.Initialize(Content, "Graphics\\bgLayer1", GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 1);
            bgLayer2.Initialize(Content, "Graphics\\bgLayer2", GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 2);
            mainBackground = Content.Load <Texture2D>("Graphics\\Starbasesnow");

            enemyTexture = Content.Load <Texture2D>("Graphics\\enemyAnimation");

            shootingEnemy.LoadContent("Graphics\\shootingEnemy", Content);
            shootingEnemyAnimation = new Animation();
            shootingEnemyAnimation.Initialize(shootingEnemy.Texture, Vector2.Zero, 300, 300, 1, 30, Color.White, 0.2f, true, 0, Vector2.Zero,
                                              SpriteEffects.None, 0);
            enemyCount = 0;

            laserTexture      = Content.Load <Texture2D>("Graphics\\laser");
            enemyLaserTexture = Content.Load <Texture2D>("Graphics\\enemyLaser");

            healer.LoadContent("Graphics\\healer", Content);
            healerAnimation = new Animation();
            healerAnimation.Initialize(healer.Texture, Vector2.Zero, 155, 114, 3, 30, Color.White, 0.37f, true, 0, Vector2.Zero,
                                       SpriteEffects.None, 0);

            bomb.LoadContent("Graphics\\galaxy", Content);
            bombAnimation = new Animation();
            bombAnimation.Initialize(bomb.Texture, Vector2.Zero, 256, 256, 15, 30, Color.White, 0.42f, true, 0, Vector2.Zero,
                                     SpriteEffects.None, 0);

            for (int i = 0; i < asteroids.Length; i++)
            {
                asteroids[i]          = new Asteroids();
                asteroidsAnimation[i] = new Animation();
            }

            asteroids[0].LoadContent("Graphics\\aestroid1", Content);
            asteroidsAnimation[0].Initialize(asteroids[0].Texture, Vector2.Zero, 447, 390, 1, 30, Color.White, 0.14f, true, 0,
                                             new Vector2(asteroids[0].Texture.Width / 2, asteroids[0].Texture.Height / 2),
                                             SpriteEffects.None, 0);

            asteroids[1].LoadContent("Graphics\\aestroid2", Content);
            asteroidsAnimation[1].Initialize(asteroids[1].Texture, Vector2.Zero, 424, 349, 1, 30, Color.White, 0.13f, true, 0,
                                             new Vector2(asteroids[1].Texture.Width / 2, asteroids[1].Texture.Height / 2),
                                             SpriteEffects.None, 0);

            asteroids[2].LoadContent("Graphics\\aestroid3", Content);
            asteroidsAnimation[2].Initialize(asteroids[2].Texture, Vector2.Zero, 394, 323, 1, 30, Color.White, 0.14f, true, 0,
                                             new Vector2(asteroids[2].Texture.Width / 2, asteroids[2].Texture.Height / 2),
                                             SpriteEffects.None, 0);


            enemyExplosionTexture = Content.Load <Texture2D>("Graphics\\explosion");
            allyExplosionTexture  = Content.Load <Texture2D>("Graphics\\blueExplosion");
            brownAsteroidTexture  = Content.Load <Texture2D>("Graphics\\brownExplosion");
            greyAsteroidTexture   = Content.Load <Texture2D>("Graphics\\greyExplosion");

            playButton = new Button("Graphics\\playButton", new Vector2((GraphicsDevice.Viewport.TitleSafeArea.Width / 2), 250), Content,
                                    0.9f, 1f);
            exitButton = new Button("Graphics\\exitButton", new Vector2((GraphicsDevice.Viewport.TitleSafeArea.Width / 2), 390), Content,
                                    0.9f, 1f);
            healthBar = new HealthBar("Graphics\\healthBar2", Content, 262, 41, 0.8f, new Vector2(458, 5));

            playButtonSound             = new Sound(Content, "Sounds\\button", 0.3f, false);
            exitButtonSound             = new Sound(Content, "Sounds\\button", 0.3f, false);
            playerLaserSound            = new Sound(Content, "Sounds\\laser", 0.16f, false);
            enemyLaserSound             = new Sound(Content, "Sounds\\enemyLaser", 0.17f, false);
            asteroidExplosionSound      = new Sound(Content, "Sounds\\asteroidExplosion", 0.17f, false);
            shootingEnemyExplosionSound = new Sound(Content, "Sounds\\asteroidExplosion", 0.17f, false);
            bigBombSound         = new Sound(Content, "Sounds\\bigBomb", 0.25f, false);
            healerCollisionSound = new Sound(Content, "Sounds\\health", 0.25f, false);
            playerExplosionSound = new Sound(Content, "Sounds\\playerExplosion", 0.3f, false);
            injuredPlayerSound   = new Sound(Content, "Sounds\\injuredPlayer", 0.27f, false);

            gameMusic = new GameMusic(Content, "Sounds\\gameMusic", 0.35f, true);

            font = Content.Load <SpriteFont>("Text");
        }