|
@@ -17,6 +17,9 @@
|
|
|
#include <physics/vec2.h>
|
|
|
#include <physics/force.h>
|
|
|
|
|
|
+#include <physics/shape.h>
|
|
|
+#include <physics/shapes/circle.h>
|
|
|
+
|
|
|
#include <SDL.h>
|
|
|
|
|
|
void application::parseParameters(int argc, char *argv[])
|
|
@@ -30,8 +33,8 @@ void application::setup()
|
|
|
this->millisecsPreviousFrame = SDL_GetTicks();
|
|
|
|
|
|
this->anchor = vec2(graphics::width() / 2.0,30);
|
|
|
- this->bodies.push_back(new body(graphics::width() / 2.0, graphics::height() / 2.0,
|
|
|
- 2.0, 10));
|
|
|
+ this->bodies.push_back(new body(circleShape(12), graphics::width() / 2.0, graphics::height() / 2.0,
|
|
|
+ 2.0));
|
|
|
}
|
|
|
|
|
|
void application::input()
|
|
@@ -163,40 +166,6 @@ void application::update()
|
|
|
part->integrate(deltaTime);
|
|
|
}
|
|
|
|
|
|
- for (auto part:this->bodies)
|
|
|
- {
|
|
|
- // check the bodies position and keep the body in the window.
|
|
|
- if ( ((part->position.y - part->radius) <= 0) ||
|
|
|
- ((part->position.y + part->radius) >= graphics::height()))
|
|
|
- {
|
|
|
- if ((part->position.y - part->radius) <= 0)
|
|
|
- {
|
|
|
- part->position.y = part->radius;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- part->position.y = graphics::height() - part->radius;
|
|
|
- }
|
|
|
-
|
|
|
- part->velocity.y = -part->velocity.y;
|
|
|
- }
|
|
|
-
|
|
|
- if ( ((part->position.x - part->radius) <= 0) ||
|
|
|
- ((part->position.x + part->radius) >= graphics::width()))
|
|
|
- {
|
|
|
- if ((part->position.x - part->radius) <= 0)
|
|
|
- {
|
|
|
- part->position.x = part->radius;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- part->position.x = graphics::width() - part->radius;
|
|
|
- }
|
|
|
-
|
|
|
- part->velocity.x = -part->velocity.x;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
updateTime.stop();
|
|
|
}
|
|
|
|
|
@@ -216,15 +185,16 @@ void application::render()
|
|
|
0xFF313131);
|
|
|
graphics::draw::fillCircle(this->anchor.x, this->anchor.y, 5, 0xFF001155);
|
|
|
|
|
|
- for(auto part: this->bodies)
|
|
|
+ /*
|
|
|
+ for(auto bod: this->bodies)
|
|
|
{
|
|
|
- graphics::draw::fillCircle(part->position.x, part->position.y, part->radius, 0xFFAA3300);
|
|
|
+ graphics::draw::fillCircle(bod->position.x, bod->position.y, bod->radius, 0xFFAA3300);
|
|
|
}
|
|
|
+ */
|
|
|
|
|
|
-
|
|
|
- for(auto part: this->bodies)
|
|
|
+ for(auto bod: this->bodies)
|
|
|
{
|
|
|
- part->forceDebug(this->showVelocity, this->showForceSum, this->showAllForces);
|
|
|
+ bod->forceDebug(this->showVelocity, this->showForceSum, this->showAllForces);
|
|
|
}
|
|
|
|
|
|
graphics::draw::text(5, 5, 0x11FF22, "Wait time: %02.2f ms", waitTime.get());
|