Exemplo n.º 1
0
 public void spawn(int posX, int posY)
 {
     this.posX  = posX;
     this.posY  = posY;
     directionX = BallDirection.RandomDirection();
     directionY = BallDirection.Direction.Positive;
     Canvas.SetLeft(rectangle, posX);
     Canvas.SetTop(rectangle, posY);
 }
Exemplo n.º 2
0
 public void bounce(WallPlane plane)
 {
     if (plane.Equals(WallPlane.Vertical))
     {
         directionX = BallDirection.SwitchDirection(directionX);
     }
     if (plane.Equals(WallPlane.Horizontal))
     {
         directionY = BallDirection.SwitchDirection(directionY);
     }
 }
Exemplo n.º 3
0
        public Ball(Canvas canvas)
        {
            this.canvas = canvas;
            SolidColorBrush color = new SolidColorBrush();

            directionX       = BallDirection.RandomDirection();
            directionY       = BallDirection.Direction.Positive;
            color.Color      = Color.FromRgb(255, 0, 0);
            rectangle.Fill   = color;
            rectangle.Width  = size;
            rectangle.Height = size;
            canvas.Children.Add(rectangle);
        }