public void PadBounce(GameElement pad) { this.Pad = pad; for (int i = 0; i < Pad1.Hight; i++) { if (this.Ball.Position.Y == this.Pad.Position.Y + i) { switch (this.Ball.Direction.Dir) { case "diagonalUpLeft": this.Ball.Direction.Dir = "diagonalUpRight"; break; case "diagonalUpRight": this.Ball.Direction.Dir = "diagonalUpLeft"; break; case "diagonalDownLeft": this.Ball.Direction.Dir = "diagonalDownRight"; break; case "diagonalDownRight": this.Ball.Direction.Dir = "diagonalDownLeft"; break; } } } }
public GamePhysics(GameElement pad1, GameElement pad2, GameElement Ball, GameElement border) { this.Pad1 = pad1; this.Pad2 = pad2; this.Ball = Ball; this.Border = border; BallReset(); }
private void ManageDirection(GameElement element, GameElement element2, GameElement ball) { ConsoleKeyInfo key = new ConsoleKeyInfo(); key = Console.ReadKey(true); switch (key.Key) { // case ConsoleKey.A: // element.Direction.MoveLeft(); // break; // case ConsoleKey.D: // element.Direction.MoveRight(); // break; case ConsoleKey.W: element.Direction.MoveUp(); break; case ConsoleKey.S: element.Direction.MoveDown(); break; // case ConsoleKey.LeftArrow: // element2.Direction.MoveLeft(); // break; // case ConsoleKey.RightArrow: // element2.Direction.MoveRight(); // break; case ConsoleKey.UpArrow: element2.Direction.MoveUp(); break; case ConsoleKey.DownArrow: element2.Direction.MoveDown(); break; case ConsoleKey.Spacebar: ball.Direction.RandomDiag(); break; default: break; } }