예제 #1
0
        public Level(int levelId, int largeurEcran, int hauteurEcran, List <Texture2D> listeTexture)
        {
            this.hauteurEcran = hauteurEcran;
            this.largeurEcran = largeurEcran;
            int BarreSpeed = 1;

            this.levelId = levelId;
            this.barre   = new Barre(BarreSpeed, this);
            //Le nombre de balles du joueur
            this.balls  = 3;
            this.ball   = new Ball(this);
            this.Bricks = new List <Brick>();
            this.LoadLevel(hauteurEcran);
            this.initTexture(listeTexture);
        }
예제 #2
0
 /// <summary>
 /// Gère la collision entre la balle et la barre
 /// </summary>
 /// <param name="barre"></param>
 /// <returns>Un booleen qui permet de savoir si la collision a ou non eu lieu</returns>
 public bool Collision(Barre barre)
 {
     if (barre.getRectangle().Intersects(this.rectangle))
     {
         //Fait en sorte que la balle ne s'incruste pas dans la barre
         while (barre.getRectangle().Intersects(this.rectangle))
         {
             this.rectangle.X -= (int)this.ballDirection.X;
             this.rectangle.Y -= (int)this.ballDirection.Y;
         }
         //Calcule le point d'impact pour en tirer un coefficient permettant de renvoyer la balle dans l'angle voulu
         float milieuBarre      = this.level.getBarre().getRectangle().X + this.level.getBarre().getRectangle().Width / 2;
         float milieuBall       = this.rectangle.X + this.texture.Width / 2;
         float différenceImpact = (milieuBall - milieuBarre) / this.level.getBarre().getRectangle().Width / 2;
         this.ballDirection.X = 10 * différenceImpact;
         //Renvoie la balle vers le haut
         this.ballDirection.Y = -this.ballDirection.Y;
         return(true);
     }
     return(false);
 }
예제 #3
0
 public void setBarre(Barre barre)
 {
     this.barre = barre;
 }