Player has proper size and a better placeholder graphic

This commit is contained in:
Maximilian Giller 2023-06-11 14:03:48 +02:00
parent b3d793cb9f
commit 74ca505b60
6 changed files with 21 additions and 18 deletions

View file

@ -56,8 +56,8 @@ set(SOURCES
src/game/player/player_spawner.hpp src/game/player/player_spawner.hpp
src/game/camera/tracking_area.h src/game/camera/tracking_area.h
src/game/camera/tracking_view_options.hpp src/game/camera/tracking_view_options.hpp
src/game/collectables/environment_collectable.cpp src/game/collectables/collectable.cpp
src/game/collectables/environment_collectable.hpp src/game/collectables/collectable.hpp
src/sprites/texture_manager.cpp src/sprites/texture_manager.cpp
src/sprites/texture_manager.hpp src/sprites/texture_manager.hpp
src/sprites/sprite_sheet.cpp src/sprites/sprite_sheet.cpp

BIN
assets/hole.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 KiB

View file

@ -20,7 +20,7 @@
// Graphic settings // Graphic settings
#define ISOMETRIC_SKEW 0.3f #define ISOMETRIC_SKEW 0.3f
#define MOVEMENT_SKEW sf::Vector2f(1.f, 1/ISOMETRIC_SKEW/2.f) #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 // Tracking view defaults
#define DEF_TV_FREE_MOVE_THRESHOLD 0.f #define DEF_TV_FREE_MOVE_THRESHOLD 0.f

View file

@ -12,9 +12,8 @@ Player::Player(std::shared_ptr<InputIdentity> assignedInput, const std::string &
input = std::move(assignedInput); input = std::move(assignedInput);
auto radiusInIso = getIsoRadius(); auto sprite = std::make_shared<VersatileSprite>(skinRessourceName, getIsoSize());
auto sprite = std::make_shared<VersatileSprite>(skinRessourceName, sf::Vector2f{radiusInIso * 2.f, radiusInIso * 2.f}); addChildScreenOffset(sprite, IsometricCoordinates(-getIsoSize() / 2.f));
addChildScreenOffset(sprite, {-radiusInIso, -radiusInIso});
} }
sf::Vector2f Player::getTrackablePosition() const sf::Vector2f Player::getTrackablePosition() const
@ -24,8 +23,7 @@ sf::Vector2f Player::getTrackablePosition() const
sf::Vector2f Player::getTrackableSize() const sf::Vector2f Player::getTrackableSize() const
{ {
auto isoRadius = getIsoRadius(); return getIsoSize();
return {isoRadius * 2.f, isoRadius * 2.f};
} }
void Player::update() void Player::update()
@ -64,12 +62,15 @@ int Player::getPlayerId() const
return playerId; return playerId;
} }
float Player::getIsoRadius() const
{
return radiusInWorld * WORLD_TO_ISO_SCALE;
}
float Player::getWorldRadius() const float Player::getWorldRadius() const
{ {
return radiusInWorld; 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};
}

View file

@ -25,6 +25,8 @@ public:
float speed = DEFAULT_PLAYER_SPEED; float speed = DEFAULT_PLAYER_SPEED;
sf::Vector2f getIsoSize() const;
int getPlayerId() const; int getPlayerId() const;
float getWorldRadius() const; float getWorldRadius() const;
@ -37,8 +39,6 @@ private:
int playerId; int playerId;
static inline int playerCreationCounter = 0; static inline int playerCreationCounter = 0;
float getIsoRadius() const;
}; };

View file

@ -7,7 +7,7 @@
#include "sprites/configs/sheet_config.hpp" #include "sprites/configs/sheet_config.hpp"
#include "sprites/configs/sprite_config.hpp" #include "sprites/configs/sprite_config.hpp"
#define PLAYER_SKIN "ring" #define PLAYER_SKIN "hole"
/** /**
* All textures used in the game. * All textures used in the game.
@ -17,7 +17,8 @@ std::map<std::string, std::string> const all_textures = {
{"numbers", "assets/numbers.png"}, {"numbers", "assets/numbers.png"},
{"64", "assets/64.png"}, {"64", "assets/64.png"},
{"edge", "assets/edge.png"}, {"edge", "assets/edge.png"},
{"ring", "assets/ring.png"} {"ring", "assets/ring.png"},
{"hole", "assets/hole.png"}
}; };
/** /**
@ -43,7 +44,8 @@ std::map<std::string, AnimationConfig> const all_animations = {
std::map<std::string, SpriteConfig> const all_sprites = { std::map<std::string, SpriteConfig> const all_sprites = {
{"64", SpriteConfig("64")}, {"64", SpriteConfig("64")},
{"edge", SpriteConfig("edge")}, {"edge", SpriteConfig("edge")},
{"ring", SpriteConfig("ring")} {"ring", SpriteConfig("ring")},
{"hole", SpriteConfig("hole")}
}; };
#endif //HOLESOME_TEXTURE_CONFIG_H #endif //HOLESOME_TEXTURE_CONFIG_H