diff --git a/src/config.h b/src/config.h index 2092052..50ce32a 100644 --- a/src/config.h +++ b/src/config.h @@ -32,6 +32,7 @@ #define MOVEMENT_SKEW sf::Vector2f(1.f, 1/ISOMETRIC_SKEW/2.f) #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 // Tracking view defaults #define DEF_TV_IS_ABSOLUTE_FREE_MOVE_THRESHOLD false diff --git a/src/coordinates/translated_coordinates.cpp b/src/coordinates/translated_coordinates.cpp index 93933c6..0db3f2f 100644 --- a/src/coordinates/translated_coordinates.cpp +++ b/src/coordinates/translated_coordinates.cpp @@ -109,3 +109,8 @@ void TranslatedCoordinates::removeParent() // this->worldCoordinates = globalWorldCoordinates; this->parent = nullptr; } + +TranslatedCoordinates::TranslatedCoordinates(IsometricCoordinates isometricCoordinates) +{ + setIsometric(isometricCoordinates); +} diff --git a/src/coordinates/translated_coordinates.h b/src/coordinates/translated_coordinates.h index 75734fb..793f4a7 100644 --- a/src/coordinates/translated_coordinates.h +++ b/src/coordinates/translated_coordinates.h @@ -10,6 +10,7 @@ class TranslatedCoordinates public: explicit TranslatedCoordinates(WorldCoordinates worldCoordinates); explicit TranslatedCoordinates(DiagonalWorldCoordinates diagonalWorldCoordinates); + explicit TranslatedCoordinates(IsometricCoordinates isometricCoordinates); explicit TranslatedCoordinates(GridCoordinates gridCoordinates); [[nodiscard]] WorldCoordinates world() const; diff --git a/src/game/collectables/collectable.hpp b/src/game/collectables/collectable.hpp index 98e6d10..e2931ab 100644 --- a/src/game/collectables/collectable.hpp +++ b/src/game/collectables/collectable.hpp @@ -3,6 +3,7 @@ #include "../game_object.h" +#include "../player/player.hpp" class Collectable : public GameObject { @@ -23,6 +24,8 @@ public: private: int collectableId = 0; static inline int collectableCount = 0; + + std::shared_ptr consumedBy = nullptr; }; diff --git a/src/sprites/masked_sprite.cpp b/src/sprites/masked_sprite.cpp index e522d25..13e74fa 100644 --- a/src/sprites/masked_sprite.cpp +++ b/src/sprites/masked_sprite.cpp @@ -58,7 +58,10 @@ void MaskedSprite::updateFreshMaskedSprite() maskedImage->copy(*image, 0, 0); // Calculate world coordinates for each pixel - auto topLeftCorner = sf::Vector2f(coordinates->diagonalWorld().horizontal, coordinates->diagonalWorld().vertical); + auto coordinatesTopLeftCorner = TranslatedCoordinates( + IsometricCoordinates(renderPosition.x, renderPosition.y, coordinates->isometric().depth)); + auto topLeftCorner = sf::Vector2f(coordinatesTopLeftCorner.diagonalWorld().horizontal, + coordinatesTopLeftCorner.diagonalWorld().vertical); auto xAxis = rotateVectorByAngle(sf::Vector2f(1, 0), angle); auto yAxis = rotateVectorByAngle(sf::Vector2f(0, -1), angle); float xFactorPerPixel = sprite->getScale().x / WORLD_TO_ISO_SCALE; @@ -124,7 +127,13 @@ sf::Color MaskedSprite::calculateNewPixelColor(sf::Color currentColor, sf::Vecto return currentColor; } - // Change color based on height and hole + // Make darker the further below the ground + float remainigBrightnessFactor = exp(position.y) * (1 - MASKED_HOLE_DARKNESS_LIMIT) + + MASKED_HOLE_DARKNESS_LIMIT; // y is negative here already + currentColor.r *= remainigBrightnessFactor; + currentColor.g *= remainigBrightnessFactor; + currentColor.b *= remainigBrightnessFactor; + // Cut off pixels that are hidden in the ground, beyond the hole float depth = coordinates->diagonalWorld().depth; auto pixelCoordinates = TranslatedCoordinates(DiagonalWorldCoordinates(position.x, position.y, depth));