Shape(): draw_fill(true), draw_outline(true), outline_thickness(1.f), outline_color(255, 255, 255, 255), fill_color(150, 150, 150, 255) { vertices.setPrimitiveType(sf::Triangles); outline.setPrimitiveType(sf::LinesStrip); }
int main() { sf::TcpSocket socket; //sf::RenderWindow * win = new sf::RenderWindow(sf::VideoMode(200, 200), "QQ"); draw_arr.setPrimitiveType(sf::LinesStrip); int port = 8000; string name = "admin"; string pass = "******"; std::size_t received = 0; socket.connect("127.0.0.1", port); sf::Thread th(&workOnWin, &socket); char ns[1]; ns[0] = to_string(name.length()).c_str()[0]; socket.send(ns, 1); socket.send(name.c_str(), name.size() + 1); //system("pause"); socket.send(to_string(pass.length()).c_str(), 1); socket.send(pass.c_str(), pass.size() + 1); char ans[1]; sf::Int8 t; sf::Packet p; if (socket.receive(ans, sizeof(ans), received) == sf::Socket::Done) { if (static_cast <int> (ans[0]) == 0) { cout << "Welcome" << endl; int t; cin >> t; if (t == 5) { ans[0] = 5; if (socket.send(ans, 1) == sf::Socket::Done) { socket.receive(ans, 1, received); if (static_cast <int> (ans[0]) == 0) { cout << "BOARD CREATE" << endl; th.launch(); } } } if (t == 6) { ans[0] = 6; if (socket.send(ans, 1) == sf::Socket::Done) { socket.send(to_string(pass.length()).c_str(), 1); socket.send(name.c_str(), name.size() + 1); socket.receive(ans, 1, received); if (ans[0] == server_ok_code) { th.launch(); } } } } else {
bool load(const std::string& tileset, sf::Vector2u tileSize, const int* tiles, unsigned int width, unsigned int height) { // load the tileset texture if (!m_tileset.loadFromFile(tileset)) return false; // resize the vertex array to fit the level size m_vertices.setPrimitiveType(sf::Quads); m_vertices.resize(width * height * 4); // populate the vertex array, with one quad per tile for (unsigned int i = 0; i < width; ++i) for (unsigned int j = 0; j < height; ++j) { /* // get the current tile number int tileNumber = tiles[i + j * width]; // find its position in the tileset texture int tu = tileNumber % (m_tileset.getSize().x / tileSize.x); int tv = tileNumber / (m_tileset.getSize().x / tileSize.x); */ // get a pointer to the current tile's quad sf::Vertex* quad = &m_vertices[(i + j * width) * 4]; // define its 4 corners quad[0].position = sf::Vector2f(i * tileSize.x, j * tileSize.y); quad[1].position = sf::Vector2f((i + 1) * tileSize.x, j * tileSize.y); quad[2].position = sf::Vector2f((i + 1) * tileSize.x, (j + 1) * tileSize.y); quad[3].position = sf::Vector2f(i * tileSize.x, (j + 1) * tileSize.y); quad[0].texCoords = sf::Vector2f(0, 0); quad[1].texCoords = sf::Vector2f(0, 32); quad[2].texCoords = sf::Vector2f(32, 0); quad[3].texCoords = sf::Vector2f(32, 32); /* // define its 4 texture coordinates quad[0].texCoords = sf::Vector2f(tu * tileSize.x, tv * tileSize.y); quad[1].texCoords = sf::Vector2f((tu + 1) * tileSize.x, tv * tileSize.y); quad[2].texCoords = sf::Vector2f((tu + 1) * tileSize.x, (tv + 1) * tileSize.y); quad[3].texCoords = sf::Vector2f(tu * tileSize.x, (tv + 1) * tileSize.y); */ } return true; }