コード例 #1
0
        protected override void Initialize()
        {
            this._graphics.IsFullScreen              = false;
            this._graphics.PreferredBackBufferWidth  = 650;
            this._graphics.PreferredBackBufferHeight = 600;
            this._graphics.ApplyChanges();

            _keyboardState = Keyboard.GetState();

            raquette = new Raquette(this, "raquette");
            this.Components.Add(raquette);

            balle = new Balle(this, "balle", raquette);
            this.Components.Add(balle);

            murDeBrique = new MurDeBrique(this);
            this.Components.Add(murDeBrique);

            score    = 0;
            level    = 1;
            life     = 3;
            hudLevel = new Hud(this, "Level : 1", new Vector2(this.GraphicsDevice.PresentationParameters.BackBufferWidth - 180, 0));
            this.Components.Add(hudLevel);
            hudScore = new Hud(this, "Score : 0", new Vector2(this.GraphicsDevice.PresentationParameters.BackBufferWidth - 50, 0));
            this.Components.Add(hudScore);

            dernnierNiveau = 10;
            gameOver       = "";

            base.Initialize();
        }
コード例 #2
0
        public int startLevel(int maxLevel, Balle balle, Raquette raquette)
        {
            // On verifie si toutes les briques sont désactives
            List <Brique> briques_old = new List <Brique>();

            foreach (var brique in briques)
            {
                if (brique.active)
                {
                    briques_old.Add(brique);
                }
            }
            briques.Clear();
            briques = briques_old;

            // Si le nombre de brique est 0
            if (briques.Count == 0)
            {
                level++;
                raquette.reset();
                balle.reset();

                if (level > maxLevel)
                {
                    return(level);
                }

                int[,] level_position = getLevel("levels/" + level + ".txt");

                for (int x = 0; x < width; x++)
                {
                    for (int y = 0; y < height; y++)
                    {
                        if (level_position[x, y] == 1)
                        {
                            Brique brique = new Brique(base.Game, "brique", new Vector2(x * 70 + 9 * x + 13, y * 15 + 8 * y + 8));
                            briques.Add(brique);
                            this.Game.Components.Add(brique);
                        }
                        else if (level_position[x, y] == 2)
                        {
                            BriqueVitesse brique = new BriqueVitesse(base.Game, "briqueVitesse", new Vector2(x * 70 + 9 * x + 13, y * 15 + 8 * y + 8));
                            briques.Add(brique);
                            this.Game.Components.Add(brique);
                        }
                    }
                }
                if (level > 1 && level <= maxLevel)
                {
                    _ballBouncePartie.Play();
                }
            }

            return(level);
        }
コード例 #3
0
        public int detection_collision(Balle balle)
        {
            int point = 0;

            foreach (var brique in this.briques)
            {
                if (balle.collision_brique(brique, brique.multiplicateurVitesse))
                {
                    this.Game.Components.Remove(brique);
                    point += brique.points;
                }
            }
            return(point);
        }