diff --git a/assets/ring.png b/assets/ring.png new file mode 100644 index 0000000..65b3c2f Binary files /dev/null and b/assets/ring.png differ diff --git a/src/config.h b/src/config.h index d9025dd..d81ccd7 100644 --- a/src/config.h +++ b/src/config.h @@ -5,6 +5,9 @@ #define DEVELOPER_MODE true +// Player +#define DEFAULT_PLAYER_SPEED 5.f // World units per second +#define DEFAULT_PLAYER_RADIUS .5f // In World units // FPS #define FRAME_RATE 60 @@ -17,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 10.0f +#define WORLD_TO_ISO_SCALE 50.0f // 50.f // Tracking view defaults #define DEF_TV_FREE_MOVE_THRESHOLD 0.f @@ -28,7 +31,6 @@ #define DEF_TV_VIEW_SIZE_PADDING sf::Vector2f(0.5f, 0.5f) // Simulations -#define MAPSIM_PLAYER_RADIUS 2.f #define MAPSIM_VELOCITY_ITERATIONS 6 #define MAPSIM_POSITION_ITERATIONS 2 diff --git a/src/game/physics/map_simulation.cpp b/src/game/physics/map_simulation.cpp index bd0df39..8e756f2 100644 --- a/src/game/physics/map_simulation.cpp +++ b/src/game/physics/map_simulation.cpp @@ -70,7 +70,7 @@ void MapSimulation::addPlayer(Player *player) b2Body *body = world->CreateBody(&bodyDef); b2CircleShape shape; - shape.m_radius = MAPSIM_PLAYER_RADIUS; + shape.m_radius = player->getWorldRadius(); shape.m_p.Set(0, 0); b2FixtureDef fixtureDef; diff --git a/src/game/player/player.cpp b/src/game/player/player.cpp index ab7684e..a3f1991 100644 --- a/src/game/player/player.cpp +++ b/src/game/player/player.cpp @@ -12,8 +12,9 @@ Player::Player(std::shared_ptr assignedInput, const std::string & input = std::move(assignedInput); - auto sprite = std::make_shared(skinRessourceName, sf::Vector2f{width, width}); - addChildScreenOffset(sprite, {-width / 2.f, -width / 2.f}); + auto radiusInIso = getIsoRadius(); + auto sprite = std::make_shared(skinRessourceName, sf::Vector2f{radiusInIso * 2.f, radiusInIso * 2.f}); + addChildScreenOffset(sprite, {-radiusInIso, -radiusInIso}); } sf::Vector2f Player::getTrackablePosition() const @@ -23,7 +24,8 @@ sf::Vector2f Player::getTrackablePosition() const sf::Vector2f Player::getTrackableSize() const { - return {width, width}; + auto isoRadius = getIsoRadius(); + return {isoRadius * 2.f, isoRadius * 2.f}; } void Player::update() @@ -61,3 +63,13 @@ int Player::getPlayerId() const { return playerId; } + +float Player::getIsoRadius() const +{ + return radiusInWorld * WORLD_TO_ISO_SCALE; +} + +float Player::getWorldRadius() const +{ + return radiusInWorld; +} diff --git a/src/game/player/player.hpp b/src/game/player/player.hpp index 1b11fa2..b08eea5 100644 --- a/src/game/player/player.hpp +++ b/src/game/player/player.hpp @@ -5,6 +5,7 @@ #include "../camera/ITrackable.h" #include "../../sprites/versatile_sprite.hpp" #include "../input/input_identity.h" +#include "../../config.h" class Player : public GameObject, public ITrackable { @@ -22,18 +23,22 @@ public: TrackableState getTrackableState() const override; - float speed = 30.0f; + float speed = DEFAULT_PLAYER_SPEED; int getPlayerId() const; + float getWorldRadius() const; + private: std::shared_ptr input; - float width = 50; + float radiusInWorld = DEFAULT_PLAYER_RADIUS; sf::Vector2f spawnPosition; int playerId; static inline int playerCreationCounter = 0; + + float getIsoRadius() const; }; diff --git a/src/texture_config.h b/src/texture_config.h index c16c821..872ba00 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 "edge" +#define PLAYER_SKIN "ring" /** * All textures used in the game. @@ -16,7 +16,8 @@ std::map const all_textures = { {"numbers", "assets/numbers.png"}, {"64", "assets/64.png"}, - {"edge", "assets/edge.png"} + {"edge", "assets/edge.png"}, + {"ring", "assets/ring.png"} }; /** @@ -41,7 +42,8 @@ std::map const all_animations = { */ std::map const all_sprites = { {"64", SpriteConfig("64")}, - {"edge", SpriteConfig("edge")} + {"edge", SpriteConfig("edge")}, + {"ring", SpriteConfig("ring")} }; #endif //HOLESOME_TEXTURE_CONFIG_H