Example #1
0
        //Логика Пули
        public override void Update(GameTime gameTime)
        {
            Vector2 direction = new Vector2();

            //если танк направлен ВЛЕВО
            if (Angle == (float)MathHelper.PiOver2)
            {
                direction += new Vector2(-Speed, 0);
            }


            //если танк направлен ВВЕРХ
            if (Angle == (float)MathHelper.Pi)
            {
                direction += new Vector2(0, -Speed);
            }


            //если танк направлен ВПРАВО
            if (Angle == -(float)MathHelper.PiOver2)
            {
                direction += new Vector2(Speed, 0);
            }


            //если танк направлен ВНИЗ
            if (Angle == (float)MathHelper.TwoPi)
            {
                direction += new Vector2(0, Speed);
            }


            if (direction.Length() > 0f)
            {
                Position += direction * (float)gameTime.ElapsedGameTime.TotalMilliseconds;
                if (HasCollisions(this))
                {
                    ShotHasCollisions = true;
                    BigBang bigbang = new BigBang(Position, spriteInfoBigBang)
                    {
                        Position         = new Vector2((Position.X + Height / 2) + Speed * (float)gameTime.ElapsedGameTime.TotalMilliseconds, Position.Y),
                        SpeedOfAnimation = 0.1f
                    };
                    BigBangObjects = bigbang;
                }
            }
        }
Example #2
0
        //Логика Пули
        public override void Update(GameTime gameTime)
        {


            Vector2 direction = new Vector2();      

            //если танк направлен ВЛЕВО
            if (Angle == (float)MathHelper.PiOver2)
            {
                direction += new Vector2(-Speed, 0);             
            }


            //если танк направлен ВВЕРХ
            if (Angle == (float)MathHelper.Pi)
            {
                direction += new Vector2(0, -Speed);
            }
            

            //если танк направлен ВПРАВО
            if (Angle == -(float)MathHelper.PiOver2)
            {
                direction += new Vector2(Speed, 0);
            }


            //если танк направлен ВНИЗ
            if (Angle == (float)MathHelper.TwoPi)
            {
                direction += new Vector2(0, Speed);
            }
            
            
            if (direction.Length() > 0f)
            {
                Position += direction * (float)gameTime.ElapsedGameTime.TotalMilliseconds;
                if (HasCollisions(this))
                {
                    ShotHasCollisions = true;
                    BigBang bigbang = new BigBang(Position, spriteInfoBigBang)
                    {
                        Position = new Vector2((Position.X + Height / 2) + Speed * (float)gameTime.ElapsedGameTime.TotalMilliseconds, Position.Y),
                        SpeedOfAnimation = 0.1f
                    };
                    BigBangObjects = bigbang;
                }
            }







        }