public MainWindow() { InitializeComponent(); center = new Point(Canvas.Width / 2, Canvas.Height / 2); playerPlatform = new PlayerPlatform(center); ball = new Ball(playerPlatform.radius, center); SetBackground(Color.LightSeaGreen); SetBackgroundMainMenu(Color.LightSeaGreen); enemies1 = new Enemies(7, 50, new Pen(new SolidBrush(Color.FromArgb(200, 255, 186, 2)), 25), center, true, (float)0.2, 7); enemies2 = new Enemies(4, 90, new Pen(new SolidBrush(Color.FromArgb(200, 217, 68, 48)), 20), center, false, (float)0.3, 5); enemies3 = new Enemies(8, 120, new Pen(new SolidBrush(Color.FromArgb(200, 23, 109, 237)), 22), center, true, (float)0.4, 4); enemies4 = new Enemies(10, 145, new Pen(new SolidBrush(Color.FromArgb(200, 0, 155, 87)), 16), center, false, (float)0.5, 1); ball.speed = 3; playerPlatform.sweepAngle = 40; colorScheme = new ColorScheme(ColourScheme, new[] { Color.LightSeaGreen, Color.FromArgb(114, 34, 114), Color.FromArgb(67, 67, 170), Color.FromArgb(201, 68, 68), Color.FromArgb(34, 102, 34), Color.Firebrick, Color.FromArgb(39, 28, 39), Color.FromArgb(99, 55, 99), Color.Beige, Color.FromArgb(21, 21, 66), Color.FromArgb(44, 120, 120), Color.FromArgb(187, 187, 92), Color.FromArgb(166, 166, 212), Color.FromArgb(32, 189, 189), Color.FromArgb(200, 200, 40), Color.FromArgb(77, 77, 46), Color.FromArgb(190, 55, 55), Color.FromArgb(58, 58, 185), Color.FromArgb(112, 62, 62), Color.FromArgb(54, 54, 60)}); colorScheme.Draw(ColourScheme.CreateGraphics()); }
public void UpdateOnPlatform(float newMouseAngle, PlayerPlatform playerPlatform) { location.X = (canvasRadius - playerPlatform.penPlatform.Width / 2 - diametr / 2) * (float)Math.Cos((Math.PI * newMouseAngle) / 180); location.Y = (canvasRadius - playerPlatform.penPlatform.Width / 2 - diametr / 2) * (float)Math.Sin((Math.PI * newMouseAngle) / 180); location.X += center.X -diametr / 2; location.Y += center.Y -diametr / 2; angle = newMouseAngle; }
public void Click(float newMouseAngle, PlayerPlatform playerPlatform) { UpdateOnPlatform(newMouseAngle, playerPlatform); started = true; location.X -= 10 * (float)Math.Cos((Math.PI * angle) / 180); location.Y -= 10 * (float)Math.Sin((Math.PI * angle) / 180); if (MainWindow.AngleTo360DegreeSystem(playerPlatform.startAngle + playerPlatform.sweepAngle) - playerPlatform.startAngle != playerPlatform.sweepAngle) shiftAngle = 5; else shiftAngle = 0; score_subtrahend = 4; }
public void Move(PlayerPlatform playerPlatform) { if (started) { location.X -= speed * (float)Math.Cos((Math.PI * angle + shiftAngle) / 180); location.Y -= speed * (float)Math.Sin((Math.PI * angle + shiftAngle) / 180); movingAngle = MainWindow.AngleTo360DegreeSystem(((float)Math.Atan2(location.Y - center.Y, location.X - center.X) * 180) / (float)Math.PI); locationRadius = (float)Math.Sqrt(Math.Pow(location.X + diametr/2 - center.X, 2) + Math.Pow(location.Y + diametr/2 - center.Y, 2)); if ((int)(playerPlatform.endAngle - playerPlatform.startAngle) == (int)playerPlatform.sweepAngle || (int)(playerPlatform.endAngle - playerPlatform.startAngle) == (int)playerPlatform.sweepAngle-1) { if (locationRadius + diametr / 2 >= playerPlatform.locationRadius && locationRadius + diametr / 2 < playerPlatform.locationRadius + playerPlatform.penPlatform.Width/2 && movingAngle > playerPlatform.startAngle && movingAngle < playerPlatform.endAngle) { location.X += speed / Math.Abs(speed) * 10 * (float)Math.Cos((Math.PI * angle + shiftAngle) / 180); location.Y += speed / Math.Abs(speed) * 10 * (float)Math.Sin((Math.PI * angle + shiftAngle) / 180); speed *= -1; angle = angle/Math.Abs(angle) * playerPlatform.centerAngle; shiftAngle = 4*(playerPlatform.centerAngle - movingAngle); } } else { if (locationRadius + diametr / 2 >= playerPlatform.locationRadius && ((movingAngle < 360 && movingAngle > playerPlatform.startAngle) || (movingAngle > 0 && movingAngle < playerPlatform.endAngle))) { speed *= -1; } } if (locationRadius + diametr / 2 >= canvasRadius) { MainWindow.score -= score_subtrahend; score_subtrahend = 0; } if (locationRadius + diametr / 2 >= canvasRadius + 300) { started = false; fault++; } } }