Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Here are the most important methods of Tile...
- Tile::Tile() : sprite(), isInvisible(false), canBlock(false)
- {
- tileColor = sf::Color();
- }
- Tile::Tile(bool isInvisible, bool blocks, sf::Sprite sprite, sf::Color color)
- : isInvisible(isInvisible), canBlock(blocks)
- {
- this->SetTexture(sprite, color);
- this->setSize(sf::Vector2f(C_TILE_IN_GAME_SIZE, C_TILE_IN_GAME_SIZE));
- }
- Tile::Tile(bool blocks) : sprite(), isInvisible(true)
- {
- }
- Tile::Tile(bool isInvisible, bool blocks) : isInvisible(isInvisible), canBlock(blocks)
- {
- }
- #warning Default constructor for Tile
- Tile::Tile(const unsigned int tileSpriteIntVal, bool isInvisible, bool blocks, sf::Color color, const std::vector<sf::Sprite> spritesVector) : isInvisible(isInvisible), canBlock(blocks)
- {
- // TODO: Use this constructor as a default
- sf::Sprite sprite = spritesVector.at(tileSpriteIntVal);
- this->SetTexture(sprite, color); // changes the tileSpriteIntVal
- this->setSize(sf::Vector2f(C_TILE_IN_GAME_SIZE, C_TILE_IN_GAME_SIZE));
- this->spriteEnumVal = static_cast<TileSprite>(tileSpriteIntVal);
- }
- Tile::~Tile()
- {
- }
- /* setTile sets a colored sprite to the tile and sets the alpha mask of it */
- void Tile::SetTexture(sf::Sprite& _sprite, sf::Color color)
- {
- if (this->isInvisible)
- {
- _sprite.setColor(sf::Color::Transparent);
- } else
- {
- _sprite.setColor(color);
- }
- const sf::Texture* t = _sprite.getTexture();
- this->setTexture(t);
- this->setFillColor(color);
- }
- // Here are the most important methods from Entity:
- Entity::~Entity()
- {
- delete this->tile;
- }
- Entity* Entity::CreateNewEntityFromSprite(sf::Sprite entitySprite, std::string name, bool isInvisible, bool blocks, sf::Color entityColor, int x, int y)
- {
- Tile* entityTile = new Tile{isInvisible, blocks, entitySprite, entityColor};
- Entity* entity = new Entity{entityTile, name, x, y};
- return entity;
- }
- void Entity::SetActorComponent(Actor* acp)
- {
- this->actorComponent = acp;
- }
- Entity::Entity(const Entity& ec) : x(ec.x), y(ec.y), name(ec.name), blockingEntitiesVectorPos(ec.blockingEntitiesVectorPos)
- {
- this->SetTile(ec.tile);
- this->SetActorComponent(ec.actorComponent);
- //this->tile->move(this->GetX(), this->GetY());
- }
- // Here is the GetSpritesOfEntitiesCloseToPlayer method of Engine class.
- std::vector<Tile*> Engine::GetSpritesOfEntitiesCloseToPlayer(const std::vector<Entity*>& entities, const Entity *cameraPointer) const
- {
- std::vector<Tile*> vt;
- for (const Entity* bep: entities)
- {
- if (bep != nullptr)
- {
- if (DistanceBetweenTwoEntities(*bep, *cameraPointer) <= C_CAMERA_RANGE)
- {
- vt.push_back(bep->GetTile());
- }
- }
- }
- return vt;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement