From 68cce5f6e0efdbc6a096769e6442b8d3a00f189c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matt=C3=A9o=20Delabre?= Date: Tue, 8 Mar 2016 21:15:08 +0100 Subject: [PATCH] Move Physics constants in Ball --- ball.cpp | 6 +++--- ball.hpp | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ball.cpp b/ball.cpp index 851dfc0..a7a97b0 100644 --- a/ball.cpp +++ b/ball.cpp @@ -13,11 +13,11 @@ sf::Vector2f Ball::getForces(State state) { // déplacement de la balle après appui sur les touches de direction if (state.goLeftKey) { - forces += sf::Vector2f(-Engine::MOVE, 0); + forces += sf::Vector2f(-Ball::MOVE, 0); } if (state.goRightKey) { - forces += sf::Vector2f(Engine::MOVE, 0); + forces += sf::Vector2f(Ball::MOVE, 0); } // force d'attraction entre les balles et les blocs chargés @@ -42,7 +42,7 @@ sf::Vector2f Ball::getForces(State state) { // normalisation du vecteur direction qui porte // la force d'attraction, puis application de la norme attraction /= std::sqrt(distanceSquared); - attraction *= Engine::ATTRACTION * ( + attraction *= Ball::ATTRACTION * ( (objects[i].getCharge() * objects[j].getCharge()) / distanceSquared ); diff --git a/ball.hpp b/ball.hpp index 06a4ca4..5703274 100644 --- a/ball.hpp +++ b/ball.hpp @@ -13,6 +13,9 @@ protected: */ void getForces(State state); + static constexpr float ATTRACTION = 10; + static constexpr float MOVE = 10; + public: Ball();