diff --git a/CMakeLists.txt b/CMakeLists.txt index fa8c037..9351e6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,8 +56,8 @@ set(SOURCES src/game/player/player_spawner.hpp src/game/camera/tracking_area.h src/game/camera/tracking_view_options.hpp - src/game/collectables/environment_collectable.cpp - src/game/collectables/environment_collectable.hpp + src/game/collectables/collectable.cpp + src/game/collectables/collectable.hpp src/sprites/texture_manager.cpp src/sprites/texture_manager.hpp src/sprites/sprite_sheet.cpp diff --git a/assets/hole.png b/assets/hole.png new file mode 100644 index 0000000..f361d07 Binary files /dev/null and b/assets/hole.png differ diff --git a/src/config.h b/src/config.h index d81ccd7..0423bbf 100644 --- a/src/config.h +++ b/src/config.h @@ -20,7 +20,7 @@ // Graphic settings #define ISOMETRIC_SKEW 0.3f #define MOVEMENT_SKEW sf::Vector2f(1.f, 1/ISOMETRIC_SKEW/2.f) -#define WORLD_TO_ISO_SCALE 50.0f // 50.f +#define WORLD_TO_ISO_SCALE 50.0f // 50.f, don't change. Rather adjust the zoom of the camera // Tracking view defaults #define DEF_TV_FREE_MOVE_THRESHOLD 0.f diff --git a/src/game/player/player.cpp b/src/game/player/player.cpp index a3f1991..804274a 100644 --- a/src/game/player/player.cpp +++ b/src/game/player/player.cpp @@ -12,9 +12,8 @@ Player::Player(std::shared_ptr assignedInput, const std::string & input = std::move(assignedInput); - auto radiusInIso = getIsoRadius(); - auto sprite = std::make_shared(skinRessourceName, sf::Vector2f{radiusInIso * 2.f, radiusInIso * 2.f}); - addChildScreenOffset(sprite, {-radiusInIso, -radiusInIso}); + auto sprite = std::make_shared(skinRessourceName, getIsoSize()); + addChildScreenOffset(sprite, IsometricCoordinates(-getIsoSize() / 2.f)); } sf::Vector2f Player::getTrackablePosition() const @@ -24,8 +23,7 @@ sf::Vector2f Player::getTrackablePosition() const sf::Vector2f Player::getTrackableSize() const { - auto isoRadius = getIsoRadius(); - return {isoRadius * 2.f, isoRadius * 2.f}; + return getIsoSize(); } void Player::update() @@ -64,12 +62,15 @@ int Player::getPlayerId() const return playerId; } -float Player::getIsoRadius() const -{ - return radiusInWorld * WORLD_TO_ISO_SCALE; -} - float Player::getWorldRadius() const { return radiusInWorld; } + +sf::Vector2f Player::getIsoSize() const +{ + // TODO: For some reason, the player is a little to narrow. This fixes it. + const float fixFactor = 1.4f; + float width = radiusInWorld * 2.f * WORLD_TO_ISO_SCALE * fixFactor; + return {width, width * ISOMETRIC_SKEW}; +} diff --git a/src/game/player/player.hpp b/src/game/player/player.hpp index b08eea5..9ab64a2 100644 --- a/src/game/player/player.hpp +++ b/src/game/player/player.hpp @@ -25,6 +25,8 @@ public: float speed = DEFAULT_PLAYER_SPEED; + sf::Vector2f getIsoSize() const; + int getPlayerId() const; float getWorldRadius() const; @@ -37,8 +39,6 @@ private: int playerId; static inline int playerCreationCounter = 0; - - float getIsoRadius() const; }; diff --git a/src/texture_config.h b/src/texture_config.h index 872ba00..9bf25e1 100644 --- a/src/texture_config.h +++ b/src/texture_config.h @@ -7,7 +7,7 @@ #include "sprites/configs/sheet_config.hpp" #include "sprites/configs/sprite_config.hpp" -#define PLAYER_SKIN "ring" +#define PLAYER_SKIN "hole" /** * All textures used in the game. @@ -17,7 +17,8 @@ std::map const all_textures = { {"numbers", "assets/numbers.png"}, {"64", "assets/64.png"}, {"edge", "assets/edge.png"}, - {"ring", "assets/ring.png"} + {"ring", "assets/ring.png"}, + {"hole", "assets/hole.png"} }; /** @@ -43,7 +44,8 @@ std::map const all_animations = { std::map const all_sprites = { {"64", SpriteConfig("64")}, {"edge", SpriteConfig("edge")}, - {"ring", SpriteConfig("ring")} + {"ring", SpriteConfig("ring")}, + {"hole", SpriteConfig("hole")} }; #endif //HOLESOME_TEXTURE_CONFIG_H