public void construit() { // Affectaion aléatoire de briques au mur Random R = new Random(); for (int l = 0; l < 10; l++) { for (int c = 0; c < 20; c++) { switch (R.Next(11)) { case 1: mur[l, c] = new BriqueRetourNorme(); break; case 2: mur[l, c] = new BriqueBouleRapide(); break; case 3: mur[l, c] = new BriqueBarreRetrecire(); break; default: mur[l, c] = new Brique(); break; } mur[l, c].positionne(c * (mur[l, c].getLargeur() + 1), l * (mur[l, c].getHauteur() + 1)); } } nbBriques = 200; }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { int offsetX = 40; int offsetY = 40; TAILLEH = 1024; // this.GraphicsDevice.Viewport.Width à mettre + tard TAILLEV = 660; //this.GraphicsDevice.Viewport.Height à mettre + tard TAILLEBRIQUEX = 119; //trouver la bonne équation à mettre TAILLEBRIQUEY = 50; // same // TODO: Add your initialization logic here uneballe = new Balle(this, TAILLEH, TAILLEV); raquette = new Raquette(this, TAILLEH, TAILLEV); uneballe.Raquette = raquette; raquette.Balle = uneballe; mesBriques = new Brique[NBLIGNES, NBBRIQUES]; // On passe à la balle le tableau de briques int xpos, ypos; for (int x = 0; x < NBLIGNES; x++) { ypos = offsetY + x * TAILLEBRIQUEY; for (int y = 0; y < NBBRIQUES; y++) { xpos = offsetX + y * TAILLEBRIQUEX; Vector2 pos = new Vector2(xpos, ypos); // On mémorise les positions de la brique mesBriques[x, y] = new Brique(this, pos, new Vector2(TAILLEBRIQUEX, TAILLEBRIQUEY)); } } uneballe.MesBriquesballe = mesBriques; base.Initialize(); }