Example #1
0
        //public void Initialize(Texture2D texture, Vector2 position)
        //{
        //    PlayerTexture = texture;
        //    // Set the starting position of the player around the middle of the screen and to the back
        //    Position = position;
        //    // Set the player to be active
        //    Active = true;
        //    // Set the player health
        //    Health = 100;
        //}
        public void Initialize(Animation animation, Vector2 position)
        {
            CannonAngle = MathHelper.ToRadians(270f);

            PlayerAnimation = animation;

            // Set the starting posit ion of the player around the middle of the screen and to the back
            Position = position;

            //CannonTip = new Vector2(12,22);

            // Set the player to be active
            Active = true;

            // Set the player health
            Health = 100;
        }
Example #2
0
        //public void Initialize(Texture2D texture, Vector2 position)
        //{
        //    PlayerTexture = texture;
        //    // Set the starting position of the player around the middle of the screen and to the back
        //    Position = position;
        //    // Set the player to be active
        //    Active = true;
        //    // Set the player health
        //    Health = 100;
        //}
        public void Initialize(Animation animation, Vector2 position, Orientation orientation)
        {
            PlayerDirection = orientation;

            if (PlayerDirection == Orientation.facesLeft)
                CannonAngle = MathHelper.ToRadians(270f);
            else
                CannonAngle = MathHelper.ToRadians(90f);

            PlayerAnimation = animation;

            PlayerAnimation.facesDirection = PlayerDirection;

            // Set the starting posit ion of the player around the middle of the screen and to the back
            Position = position;

            //CannonTip = new Vector2(12,22);

            // Set the player to be active
            Active = true;

            // Set the player health
            Health = 100;
        }
Example #3
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);

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

            //Texture2D playerTexture = Content.Load<Texture2D>("Tank");

            // Load the player resources
            Animation playerAnimation = new Animation();
            playerAnimation.Active = false;

            Texture2D playerTexture = Content.Load<Texture2D>("TankSheetNoCannon");
            playerAnimation.Initialize(playerTexture,Vector2.Zero,75,60,3,100,Color.White,1f,true);

            // Load the player resources
            Vector2 playerPosition = new Vector2(ScreenWidth - playerAnimation.FrameWidth, ScreenHeight - playerAnimation.FrameHeight);
               //Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y + GraphicsDevice.Viewport.TitleSafeArea.Height / 2);
            //player.Initialize(playerTexture, playerPosition);
            player.Initialize(playerAnimation, playerPosition);
            player.Cannon = Content.Load<Texture2D>("TankCannon");

            // TODO: use this.Content to load your game content here
        }
Example #4
0
 private void AddExplosion(Vector2 position)
 {
     Animation explosion = new Animation();
     explosion.Initialize(explosionTexture, position, 134, 134, 12, 45, Color.White, 1f, false);
     explosions.Add(explosion);
     explosionSound.Play(0.2f, 0, 0);
 }
Example #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);

            textures = new List<Texture2D>();
            textures.Add(Content.Load<Texture2D>("smokeTexture"));
            textures.Add(Content.Load<Texture2D>("smokeTexture2"));
            textures.Add(Content.Load<Texture2D>("smokeTexture3"));
            textures.Add(Content.Load<Texture2D>("smokeTexture4"));

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

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

            explosionSound = Content.Load<SoundEffect>("explosionSound");
            tankFire = Content.Load<SoundEffect>("tankFire");
            background = Content.Load<Texture2D>("background");
            wall = Content.Load<Texture2D>("wall");

            wallPosition = new Vector2((ScreenWidth / 2) - (wall.Width / 2), ScreenHeight - wall.Height);

            // Create a bounding box for the wall object
            wallBox = new BoundingBox();
            wallBox.Max.X = wallPosition.X + wall.Width;
            wallBox.Max.Y = ScreenHeight;
            wallBox.Min.X = wallPosition.X;
            wallBox.Min.Y = ScreenHeight - wall.Height;

            // Load the player resources
            Animation playerAnimation1 = new Animation();
            playerAnimation1.Active = false;

            Texture2D playerTexture1 = Content.Load<Texture2D>("TankSheetNoCannon");
            playerAnimation1.Initialize(playerTexture1,Vector2.Zero,75,60,3,100,Color.White,1f,true);

            // Load the player resources
            Vector2 playerPosition1 = new Vector2(ScreenWidth - playerAnimation1.FrameWidth, ScreenHeight - playerAnimation1.FrameHeight);
            player1.Initialize(playerAnimation1, playerPosition1,Player.Orientation.facesLeft);
            player1.Cannon = Content.Load<Texture2D>("TankCannon");

            // Load the player resources
            Animation playerAnimation2 = new Animation();
            playerAnimation2.Active = false;

            Texture2D playerTexture2 = Content.Load<Texture2D>("TankSheetNoCannon");
            playerAnimation2.Initialize(playerTexture2, Vector2.Zero, 75, 60, 3, 100, Color.White, 1f, true);

            // Load the player resources
            Vector2 playerPosition2 = new Vector2(0, ScreenHeight - playerAnimation2.FrameHeight);
            player2.Initialize(playerAnimation2, playerPosition2, Player.Orientation.facesRight);
            player2.Cannon = Content.Load<Texture2D>("TankCannon");

            //Projectile.LoadContent(Content);

            soundtrack = Content.Load<Song>("SlugAssault");
            MediaPlayer.IsRepeating = true;
        }