public override void RespondToCollision(CollisionData collisionData) { this.IsDestroyed = true; Console.Beep(); IRenderer renderer = new ConsoleRenderer(50, 79); IUserInterface keyboard = new KeyboardInterface(); Engine endGame=new Engine(renderer, keyboard); Stopwatch pointless=new Stopwatch(); endGame.Run(pointless,true); }
static void Main(string[] args) { Stopwatch stopWatch = new Stopwatch(); Console.SetWindowSize(Console.LargestWindowWidth, Console.LargestWindowHeight); IRenderer renderer = new ConsoleRenderer(WorldRows, WorldCols); IUserInterface keyboard = new KeyboardInterface(); Engine gameEngine = new Engine(renderer, keyboard); Random random = new Random(); Spaceship theSpace = new Spaceship(new MatrixCoordinates(WorldRows - 3, WorldCols / 2 - 1), RacketLength); gameEngine.AddObject(theSpace); keyboard.OnActionPressed += (sender, eventInfo) => { Bullet newBullet = new Bullet(new MatrixCoordinates(theSpace.TopLeft.Row + 4, theSpace.TopLeft.Col + 3), new MatrixCoordinates(-5, 0)); gameEngine.AddObject(newBullet); int randomNumber = random.Next(0, 3); if (randomNumber % 3 == 0) { AlienBullet theAlienBullet = new AlienBullet(new MatrixCoordinates(0, random.Next(2,75))); gameEngine.AddObject(theAlienBullet); } }; keyboard.OnLeftPressed += (sender, eventInfo) => { //startCol gameEngine.MovePlayerSpaceshipLeft(5); int randomNumber = random.Next(0, 3); if (randomNumber % 3 == 0) { AlienBullet theAlienBullet = new AlienBullet(new MatrixCoordinates(0, random.Next(2, 75))); gameEngine.AddObject(theAlienBullet); } }; keyboard.OnRightPressed += (sender, eventInfo) => { //worldCols gameEngine.MovePlayerSpaceshipRight(WorldCols); int randomNumber = random.Next(0, 3); if (randomNumber % 3 == 0) { AlienBullet theAlienBullet = new AlienBullet(new MatrixCoordinates(0, random.Next(2, 75))); gameEngine.AddObject(theAlienBullet); } }; keyboard.OnStartPressed += (sender, eventInfo) => { stopWatch.Start(); Bullet newBullet = new Bullet(new MatrixCoordinates(theSpace.TopLeft.Row + 4, theSpace.TopLeft.Col + 3), new MatrixCoordinates(-5, 0)); gameEngine.AddObject(newBullet); //gameEngine.CalculatePoints(); }; //Stopwatch timer = new Stopwatch(); //timer.Start(); //if (timer.Elapsed.Seconds == 20) //{ // AlienBullet theAlienBullet = new AlienBullet(new MatrixCoordinates(0, 30)); // gameEngine.AddObject(theAlienBullet); // // timer.Restart(); //} Initialize(gameEngine); gameEngine.Run(stopWatch, false); }