Exemple #1
0
        public Game(Canvas canvas, Fence fence, Ball ball, Player[] players, TextBlock result)
        {
            this.canvas = canvas;
            this.fence = fence;
            this.ball = ball;
            this.players = players;
            this.result = result;

            timer = new DispatcherTimer();
            timer.Interval = new System.TimeSpan(speed);
            timer.Tick += new System.EventHandler(timer_Tick);

            wait = new DispatcherTimer();
            wait.Tick += new System.EventHandler(wait_Tick);
            wait.Interval = new TimeSpan(0, 0, 0, 0, timeWait);

            fence.SetLeft((canvas.RealWidth() - fence.Width) / 2.0);
            fence.SetTop(canvas.RealHeight() - fence.Height);

            Reset();
        }