Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Tilemap::Tilemap(sf::Image* _image)
- {
- sf::Vector2u size = _image->getSize();
- int w = size.x, int h = size.y;
- int* pixels = (int*)_image->getPixelsPtr();
- int i, j, k;
- int color;
- bool good;
- j = 0;
- while (j < h)
- {
- color = pixels[j*w];
- good = true;
- k = j;
- while (k < h)
- {
- while (i < w)
- {
- if (pixels[i+k*w] != color || pixels[k+i*w] != color) {good = false; break;}
- }
- if (!good) { j++; break; }
- k += j+1;
- }
- }
- if (good) { tileWidth = tileHeight = j; }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement