|
|
@ -13,12 +13,16 @@ TileSet::~TileSet() { |
|
|
|
|
|
|
|
|
|
|
|
Map::Map() { |
|
|
|
Map::Map() { |
|
|
|
this->ground1 = new Layer(); |
|
|
|
this->ground1 = new Layer(); |
|
|
|
|
|
|
|
this->ground2 = new Layer(); |
|
|
|
|
|
|
|
this->ground3 = new Layer(); |
|
|
|
this->above1 = new Layer(); |
|
|
|
this->above1 = new Layer(); |
|
|
|
|
|
|
|
this->above2 = new Layer(); |
|
|
|
|
|
|
|
this->above3 = new Layer(); |
|
|
|
this->collision = new Layer(); |
|
|
|
this->collision = new Layer(); |
|
|
|
this->tileSet = new TileSet(); |
|
|
|
this->tileSet = new TileSet(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Map::CheckCollision(sf::RenderWindow *window, Entity *entity) { |
|
|
|
void Map::CheckCollision(Entity *entity) { |
|
|
|
// Get check section
|
|
|
|
// Get check section
|
|
|
|
sf::Vector2f checkWidth = sf::Vector2f( |
|
|
|
sf::Vector2f checkWidth = sf::Vector2f( |
|
|
|
(int)entity->getPosition().x / this->tileSet->tileWidth, |
|
|
|
(int)entity->getPosition().x / this->tileSet->tileWidth, |
|
|
@ -98,11 +102,23 @@ void Map::CheckCollision(sf::RenderWindow *window, Entity *entity) { |
|
|
|
void Map::RenderGround(sf::RenderWindow *window) { |
|
|
|
void Map::RenderGround(sf::RenderWindow *window) { |
|
|
|
Layer* layer = this->ground1; |
|
|
|
Layer* layer = this->ground1; |
|
|
|
this->Render(window, layer); |
|
|
|
this->Render(window, layer); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
layer = this->ground2; |
|
|
|
|
|
|
|
this->Render(window, layer); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
layer = this->ground3; |
|
|
|
|
|
|
|
this->Render(window, layer); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Map::RenderAbove(sf::RenderWindow *window) { |
|
|
|
void Map::RenderAbove(sf::RenderWindow *window) { |
|
|
|
Layer* layer = this->above1; |
|
|
|
Layer* layer = this->above1; |
|
|
|
this->Render(window, layer); |
|
|
|
this->Render(window, layer); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
layer = this->above2; |
|
|
|
|
|
|
|
this->Render(window, layer); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
layer = this->above3; |
|
|
|
|
|
|
|
this->Render(window, layer); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Map::Render(sf::RenderWindow *window, Layer *layer) { |
|
|
|
void Map::Render(sf::RenderWindow *window, Layer *layer) { |
|
|
@ -134,6 +150,10 @@ void Map::Render(sf::RenderWindow *window, Layer *layer) { |
|
|
|
Map::~Map() { |
|
|
|
Map::~Map() { |
|
|
|
delete this->tileSet; |
|
|
|
delete this->tileSet; |
|
|
|
delete this->ground1; |
|
|
|
delete this->ground1; |
|
|
|
|
|
|
|
delete this->ground2; |
|
|
|
|
|
|
|
delete this->ground3; |
|
|
|
delete this->above1; |
|
|
|
delete this->above1; |
|
|
|
|
|
|
|
delete this->above2; |
|
|
|
|
|
|
|
delete this->above3; |
|
|
|
delete this->collision; |
|
|
|
delete this->collision; |
|
|
|
} |
|
|
|
} |
|
|
|