Player size now correlated to world size
This commit is contained in:
parent
37ede84344
commit
041a565ae1
6 changed files with 32 additions and 11 deletions
BIN
assets/ring.png
Normal file
BIN
assets/ring.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
|
@ -5,6 +5,9 @@
|
||||||
|
|
||||||
#define DEVELOPER_MODE true
|
#define DEVELOPER_MODE true
|
||||||
|
|
||||||
|
// Player
|
||||||
|
#define DEFAULT_PLAYER_SPEED 5.f // World units per second
|
||||||
|
#define DEFAULT_PLAYER_RADIUS .5f // In World units
|
||||||
|
|
||||||
// FPS
|
// FPS
|
||||||
#define FRAME_RATE 60
|
#define FRAME_RATE 60
|
||||||
|
@ -17,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 10.0f
|
#define WORLD_TO_ISO_SCALE 50.0f // 50.f
|
||||||
|
|
||||||
// Tracking view defaults
|
// Tracking view defaults
|
||||||
#define DEF_TV_FREE_MOVE_THRESHOLD 0.f
|
#define DEF_TV_FREE_MOVE_THRESHOLD 0.f
|
||||||
|
@ -28,7 +31,6 @@
|
||||||
#define DEF_TV_VIEW_SIZE_PADDING sf::Vector2f(0.5f, 0.5f)
|
#define DEF_TV_VIEW_SIZE_PADDING sf::Vector2f(0.5f, 0.5f)
|
||||||
|
|
||||||
// Simulations
|
// Simulations
|
||||||
#define MAPSIM_PLAYER_RADIUS 2.f
|
|
||||||
#define MAPSIM_VELOCITY_ITERATIONS 6
|
#define MAPSIM_VELOCITY_ITERATIONS 6
|
||||||
#define MAPSIM_POSITION_ITERATIONS 2
|
#define MAPSIM_POSITION_ITERATIONS 2
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ void MapSimulation::addPlayer(Player *player)
|
||||||
b2Body *body = world->CreateBody(&bodyDef);
|
b2Body *body = world->CreateBody(&bodyDef);
|
||||||
|
|
||||||
b2CircleShape shape;
|
b2CircleShape shape;
|
||||||
shape.m_radius = MAPSIM_PLAYER_RADIUS;
|
shape.m_radius = player->getWorldRadius();
|
||||||
shape.m_p.Set(0, 0);
|
shape.m_p.Set(0, 0);
|
||||||
|
|
||||||
b2FixtureDef fixtureDef;
|
b2FixtureDef fixtureDef;
|
||||||
|
|
|
@ -12,8 +12,9 @@ Player::Player(std::shared_ptr<InputIdentity> assignedInput, const std::string &
|
||||||
|
|
||||||
input = std::move(assignedInput);
|
input = std::move(assignedInput);
|
||||||
|
|
||||||
auto sprite = std::make_shared<VersatileSprite>(skinRessourceName, sf::Vector2f{width, width});
|
auto radiusInIso = getIsoRadius();
|
||||||
addChildScreenOffset(sprite, {-width / 2.f, -width / 2.f});
|
auto sprite = std::make_shared<VersatileSprite>(skinRessourceName, sf::Vector2f{radiusInIso * 2.f, radiusInIso * 2.f});
|
||||||
|
addChildScreenOffset(sprite, {-radiusInIso, -radiusInIso});
|
||||||
}
|
}
|
||||||
|
|
||||||
sf::Vector2f Player::getTrackablePosition() const
|
sf::Vector2f Player::getTrackablePosition() const
|
||||||
|
@ -23,7 +24,8 @@ sf::Vector2f Player::getTrackablePosition() const
|
||||||
|
|
||||||
sf::Vector2f Player::getTrackableSize() const
|
sf::Vector2f Player::getTrackableSize() const
|
||||||
{
|
{
|
||||||
return {width, width};
|
auto isoRadius = getIsoRadius();
|
||||||
|
return {isoRadius * 2.f, isoRadius * 2.f};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::update()
|
void Player::update()
|
||||||
|
@ -61,3 +63,13 @@ int Player::getPlayerId() const
|
||||||
{
|
{
|
||||||
return playerId;
|
return playerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float Player::getIsoRadius() const
|
||||||
|
{
|
||||||
|
return radiusInWorld * WORLD_TO_ISO_SCALE;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Player::getWorldRadius() const
|
||||||
|
{
|
||||||
|
return radiusInWorld;
|
||||||
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "../camera/ITrackable.h"
|
#include "../camera/ITrackable.h"
|
||||||
#include "../../sprites/versatile_sprite.hpp"
|
#include "../../sprites/versatile_sprite.hpp"
|
||||||
#include "../input/input_identity.h"
|
#include "../input/input_identity.h"
|
||||||
|
#include "../../config.h"
|
||||||
|
|
||||||
class Player : public GameObject, public ITrackable
|
class Player : public GameObject, public ITrackable
|
||||||
{
|
{
|
||||||
|
@ -22,18 +23,22 @@ public:
|
||||||
|
|
||||||
TrackableState getTrackableState() const override;
|
TrackableState getTrackableState() const override;
|
||||||
|
|
||||||
float speed = 30.0f;
|
float speed = DEFAULT_PLAYER_SPEED;
|
||||||
|
|
||||||
int getPlayerId() const;
|
int getPlayerId() const;
|
||||||
|
|
||||||
|
float getWorldRadius() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<InputIdentity> input;
|
std::shared_ptr<InputIdentity> input;
|
||||||
float width = 50;
|
float radiusInWorld = DEFAULT_PLAYER_RADIUS;
|
||||||
|
|
||||||
sf::Vector2f spawnPosition;
|
sf::Vector2f spawnPosition;
|
||||||
|
|
||||||
int playerId;
|
int playerId;
|
||||||
static inline int playerCreationCounter = 0;
|
static inline int playerCreationCounter = 0;
|
||||||
|
|
||||||
|
float getIsoRadius() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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 "edge"
|
#define PLAYER_SKIN "ring"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All textures used in the game.
|
* All textures used in the game.
|
||||||
|
@ -16,7 +16,8 @@
|
||||||
std::map<std::string, std::string> const all_textures = {
|
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"}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,7 +42,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")}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //HOLESOME_TEXTURE_CONFIG_H
|
#endif //HOLESOME_TEXTURE_CONFIG_H
|
||||||
|
|
Loading…
Reference in a new issue