Migration des constantes pour Object dans constants.hpp

This commit is contained in:
Mattéo Delabre 2016-03-18 18:33:46 +01:00
parent 62b4c53a36
commit f5e6a3c96e
2 changed files with 26 additions and 1 deletions

View File

@ -35,6 +35,27 @@ namespace Constants {
*/
static constexpr float CORRECTION_PERCENTAGE = .2f;
static constexpr float CORRECTION_THRESHOLD = .01f;
/**
* Masse par défaut d'un objet
*/
static constexpr float DEFAULT_MASS = 1.f;
/**
* Charge par défaut d'un objet
*/
static constexpr float DEFAULT_CHARGE = 0.f;
/**
* Coefficient de restitution par défaut
*/
static constexpr float DEFAULT_RESTITUTION = 0.4f;
/**
* Couche par défaut d'affichage d'un objet
* (peut être modifié objet par objet)
*/
static constexpr int DEFAULT_LAYER = 10;
}
#endif

View File

@ -5,7 +5,11 @@ Object::Object(float x, float y) :
acceleration(0, 0), velocity(0, 0), position(x, y),
accelerationLine(sf::Lines, 2),
velocityLine(sf::Lines, 2),
mass(1.f), inv_mass(1.f), charge(0.f), restitution(0.5f), layer(10) {}
mass(Constants::DEFAULT_MASS),
inv_mass(1.f / Constants::DEFAULT_MASS),
charge(Constants::DEFAULT_CHARGE),
restitution(Constants::DEFAULT_RESTITUTION),
layer(Constants::DEFAULT_LAYER) {}
sf::Vector2f Object::getForces(EngineState& state) {
sf::Vector2f forces(0, 0);