Exemplo n.º 1
0
        /// <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)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            collisionManager = new CollisionsManager(playerSprite, explosionManager, enemyManager);

            //Updates that Starfield corresponds with time
            starField.Update(gameTime);

            //Player Movement
            playerSprite.HandleSpriteMovement(gameTime);

            playerSprite.Update(gameTime);

            collisionManager.CheckCollisions();

            enemyManager.Update(gameTime);

            explosionManager.Update(gameTime);


            base.Update(gameTime);
        }
Exemplo n.º 2
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);
            //Loads Mixeds prite
            mixedSprites = Content.Load <Texture2D>(@"Images/Mixed");
            //Loads new starfield to this StarField
            starField = new Starfield(this.Window.ClientBounds.Width, this.Window.ClientBounds.Height, 200, new Vector2(0, 30f), mixedSprites, new Rectangle(0, 450, 2, 2));

            Rectangle screenBounds = new Rectangle(0, 0, this.Window.ClientBounds.Width, this.Window.ClientBounds.Height);

            playerSprite = new PlayerManager(Content.Load <Texture2D>(@"Images/SpriteSheet"), 1, 32, 48, screenBounds);

            enemyManager = new EnemyManager(mixedSprites, new Rectangle(0, 200, 50, 50), 6, playerSprite, screenBounds);

            //_________________________________
            playerSprite.Position = new Vector2(400, 300);

            explosionManager = new ExplosionManager(mixedSprites, new Rectangle(0, 100, 50, 50), 3, new Rectangle(0, 450, 2, 2));

            collisionManager = new CollisionsManager(playerSprite, explosionManager, enemyManager);
        }