Fixed collectable sizes
This commit is contained in:
parent
364f4c6423
commit
b0a83a90ef
5 changed files with 21 additions and 9 deletions
|
@ -33,6 +33,7 @@
|
|||
#define WORLD_TO_ISO_SCALE 50.0f // 50.f, don't change. Rather adjust the zoom of the camera
|
||||
#define MASKED_HOLE_BORDER_TRANSITION_SIZE 0.2f
|
||||
#define MASKED_HOLE_DARKNESS_LIMIT 0.5f
|
||||
#define COLLECTABLE_SCALE 5.f
|
||||
|
||||
// Tracking view defaults
|
||||
#define DEF_TV_IS_ABSOLUTE_FREE_MOVE_THRESHOLD false
|
||||
|
|
|
@ -24,11 +24,16 @@ float Collectable::getDepth() const
|
|||
void Collectable::setSprite(const std::string &spriteName)
|
||||
{
|
||||
// Create versatile sprite
|
||||
float sizeWidth = 1.f * WORLD_TO_ISO_SCALE;
|
||||
auto size = sf::Vector2f{sizeWidth, sizeWidth};
|
||||
auto sprite = std::make_shared<VersatileSprite>(spriteName, size);
|
||||
auto sprite = std::make_shared<VersatileSprite>(spriteName);
|
||||
size = sprite->getSize() * COLLECTABLE_SCALE;
|
||||
sprite->setSize(size);
|
||||
addChildScreenOffset(sprite, IsometricCoordinates(-size / 2.f));
|
||||
|
||||
// Set half size offset of coordinates
|
||||
coordinates->move(IsometricCoordinates(0, -sizeWidth / 2.f, 0));
|
||||
coordinates->move(IsometricCoordinates(0, -size.x / 2.f, 0));
|
||||
}
|
||||
|
||||
sf::Vector2f Collectable::getSize() const
|
||||
{
|
||||
return size / WORLD_TO_ISO_SCALE;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ public:
|
|||
|
||||
void setRotation(float angle);
|
||||
|
||||
sf::Vector2f getSize() const;
|
||||
|
||||
float getDepth() const;
|
||||
|
||||
int getId() const
|
||||
|
@ -25,6 +27,8 @@ private:
|
|||
int collectableId = 0;
|
||||
static inline int collectableCount = 0;
|
||||
|
||||
sf::Vector2f size;
|
||||
|
||||
std::shared_ptr<Player> consumedBy = nullptr;
|
||||
};
|
||||
|
||||
|
|
|
@ -18,10 +18,7 @@ CollectableSimulation::CollectableSimulation(const std::shared_ptr<Collectable>
|
|||
// Create body
|
||||
collectableBody = std::make_shared<BodyAdapter>(world);
|
||||
auto coordinates = collectable->coordinates->diagonalWorld();
|
||||
|
||||
// todo: scale collectable and HOLE WIDTH SIZE based on factor
|
||||
auto size = sf::Vector2f(1, 1);
|
||||
collectableBody->createSquare(b2_dynamicBody, {coordinates.horizontal, coordinates.vertical}, size);
|
||||
collectableBody->createSquare(b2_dynamicBody, {coordinates.horizontal, coordinates.vertical}, collectable->getSize());
|
||||
}
|
||||
|
||||
void CollectableSimulation::physicsUpdate()
|
||||
|
|
|
@ -135,11 +135,16 @@ sf::Color MaskedSprite::calculateNewPixelColor(sf::Color currentColor, sf::Vecto
|
|||
currentColor.b *= remainigBrightnessFactor;
|
||||
|
||||
// Cut off pixels that are hidden in the ground, beyond the hole
|
||||
auto players = PlayerCollection::getInstance()->getPlayers();
|
||||
if (players.empty())
|
||||
{
|
||||
return currentColor;
|
||||
}
|
||||
|
||||
float depth = coordinates->diagonalWorld().depth;
|
||||
auto pixelCoordinates = TranslatedCoordinates(DiagonalWorldCoordinates(position.x, position.y, depth));
|
||||
|
||||
std::vector<float> holeAlphaFactors{};
|
||||
auto players = PlayerCollection::getInstance()->getPlayers();
|
||||
for (auto &player: players)
|
||||
{
|
||||
auto holeMask = MaskedSpriteHole(player);
|
||||
|
|
Loading…
Reference in a new issue