From 382cc27eb33919870a6def9c6fbb846bf7980f3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matt=C3=A9o=20Delabre?= Date: Thu, 10 Mar 2016 19:18:50 +0100 Subject: [PATCH 1/2] Ajout de l'instruction de dessin final --- Makefile | 2 +- engine.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index dd249c9..a45e723 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ CC=g++ CFLAGS=-Wall -std=c++11 TARGET=ptf -$(TARGET): build/main.o build/object.o build/physics_object.o build/block.o build/ball.o build/engine.o +$(TARGET): build/main.o build/object.o build/physics_object.o build/block.o build/ball.o build/engine.o $(CC) $(CFLAGS) -o build/$(TARGET) \ build/main.o build/object.o build/physics_object.o build/block.o \ build/ball.o build/engine.o \ diff --git a/engine.cpp b/engine.cpp index 5879154..1cfc6f2 100644 --- a/engine.cpp +++ b/engine.cpp @@ -89,4 +89,6 @@ void Engine::draw() { display_queue.top()->draw(window); display_queue.pop(); } + + window.display(); } From 3df200091b505fc9de39fde1fa36e543a1912d04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matt=C3=A9o=20Delabre?= Date: Thu, 10 Mar 2016 19:52:59 +0100 Subject: [PATCH 2/2] =?UTF-8?q?Ajout=20de=20l'int=C3=A9gration=20simple=20?= =?UTF-8?q?(Euler=20explicite)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- physics_object.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/physics_object.cpp b/physics_object.cpp index 4d6217b..280da42 100644 --- a/physics_object.cpp +++ b/physics_object.cpp @@ -1,9 +1,9 @@ #include "physics_object.hpp" void PhysicsObject::update(State state) { - sf::Vector2f forces = getForces(state); - - // TODO: intégrer le vecteur force dans la vitesse puis la position + sf::Vector2f acceleration = getForces(state) / mass; + velocity += acceleration * state.delta; + position += velocity * state.delta; } sf::Vector2f PhysicsObject::getVelocity() {