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 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_BORDER_TRANSITION_SIZE 0.2f
|
||||||
#define MASKED_HOLE_DARKNESS_LIMIT 0.5f
|
#define MASKED_HOLE_DARKNESS_LIMIT 0.5f
|
||||||
|
#define COLLECTABLE_SCALE 5.f
|
||||||
|
|
||||||
// Tracking view defaults
|
// Tracking view defaults
|
||||||
#define DEF_TV_IS_ABSOLUTE_FREE_MOVE_THRESHOLD false
|
#define DEF_TV_IS_ABSOLUTE_FREE_MOVE_THRESHOLD false
|
||||||
|
|
|
@ -24,11 +24,16 @@ float Collectable::getDepth() const
|
||||||
void Collectable::setSprite(const std::string &spriteName)
|
void Collectable::setSprite(const std::string &spriteName)
|
||||||
{
|
{
|
||||||
// Create versatile sprite
|
// Create versatile sprite
|
||||||
float sizeWidth = 1.f * WORLD_TO_ISO_SCALE;
|
auto sprite = std::make_shared<VersatileSprite>(spriteName);
|
||||||
auto size = sf::Vector2f{sizeWidth, sizeWidth};
|
size = sprite->getSize() * COLLECTABLE_SCALE;
|
||||||
auto sprite = std::make_shared<VersatileSprite>(spriteName, size);
|
sprite->setSize(size);
|
||||||
addChildScreenOffset(sprite, IsometricCoordinates(-size / 2.f));
|
addChildScreenOffset(sprite, IsometricCoordinates(-size / 2.f));
|
||||||
|
|
||||||
// Set half size offset of coordinates
|
// 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);
|
void setRotation(float angle);
|
||||||
|
|
||||||
|
sf::Vector2f getSize() const;
|
||||||
|
|
||||||
float getDepth() const;
|
float getDepth() const;
|
||||||
|
|
||||||
int getId() const
|
int getId() const
|
||||||
|
@ -25,6 +27,8 @@ private:
|
||||||
int collectableId = 0;
|
int collectableId = 0;
|
||||||
static inline int collectableCount = 0;
|
static inline int collectableCount = 0;
|
||||||
|
|
||||||
|
sf::Vector2f size;
|
||||||
|
|
||||||
std::shared_ptr<Player> consumedBy = nullptr;
|
std::shared_ptr<Player> consumedBy = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,7 @@ CollectableSimulation::CollectableSimulation(const std::shared_ptr<Collectable>
|
||||||
// Create body
|
// Create body
|
||||||
collectableBody = std::make_shared<BodyAdapter>(world);
|
collectableBody = std::make_shared<BodyAdapter>(world);
|
||||||
auto coordinates = collectable->coordinates->diagonalWorld();
|
auto coordinates = collectable->coordinates->diagonalWorld();
|
||||||
|
collectableBody->createSquare(b2_dynamicBody, {coordinates.horizontal, coordinates.vertical}, collectable->getSize());
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CollectableSimulation::physicsUpdate()
|
void CollectableSimulation::physicsUpdate()
|
||||||
|
|
|
@ -135,11 +135,16 @@ sf::Color MaskedSprite::calculateNewPixelColor(sf::Color currentColor, sf::Vecto
|
||||||
currentColor.b *= remainigBrightnessFactor;
|
currentColor.b *= remainigBrightnessFactor;
|
||||||
|
|
||||||
// Cut off pixels that are hidden in the ground, beyond the hole
|
// 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;
|
float depth = coordinates->diagonalWorld().depth;
|
||||||
auto pixelCoordinates = TranslatedCoordinates(DiagonalWorldCoordinates(position.x, position.y, depth));
|
auto pixelCoordinates = TranslatedCoordinates(DiagonalWorldCoordinates(position.x, position.y, depth));
|
||||||
|
|
||||||
std::vector<float> holeAlphaFactors{};
|
std::vector<float> holeAlphaFactors{};
|
||||||
auto players = PlayerCollection::getInstance()->getPlayers();
|
|
||||||
for (auto &player: players)
|
for (auto &player: players)
|
||||||
{
|
{
|
||||||
auto holeMask = MaskedSpriteHole(player);
|
auto holeMask = MaskedSpriteHole(player);
|
||||||
|
|
Loading…
Reference in a new issue