Example #1
0
 // collision objet missible
 public bool Collision_as_mis(objet aster, sripte_V sprite)
 {
     for (int i = 0; i < sprite.bulletL.Count; ++i)
         if (aster.rectangle_C.Intersects(sprite.bulletL[i].rectangle_C))
         {
             sprite.bulletL.RemoveAt(i);
             sprite.bulletL[i].existe = false;
             return true;
         }
     return false;
 }
Example #2
0
        public void Update(objet sprite, ref KeyboardState keyboard)
        {
            for (int i = 0; i < ia_manage.Count; ++i)
            {
               ia_manage[i]. Update_rec_collision();
               if (ia_manage[i].vie >= 0 && !ia_manage[i].attaque && this.ia_manage[i].rectangle_C.X < 1.2f * window_W && this.ia_manage[i].rectangle_C.X > -0.2f * window_W)
                {

                    if (ia_manage[i].tombe)
                        ia_manage[i].rectangle.Y += poid;

                    if (ia_manage[i].rectangle_C.Center.X - ia_manage[i].longueur_attaque > sprite.rectangle_C.Center.X)
                    {
                        ia_manage[i].dir = -1;
                        ia_manage[i].Speed = ia_manage[i].normalspeed;
                    }
                    else
                        if (ia_manage[i].rectangle_C.Center.X + ia_manage[i].longueur_attaque < sprite.rectangle_C.Center.X)
                        {
                            ia_manage[i].dir = 1;
                            ia_manage[i].Speed  = ia_manage[i].normalspeed;
                        }
                        else
                            ia_manage[i].Speed  = 0;

                    ia_manage[i].rectangle.X += ia_manage[i].dir * ia_manage[i].Speed ;

                }
                if (keyboard.IsKeyDown(Keys.Right))
                    ia_manage[i].rectangle.X -= front_sc;
                if (keyboard.IsKeyDown(Keys.Left))
                    ia_manage[i].rectangle.X += front_sc;

                //  if (rectangle.Center.Y  < sprite.rectangle.Center.Y)
                //    rectangle.Y += 1;
                //else
                //  rectangle.Y -= 1;
                if (ia_manage[i].dir == 1)
                {
                    ia_manage[i].decalageX  = 43;
                    this.ia_manage[i].Effects = SpriteEffects.None;
                    mov(ref i);

                }
                else
                {
                    ia_manage[i].decalageX  = 25;
                   ia_manage[i] .Effects = SpriteEffects.FlipHorizontally;
                    mov (ref i );
                }

            }
        }
Example #3
0
        /*

        public vaisseau_IA(Texture2D _texture, Rectangle n_rectangle, ContentManager Content, int height, int width, int _speed)
        {
            this.rectangle = n_rectangle;
            this._texture = _texture;
            this._speed = _speed;
            //def rectangle collision
            rectangle_Colision = rectangle;
            rectangle_Colision.Width = largeurX;
            rectangle_Colision.Height = hauteurY;
            decallageX = 0;
            decallageY = 0;
        }

        public void moveUp()
        {
            rectangle.Y -= _speed;
            rectangle_Colision.Y = rectangle.Y + decallageY;
        }
        public void moveDown()
        {
            rectangle.Y += _speed;
            rectangle_Colision.Y = rectangle.Y + decallageY;
        }
        public void moveRight()
        {
            rectangle.X += _speed;
            rectangle_Colision.X = rectangle.X + decallageX;
        }
        public void moveleft()
        {
            rectangle.Y -= _speed;
            rectangle_Colision.X = rectangle.X + decallageX;
        }

        */
        protected Vector2 vise(objet sprt)
        {
            Vector2 _vecteur;
            _vecteur.X = -rectangle.Center.X + sprt.rectangle.Center.X;
            _vecteur.Y = rectangle.Center.Y - sprt.rectangle.Center.Y;
            _vecteur.Normalize();
            return (_vecteur);
        }