예제 #1
0
        public void CreateBall()
        {
            //Creem una bola
            Ball ball = new Game.Ball(200, 325, 50, 50, Colors.Red);

            //Dibuixem la bola al taulell
            CanvasBalls.Children.Add(ball.BallDraw.ShapeBall);
            DrawBall(ball);

            //Guardem informació de la bola
            Balls.Add(ball);
            NumBalls++;
        }
예제 #2
0
        private void MainForm_Load(object sender, System.EventArgs e)
        {
            KeyPreview = true;

            Game.Settings settings = new Game.Settings(this)
            {
                BallDiameter  = 18,
                BallBackColor = System.Drawing.Color.Yellow,

                RacketSpeed           = 24,
                RacketWidth           = 120,
                RacketHeight          = 4,
                RacketInitialDistance = 30,
                RacketBackColor       = System.Drawing.Color.Green,

                BoardWidth           = 360,
                BoardHeight          = 480,
                BoardBorderThickness = 1,
                BoardBackColor       = System.Drawing.Color.Red,
                BoardBorderColor     = System.Drawing.Color.Blue,
            };

            Game.Board board =
                new Game.Board(scene: scenePictureBox, settings: settings);

            Game.Racket racket =
                new Game.Racket(scene: scenePictureBox, settings: settings, board: board);

            //string pathName =
            //	Infrastructure.Utility.GetPathName("Space.jpg");

            //if (System.IO.File.Exists(pathName))
            //{
            //	scenePictureBox.ImageLocation = pathName;
            //}

            Balls =
                new System.Collections.Generic.List <Game.Ball>();

            for (int index = 1; index <= 1; index++)
            {
                Game.Ball ball =
                    new Game.Ball(scene: scenePictureBox, settings: settings, board: board, racket: racket);

                Balls.Add(ball);
            }
        }
        public void CreateBall()
        {
            Color color = Colors.Green;

            if (playerId == 0)
            {
                color = Colors.Violet;
            }

            //Creem una bola
            Ball ball = new Game.Ball(200 + 200 * playerId, 325, 50, 50, color);

            //Dibuixem la bola al taulell
            CanvasBalls.Children.Add(ball.BallDraw.ShapeBall);
            DrawBall(ball);

            //Guardem informació de la bola
            Balls.Add(ball);
            NumBalls++;
        }