Example #1
0
        public void DrawPong(CanvasDrawingSession drawingSession)
        {
            pict.Draw(drawingSession);
            leftWall.Draw(drawingSession);
            rightWall.Draw(drawingSession);
            topWall.Draw(drawingSession);
            userPaddle.Draw(drawingSession); ball.Draw(drawingSession);
            //userPaddle2.Draw(drawingSession);
            int c = 1;

            while (i < 70)
            {
                for (int j = 350; j < 460 + blocks.height;)
                {
                    for (int x = leftWall.X + leftWall.width + 3; x < rightWall.X - blocks.width; x = blocks.width + x + 5)
                    {
                        blocks        = new blocksets();
                        blocks.X      = x;
                        blocks.Y      = j;
                        blocks.width  = 50;
                        blocks.height = 20;
                        if (c == 1)
                        {
                            blocks.color = Colors.Red;
                        }
                        if (c == 2)
                        {
                            blocks.color = Colors.Orange;
                        }
                        if (c == 3)
                        {
                            blocks.color = Colors.Yellow;
                        }
                        if (c == 4)
                        {
                            blocks.color = Colors.YellowGreen;
                        }
                        if (c == 5)
                        {
                            blocks.color = Colors.Green;
                        }

                        blockset.SetValue(blocks, i); i++;
                    }
                    j = (c * blocks.height) + 350 + (c * 6);
                    c++;
                    if (c == 6)
                    {
                    }
                }
            }
            for (i = 0; i < 70; i++)
            {
                if (blockset[i] != null)
                {
                    blockset[i].Draw(drawingSession);
                }
            }
            ball.Draw(drawingSession);
        }
Example #2
0
        public Pong()
        {
            pict = new Picture
            {
                X = 900,
                Y = 300
            };

            gameOver = false;
            ball     = new Ball
            {
                X         = 400,
                Y         = 730,
                Radius    = 5,
                color     = Colors.Gold,
                M_L       = Convert.ToBoolean(new Random().Next(1000)),
                M_D       = Convert.ToBoolean(false),
                ballSpeed = 2
            };
            IsUPM_L  = false;
            IsUPM_R  = false;
            leftWall = new Rectangle
            {
                X      = 10,
                Y      = 50,
                width  = 10,
                Height = 700,
                color  = Colors.Green
            };
            rightWall = new Rectangle
            {
                X      = 790,
                Y      = 50,
                width  = 10,
                Height = 700,
                color  = Colors.Green
            };
            topWall = new Rectangle
            {
                X      = 10,
                Y      = 50,
                width  = 780,
                Height = 10,
                color  = Colors.Green
            };
            blocks = new blocksets
            {
                X      = 20,
                Y      = 350,
                width  = 50,
                height = 20,
                color  = Colors.Red
            };
            userPaddle = new Rectangle
            {
                X      = 400,
                Y      = 750,
                width  = 70,
                Height = 10,
                color  = Colors.Blue
            };
            //userPaddle2 = new Rectangle
            //{
            //    X = 20,
            //    Y = 500,
            //    width = 50,
            //    Height = 10,
            //    color = Colors.Blue
            //};
        }