Ejemplo n.º 1
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    GameWidget widget;
    widget.show();
    return a.exec();
}
Ejemplo n.º 2
0
void MainWindow::play()
{
  Game *g = new Game(ui->serverLineEdit->text(), 995,
         ui->usernameLineEdit->text(),
         ui->passwordLineEdit->text(),
         botPath, this);
  connect(g, SIGNAL(error(Game::Error)),
          this, SLOT(gameError(Game::Error)));
  connect(g, SIGNAL(started(const Player&)),
          this, SLOT(gameStarted(const Player&)));
  connect(g, SIGNAL(waiting(const Player&)),
          this, SLOT(gameWaiting(const Player&)));
  connect(g, SIGNAL(ended(bool)),
          this, SLOT(gameEnded(bool)));

  GameWidget *gw = new GameWidget("Waiting for opponent...", this);
  connect(g, SIGNAL(state(const QString&)),
          &(gw->gameScene()), SLOT(setGameState(const QString&)));
  connect(g, SIGNAL(started(const Player &)),
          gw, SLOT(gameStarted(const Player &)));
  gw->show();

  g->play();
}