Example #1
0
        /// <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()
        {
            // TODO: Add your initialization logic here
            Joueur1 = new Player();
            Joueur2 = new Player();
            Ball    = new Balle(HEIGHT, WIDTH);
            base.Initialize();

            MaLatence = new Thread(new ThreadStart(DrawPing));
            MaLatence.Start();
            CreationParty  = new Thread(new ThreadStart(IsFirstPlayer));
            BoulotJ1thread = new Thread(new ThreadStart(BoulotJ1));
            BoulotJ2thread = new Thread(new ThreadStart(BoulotJ2));
        }
Example #2
0
        /// <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()
        {
            Globals.largeurFenetre = Window.ClientBounds.Width;
            Globals.hauteurFenetre = Window.ClientBounds.Height;
            Globals.Random         = new Random();
            balle    = new Balle();
            j1       = new Raquette(1);
            j2       = new Raquette(2);
            isPaused = true;
            //Initialisation des sprites
            balle.Initialize();
            j1.Initialize();
            j2.Initialize();

            //Initialisation du jeu
            base.Initialize();
        }
Example #3
0
        /// <summary>
        /// Créé et initialise toutes les variables du jeu
        /// </summary>
        protected override void Initialize()
        {
            this.graphics.PreferredBackBufferWidth = 1280;
            this.graphics.PreferredBackBufferHeight = 720;
            this.graphics.IsFullScreen = true;
            this.graphics.ApplyChanges();

            IsMouseVisible = false;

            this.Window.Title = "Polochong";
            this.Window.AllowUserResizing = true;
            MediaPlayer.IsRepeating = true;

            _boutonSolo = new Bouton(Window.ClientBounds.Width, Window.ClientBounds.Height, 1);
            _boutonSolo.Initialize();

            _boutonSolo2 = new Bouton(Window.ClientBounds.Width, Window.ClientBounds.Height, 1);
            _boutonSolo2.Initialize();

            _boutonVersus = new Bouton(Window.ClientBounds.Width, Window.ClientBounds.Height, 3);
            _boutonVersus.Initialize();

            _boutonVersus2 = new Bouton(Window.ClientBounds.Width, Window.ClientBounds.Height, 3);
            _boutonVersus2.Initialize();

            _boutonMulti = new Bouton(Window.ClientBounds.Width, Window.ClientBounds.Height, 2);
            _boutonMulti.Initialize();

            _boutonMulti2 = new Bouton(Window.ClientBounds.Width, Window.ClientBounds.Height, 2);
            _boutonMulti2.Initialize();

            _boutonOption = new Bouton(Window.ClientBounds.Width, Window.ClientBounds.Height, 4);
            _boutonOption.Initialize();

            _boutonOption2 = new Bouton(Window.ClientBounds.Width, Window.ClientBounds.Height, 4);
            _boutonOption2.Initialize();

            _easyMode = new Bouton(Window.ClientBounds.Width, Window.ClientBounds.Height, 5);
            _easyMode.Initialize();

            _easyMode2 = new Bouton(Window.ClientBounds.Width, Window.ClientBounds.Height, 5);
            _easyMode2.Initialize();

            _normalMode = new Bouton(Window.ClientBounds.Width, Window.ClientBounds.Height, 6);
            _normalMode.Initialize();

            _normalMode2 = new Bouton(Window.ClientBounds.Width, Window.ClientBounds.Height, 6);
            _normalMode2.Initialize();

            _hardMode = new Bouton(Window.ClientBounds.Width, Window.ClientBounds.Height, 7);
            _hardMode.Initialize();

            _hardMode2 = new Bouton(Window.ClientBounds.Width, Window.ClientBounds.Height, 7);
            _hardMode2.Initialize();

            _boutonEject = new Bouton(Window.ClientBounds.Width, Window.ClientBounds.Height, 8);
            _boutonEject.Initialize();

            _boutonEject2 = new Bouton(Window.ClientBounds.Width, Window.ClientBounds.Height, 8);
            _boutonEject2.Initialize();

            _muet = new Bouton(Window.ClientBounds.Width, Window.ClientBounds.Height, 9);
            _muet.Initialize();

            _unmuet = new Bouton(Window.ClientBounds.Width, Window.ClientBounds.Height, 10);
            _unmuet.Initialize();

            _ball = new Balle(Window.ClientBounds.Width, Window.ClientBounds.Height);
            _ball.Initialize();

            _batP1 = new Raquette(Window.ClientBounds.Width, Window.ClientBounds.Height, 1);
            _batP1.Initialize();

            _batP2 = new Raquette(Window.ClientBounds.Width, Window.ClientBounds.Height, 2);
            _batP2.Initialize();

            _batIA = new Raquette(Window.ClientBounds.Width, Window.ClientBounds.Height, 3);
            _batIA.Initialize();

            _Title = new Raquette(Window.ClientBounds.Width, Window.ClientBounds.Height, 0);
            _Title.Initialize();

            _timer = DateTime.Now;

            MediaPlayer.Volume = 0.2f;
            _isPaused = true;
            _ismuted = false;

            base.Initialize();
        }
Example #4
0
        /// <summary>
        /// Gère l'intelligence artificielle, avec 3 niveaux de difficulté
        /// </summary>
        /// <param name="lvl">Niveau de difficulté</param>
        private void Ia(Balle _balle, Raquette _raquette)
        {
            if (lvl == 1) // Mode facile
            {
                if (_balle.Position.X > 730)
                {
                    if (_raquette.Position.Y < _balle.Position.Y - 10)
                    {
                        _raquette.Direction = Vector2.UnitY;
                        _raquette.Speed = 0.5f;
                        if (_raquette.Position.Y > 450)
                        { _raquette.Speed = 0f; }

                    }

                    if (_raquette.Position.Y > _balle.Position.Y - 10 && _balle.Position.Y > 70)
                    {
                        _raquette.Direction = -Vector2.UnitY;
                        _raquette.Speed = 0.5f;

                    }

                }
                else _raquette.Speed = 0f;
            }

            if (lvl == 2) // Mode normal
            {
                if (_balle.Position.X > 500)
                {
                    if (_raquette.Position.Y < _balle.Position.Y - 10)
                    {
                        _raquette.Direction = Vector2.UnitY;
                        _raquette.Speed = 0.5f;
                        if (_raquette.Position.Y > 450)
                        { _raquette.Speed = 0f; }

                    }

                    if (_raquette.Position.Y > _balle.Position.Y - 10 && _balle.Position.Y > 70)
                    {
                        _raquette.Direction = -Vector2.UnitY;
                        _raquette.Speed = 0.5f;

                    }

                }
                else _raquette.Speed = 0f;
            }

            if (lvl == 3)  // Mode difficile
            {

                if (_raquette.Position.Y < _balle.Position.Y - 10)
                {
                    _raquette.Direction = Vector2.UnitY;
                    _raquette.Speed = 0.6f;
                    if (_raquette.Position.Y > 450)
                    { _raquette.Speed = 0f; }

                }

                if (_raquette.Position.Y > _balle.Position.Y - 10 && _balle.Position.Y > 70)
                {
                    _raquette.Direction = -Vector2.UnitY;
                    _raquette.Speed = 0.6f;

                }
            }
        }
Example #5
0
        private void Pong_Load(object sender, EventArgs e)
        {
            Balle bille = new Balle(new Point(29, 29));

            this.Controls.Add(bille.BalleToPictureBox());
        }
Example #6
0
        /// <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()
        {
            Globals.largeurFenetre = Window.ClientBounds.Width;
            Globals.hauteurFenetre = Window.ClientBounds.Height;
            Globals.Random = new Random();
            balle = new Balle();
            j1 = new Raquette(1);
            j2 = new Raquette(2);
            isPaused = true;
            //Initialisation des sprites
            balle.Initialize();
            j1.Initialize();
            j2.Initialize();

            //Initialisation du jeu
            base.Initialize();
        }