0 Members and 1 Guest are viewing this topic.
if (selector.wait(sf::milliseconds(10.f))) { // not enough time for server to be created with 0.1f // received something if (selector.isReady(socket)) { // Wait for a message char in[128]; std::size_t received; // am I using this? sf::IpAddress sender; sf::Packet playerData; // playerdata1 //playerdata2 sf::Packet bulletData; float playerXPosition; float playerYPosition; float clientXPosition; float clientYPosition; float clientBulletX; float clientBulletY; bool bulletShot; // third packet socket.receive(playerData, sender, port); // first packet - interpolate .. create scenario as tutorial //socket.receive(bulletData, sender, port); if (playerData >> playerXPosition >> playerYPosition >> bulletShot >> clientBulletX >> clientBulletY) { // if you are able to read clientXPosition = playerXPosition; clientYPosition = playerYPosition; player->setPosition(clientXPosition, clientYPosition); if (bulletShot) { // - might not need this // if not already received //bulletPtr->spawn(true); // once bullet spawned, should be taken care of both sides // bulletPtr->isAlive(); bulletPtr->setLocation(clientXPosition - 13.f, clientYPosition - 24.f); //bulletPtr->getSprite().move(0.f, -20); //if (!bulletShot) //{ // std::cout << "Bullet should be dead"; // bulletPtr->kill(); //} //else // clientbulletx and clientbullety // client window handled from both client and server what to do if bullet is alive } if (bulletShot && bulletShot!=NULL) { std::cout << "Satisfying both conditions" << std::endl; bulletPtr->kill(); } //else { // bulletPtr->spawn(false); //} }