public void ToBeatOfTheBat(Bat bat) { if (Y + H >= bat.Y && X + W >= bat.X && X <= bat.X + bat.W) { speedY = -10; if (speedX > 0) { if (X + W >= bat.X && X <= bat.X + bat.W / 7) { speedX = -13; speedY = -7; } if (X + W >= bat.X + 20 && X <= bat.X + bat.W / 2) { speedX = -7; speedY = -13; } if (X + W >= bat.X + 65 && X <= bat.X + bat.W * 6 / 7) { speedX = 7; speedY = -13; } if (X + W >= bat.X + 110 && X <= bat.X + bat.W) { speedX = 13; speedY = -7; } } if (speedX < 0) { if (X + W >= bat.X && X <= bat.X + bat.W / 7) { speedX = -13; speedY = -7; } if (X + W >= bat.X + 20 && X <= bat.X + bat.W / 2) { speedX = -7; speedY = -13; } if (X + W >= bat.X + 65 && X <= bat.X + bat.W * 6 / 7) { speedX = 7; speedY = -13; } if (X + W >= bat.X + 110 && X <= bat.X + bat.W) { speedX = 13; speedY = -7; } } } }
public void Level_1(ConsoleGraphics graphics) { Field field = new Field(0xFFFFFF00, 0, 0, graphics.ClientWidth, graphics.ClientHeight); Bat bat = new Bat(graphics, 100, 600, 130, 30); Ball ball = new Ball(graphics, 20, 300, 20, 20); Target[] targets = new Target[20]; for (int i = 0; i < targets.Length; i++) { if (i % 2 == 0) { targets[i] = new Target(graphics, graphics.ClientWidth * (i + 1) / targets.Length - 32, 50, 32, 32); } else { targets[i] = new Target(graphics, graphics.ClientWidth * (i + 1) / targets.Length - 32, 25, 32, 32); } } while (ball.speedX != 0 && ball.count < targets.Length * 10) { field.RenderField(graphics); bat.Render(graphics); bat.UpdateBat(graphics); ball.Render(graphics); ball.ToBeatOfTheField(field); ball.ToBeatOfTheBat(bat); for (int i = 0; i < targets.Length; i++) { targets[i].Render(graphics); ball.ToBeatOfTheTargets(targets[i]); } graphics.FlipPages(); System.Threading.Thread.Sleep(10); } Console.Clear(); Console.WriteLine($"Your Score is {ball.count} points"); }