Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Texture */
- sf::Sprite Terrain::GetTexture(int terrainIndex)
- {
- sf::Vector2i *tempSize = new sf::Vector2i(this->GetSize());
- int *nx = new int(1024 / tempSize->x);
- int *ny = new int(1024 / tempSize->y);
- sf::IntRect *tempRect = new sf::IntRect
- (
- (terrainIndex % *nx) * tempSize->x,
- ((terrainIndex/ *ny)) * tempSize->y, tempSize->x, tempSize->y
- );
- this->_sprite.setTextureRect(sf::IntRect(*tempRect));
- delete nx;
- delete ny;
- delete tempSize;
- delete tempRect;
- return this->_sprite;
- }
- /* World */
- void World::Draw(class Terrain *terrain)
- {
- sf::Vector2i *tempSize = new sf::Vector2i(terrain->GetSize());
- int *y = new int;
- int *x = new int;
- for (*y = 0; *y < this->_mapSize.y; (*y)++)
- {
- for (*x = 0; *x < this->_mapSize.x; (*x)++)
- {
- terrain->SetPostion({*x * tempSize->x, *y * tempSize->y});
- Application::Window->draw(terrain->GetTexture(this->_map[*x][*y]));
- }
- }
- delete x;
- delete y;
- delete tempSize;
- }
Advertisement
Add Comment
Please, Sign In to add comment