Example #1
0
        // Cette fonction sert à savoir si la balle touche un bloc et renvoie un nombre de points
        public int toucheDuBloc(Bloc bloc)
        {
            int nb = 0;
            /**
             *Verifie si un des coins de la balle rentre dans la brique
             **/
            if (coinSupDroit(bloc) || CoinSupGauche(bloc) || CoinInfGauche(bloc) || CoinInfDroit(bloc))
            {
                /**
                * Si le centre de la balle est à gauche ou à droite de la brique
                **/

                if(coinSupDroit(bloc))
                  {
                      if(Location.X+ Width == bloc.Location.X && Location.Y<=bloc.Location.Y+bloc.Height && Location.Y>=bloc.Location.Y)
                          deplacementX *= -1;

                      if ((Location.X + Width <= bloc.Location.X + bloc.Width) && (Location.X+ Width >= bloc.Location.X) && (Location.Y == bloc.Location.Y+bloc.Height))
                          deplacementY *= -1;
                  }
                //attntion au else if
                else if (CoinSupGauche(bloc))
                {

                    if ((Location.X <= bloc.Location.X + bloc.Width) && (Location.X >= bloc.Location.X) && (Location.Y == bloc.Location.Y + bloc.Height))
                        deplacementY *= -1;

                    if (Location.X == bloc.Location.X + bloc.Width && Location.Y <= bloc.Location.Y + bloc.Height && Location.Y >= bloc.Location.Y)
                        deplacementX *= -1;
                }
                else if (CoinInfDroit(bloc))
                {
                    if (Location.X + Width == bloc.Location.X && Location.Y + Height <= bloc.Location.Y + bloc.Height && Location.Y >= bloc.Location.Y)
                        deplacementX *= -1;

                    if ((Location.X + Width <= bloc.Location.X + bloc.Width) && (Location.X + Width >= bloc.Location.X) && (Location.Y + Height == bloc.Location.Y))
                        deplacementY *= -1;
                }
                else if(CoinInfGauche(bloc))
                {
                    if ((Location.X <= bloc.Location.X + bloc.Width) && (Location.X >= bloc.Location.X) && (Location.Y +Height== bloc.Location.Y ))
                        deplacementY *= -1;

                    if (Location.X == bloc.Location.X + bloc.Width && Location.Y+Height <= bloc.Location.Y + bloc.Height && Location.Y+Height >= bloc.Location.Y)
                        deplacementX *= -1;
                }

                nb = Constantes.SCORE_BRIQUE;
                bloc.Visible = false;
                toucheBloc = true;
            }
            return nb;
        }
Example #2
0
        // Cette action sert à mettre en place les blocs du jeu
        public void miseEnPlaceDesBlocs()
        {
            blocs = new Bloc[Constantes.NB_BLOCS_HAUTEUR][];

            for (int i = 0; i < Constantes.NB_BLOCS_HAUTEUR; i++)
            {
                blocs[i] = new Bloc[Constantes.NB_BLOCS_LARGEUR];

                for (int j = 0; j < Constantes.NB_BLOCS_LARGEUR; j++)
                {
                    this.blocs[i][j] = new Bloc(i, j, images_blocs[i]);
                    this.Controls.Add(this.blocs[i][j]);
                }
            }
        }
Example #3
0
 private bool coinSupDroit(Bloc bloc)
 {
     bool rentre = false;
     if (((bloc.Location.Y <= this.Location.Y) && (this.Location.Y <= bloc.Location.Y + bloc.Height)) &&
         ((bloc.Location.X <= Location.X + Width) && (Location.X + Width <= bloc.Location.X + bloc.Width)))
     {
         rentre = true;
     }
     return rentre;
 }
Example #4
0
 private bool CoinSupGauche(Bloc bloc)
 {
     bool rentre = false;
     if (((bloc.Location.Y <= this.Location.Y) && (this.Location.Y <= bloc.Location.Y + bloc.Height)) &&
         ((bloc.Location.X <= this.Location.X) && (this.Location.X <= bloc.Location.X + bloc.Width)))
     {
         rentre = true;
     }
     return rentre;
 }
Example #5
0
 // Ces fonctions servent à savoir si la balle touche respectivement les coins inférieur droit, inférieur gauche, supérieur gauche et supérieur droit
 // du bloc passé en paramètre
 private bool CoinInfDroit(Bloc bloc)
 {
     bool rentre = false;
     if (((bloc.Location.Y <= this.Location.Y + this.Height) && (this.Location.Y + this.Height <= bloc.Location.Y + bloc.Height)) &&
         ((bloc.Location.X <= this.Location.X + this.Width) && (this.Location.X +Width<= bloc.Location.X + bloc.Width)))
     {
         rentre = true;
     }
     return rentre;
 }