Ejemplo n.º 1
0
 private void btnStart_Click(object sender, EventArgs e)
 {
     if (sgv != null)
     {
         DisposeGame();
     }
     try
     {
         Snake.Debug("create view");
         sgv = new SnakeGameView(40, 40);
         Snake.Debug("create model");
         sgm = new SnakeGameModel(40, 40);
         Snake.Debug("create controller");
         sgc = new SnakeGameController();
         Snake.Debug("attach model");
         sgc.AddModel(sgm);
         Snake.Debug("attach view");
         sgm.AttachObserver(sgv);
         sgm.AttachObserver(this);
         Snake.Debug("set controller");
         sgv.setController(sgc);
         Snake.Debug("Start the controller");
         sgc.Start();
         sgv.Run();
         SnakeGameModel.Speed = 1;
     } catch
     {
         Snake.Debug("Error starting game");
     }
 }
Ejemplo n.º 2
0
 private void RunGame()
 {
     Snake.Debug("create view");
     sgv = new SnakeGameView(40, 40);
     Snake.Debug("create model");
     sgm = new SnakeGameModel(40, 40);
     Snake.Debug("create controller");
     sgc = new SnakeGameController();
     Snake.Debug("attach model");
     sgc.AddModel(sgm);
     Snake.Debug("attach view");
     sgm.AttachObserver(sgv);
     sgm.AttachObserver(this);
     Snake.Debug("set controller");
     sgv.setController(sgc);
     Snake.Debug("Start the controller");
     sgc.Start();
     sgv.Run();
 }