private void createGamefield(Canvas c) { // right player = player one int height_rectangles = 120; int width_rectangles = 20; POne = new Player((int)c.ActualWidth-(50 + width_rectangles), (int)c.ActualHeight / 2-60); POne.setMin(0); POne.setMax((int)c.ActualHeight - height_rectangles); playerOne = new Rectangle(); playerOne.Fill = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 0, 0, 0)); playerOne.Width = width_rectangles; playerOne.Height = height_rectangles; // left player = player two PTwo = new Player(50,(int)c.ActualHeight/2-60); PTwo.setMin(0); PTwo.setMax((int)c.ActualHeight - height_rectangles); playerTwo = new Rectangle(); playerTwo.Fill = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 0, 0, 0)); playerTwo.Width = width_rectangles; playerTwo.Height = height_rectangles; // draw ´both player to canvas this.playField.Children.Add(playerTwo); this.playField.Children.Add(playerOne); // creats and draws ball to canvas ball.Fill = new SolidColorBrush(Windows.UI.Color.FromArgb(255,255,255,0)); ball.Width = 20; ball.Height = 20; // ball.SetValue(Canvas.LeftProperty, 250); // ball.SetValue(Canvas.TopProperty, 150); moving_ball = new Ball(350,250); moving_ball.setMax(500-20); moving_ball.setMin(0); this.playField.Children.Add(ball); }
private void createGamefield(Canvas c) { // right player = player one // int height_rectangles = 80; // int width_rectangles = 20; POne = new Player((int)c.ActualWidth-(50 + width_rectangles), (int)c.ActualHeight / 2-60); POne.setMin(0); POne.setMax((int)c.ActualHeight - height_rectangles); playerOne = new Rectangle(); playerOne.Fill = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 255, 0, 0)); playerOne.Width = width_rectangles; playerOne.Height = height_rectangles; // left player = player two PTwo = new Player(50,(int)c.ActualHeight/2-60); PTwo.setMin(0); PTwo.setMax((int)c.ActualHeight - height_rectangles); playerTwo = new Rectangle(); playerTwo.Fill = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 255, 0, 0)); playerTwo.Width = width_rectangles; playerTwo.Height = height_rectangles; // draw obstacles obstacleOne = new Obstacle((int)c.ActualWidth / 2 - 10, (int)c.ActualHeight / 2 - 40); obstacleOne.min=0; obstacleOne.max=(int)c.ActualHeight - height_rectangles; obstacle1 = new Rectangle(); obstacle1.Fill = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 123, 23, 123)); obstacle1.Width = width_rectangles; obstacle1.Height = height_rectangles; // Canvas.SetLeft(obstacle1, 300); // Canvas.SetTop(obstacle1, 200); // obstacle1.SetValue(Canvas.LeftProperty, 300); // obstacle1.SetValue(Canvas.TopProperty, 300); this.level1.Children.Add(obstacle1); // draw ´both player to canvas this.level1.Children.Add(playerTwo); this.level1.Children.Add(playerOne); // creats and draws ball to canvas ball.Fill = new SolidColorBrush(Windows.UI.Color.FromArgb(255,255,255,0)); ball.Width = 20; ball.Height = 20; // ball.SetValue(Canvas.LeftProperty, 250); // ball.SetValue(Canvas.TopProperty, 150); moving_ball = new Ball(400,250); moving_ball.setMax(500-20); moving_ball.setMin(0); this.level1.Children.Add(ball); }