Exemple #1
0
        public PongForm()
        {
            InitializeComponent();
            this.KeyPreview = true; // Permet de capturer les événements clavier

            // Lance le jeu
            this.Pong = new Pong(this.GameLoop);

            // Initialise les boutons de gestion des pointes
            this.buttonAddPointLeft.Click += (sender, args) => {
                this.Pong.Scores.AddLeft();
            };
            this.buttonAddPointRight.Click += (sender, args) => {
                this.Pong.Scores.AddRight();
            };

            // Initialise les boutons de gestion des intelligences
            var intelligences = new Intelligences.Intelligence[] {
                Intelligences.Computer,
                Intelligences.KeyboardPlayer,
                Intelligences.MousePlayer
            };

            this.comboJ1.SelectedIndex         = 0;
            this.comboJ1.SelectedIndexChanged += (sender, args) => {
                this.Pong.LeftRacquet.Intelligence
                    = intelligences[this.comboJ1.SelectedIndex];
            };
            this.comboJ2.SelectedIndex         = 0;
            this.comboJ2.SelectedIndexChanged += (sender, args) => {
                this.Pong.RightRacquet.Intelligence
                    = intelligences[this.comboJ2.SelectedIndex];
            };

            // Mets le jeu en pause au départ
            this.Pause = true;
        }
Exemple #2
0
        public PongForm()
        {
            InitializeComponent();
            this.KeyPreview = true; // Permet de capturer les événements clavier

            // Lance le jeu
            this.Pong = new Pong(this.GameLoop);

            // Initialise les boutons de gestion des pointes
            this.buttonAddPointLeft.Click += (sender, args) => {
                this.Pong.Scores.AddLeft();
            };
            this.buttonAddPointRight.Click += (sender, args) => {
                this.Pong.Scores.AddRight();
            };

            // Initialise les boutons de gestion des intelligences
            var intelligences = new Intelligences.Intelligence[] {
                Intelligences.Computer,
                Intelligences.KeyboardPlayer,
                Intelligences.MousePlayer
            };

            this.comboJ1.SelectedIndex = 0;
            this.comboJ1.SelectedIndexChanged += (sender, args) => {
                this.Pong.LeftRacquet.Intelligence
                    = intelligences[this.comboJ1.SelectedIndex];
            };
            this.comboJ2.SelectedIndex = 0;
            this.comboJ2.SelectedIndexChanged += (sender, args) => {
                this.Pong.RightRacquet.Intelligence
                    = intelligences[this.comboJ2.SelectedIndex];
            };

            // Mets le jeu en pause au départ
            this.Pause = true;
        }