Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void RoomController::LoadRoom()
- {
- //First parse the string from the specific room
- //For now, use the given room
- int roomID = 0;
- string room = rooms[roomID];
- istringstream roomParser(room);
- string tile;
- //While we still have numbers in the list, go through it int by int until we reach the end
- while (getline(roomParser, tile, ','))
- {
- //Get the current tile
- int currentTile = stoi(tile);
- //Get the position in the tilesheet
- int tileXPos = tilesetCoordinates[currentTile].x;
- int tileYPos = tilesetCoordinates[currentTile].y;
- //Get a pointer to the current tile's quad
- Vertex* quad = ¤tRoom[(xIterator + yIterator * roomXSize) * 4];
- //Set the positions of each of the 4 vertices
- int x1 = 8 * xIterator;
- int y1 = 8 * yIterator;
- int x2 = 8 * (1 + xIterator);
- int y2 = 8 * (1 + yIterator);
- quad[0].position = Vector2f(x1, y1);
- quad[1].position = Vector2f(x2, y1);
- quad[2].position = Vector2f(x2, y2);
- quad[3].position = Vector2f(x1, y2);
- //Set the texture coordinates of each of the 4 vertices
- x1 = tileXPos;
- y1 = tileYPos;
- x2 = tileXPos + 8;
- y2 = tileYPos + 8;
- quad[0].texCoords = Vector2f(x1, y1);
- quad[1].texCoords = Vector2f(x2, y1);
- quad[2].texCoords = Vector2f(x2, y2);
- quad[3].texCoords = Vector2f(x1, y2);
- if (xIterator < 16)
- {
- xIterator += 1;
- }
- else
- {
- xIterator = 0;
- yIterator += 1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment