Correction des erreurs de syntaxe
This commit is contained in:
parent
b4aa564cf0
commit
313173de46
13
ball.cpp
13
ball.cpp
|
@ -22,18 +22,15 @@ sf::Vector2f Ball::getForces(State state) {
|
|||
|
||||
// force d'attraction entre les balles et les blocs chargés
|
||||
if (getCharge() != 0) {
|
||||
for (int j = 0; j < state.objects.size(); j++) {
|
||||
Object attractiveObject = *objects[j];
|
||||
for (unsigned int j = 0; j < state.objects.size(); j++) {
|
||||
Object *attractive = state.objects[j];
|
||||
|
||||
if (i == j || attractiveObject.getCharge() == 0) {
|
||||
if (attractive == this || attractive->getCharge() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// vecteur allant de l'objet attirant vers l'objet considéré
|
||||
sf::Vector2f attraction(
|
||||
attractiveObject.getPosition() -
|
||||
object.getPosition()
|
||||
);
|
||||
sf::Vector2f attraction(attractive->getPosition() - position);
|
||||
|
||||
// la norme de ce vecteur est la distance entre les objets
|
||||
float distanceSquared = attraction.x * attraction.x +
|
||||
|
@ -43,7 +40,7 @@ sf::Vector2f Ball::getForces(State state) {
|
|||
// la force d'attraction, puis application de la norme
|
||||
attraction /= std::sqrt(distanceSquared);
|
||||
attraction *= Ball::ATTRACTION * (
|
||||
(objects[i].getCharge() * objects[j].getCharge()) /
|
||||
(charge * attractive->getCharge()) /
|
||||
distanceSquared
|
||||
);
|
||||
|
||||
|
|
2
ball.hpp
2
ball.hpp
|
@ -11,7 +11,7 @@ protected:
|
|||
/**
|
||||
* Calcule les forces appliquées à l'objet
|
||||
*/
|
||||
void getForces(State state);
|
||||
sf::Vector2f getForces(State state);
|
||||
|
||||
static constexpr float ATTRACTION = 10;
|
||||
static constexpr float MOVE = 10;
|
||||
|
|
|
@ -68,7 +68,7 @@ void Engine::update() {
|
|||
state.objects = objects;
|
||||
|
||||
// demande la mise à jour de tous les objets du jeu
|
||||
for (int i = 0; i < objects.size(); i++) {
|
||||
for (unsigned int i = 0; i < objects.size(); i++) {
|
||||
objects[i]->update(state);
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ void Engine::draw() {
|
|||
// chargement de la file d'affichage des objets
|
||||
std::priority_queue<Object*, std::vector<Object*>, CompareObjectLayer> display_queue;
|
||||
|
||||
for (int i = 0; i < objects.size(); i++) {
|
||||
for (unsigned int i = 0; i < objects.size(); i++) {
|
||||
display_queue.push(objects[i]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue