// подключение клиента void MyServer::incomingConnection(int handle) { //передаем дескрпитор сокета, указатель на сервер (для вызова его методов), // и стандартный параметр - parent MyClient *client = new MyClient(handle, this, this); //подключаем сигналы напрямую к виджету, если его передали в конструктор сервера if (widget != 0) { connect(client, SIGNAL(ConnectUser(QString)), widget, SLOT(AddUser(QString))); connect(client, SIGNAL(DisconnectUser(QString)), widget, SLOT(DelitUser(QString))); connect(client, SIGNAL(messageUser(QString,QString,QStringList)), widget, SLOT(MessagesUser(QString,QString,QStringList))); } connect(client, SIGNAL(DisconUser(MyClient*)), this, SLOT(RemoveUser(MyClient*))); clients.append(client); }
// paint event that calls all the draw functions and game mechanics void GameWindow::paintEvent(QPaintEvent *){ myPaint = new QPainter(this); draw.setPainter(myPaint); if(loaded){ for(size_t i = 0, n = CONSTANTS::B_ROWS; i < n; i++){ for(size_t j = 0, n = CONSTANTS::B_COLS; j < n; j++){ gameBoard[i][j].setPainter(myPaint); } } draw.drawBoard(level_G,waves[wave_num].started,loaded); draw.drawTop(loaded,money,lives,wave_num,speedChange); if(started){ spawnMen(); towerPhysics(); moveMen(); } draw.drawTowers(loaded,gameBoard); draw.drawMen(waves,wave_num); draw.drawHealth(waves,wave_num); draw.drawWebs(waves,wave_num); draw.drawAcorns(gameBoard); draw.drawUpgrade(gameBoard,towerClicked); draw.drawPick(towerPick,gameBoard); draw.drawMenu(started); checkWave(); checkLoss(); checkKills(); messageUser(); // stops timer if paused if(!started){ timer->stop(); } } }