|
@@ -25,7 +25,7 @@ void application::setup()
|
|
|
this->millisecsPreviousFrame = SDL_GetTicks();
|
|
|
|
|
|
this->particles.push_back(new particle(50, 100, 1.0, 4));
|
|
|
- this->particles.push_back(new particle(200, 100, 3.0, 12));
|
|
|
+ //this->particles.push_back(new particle(200, 100, 3.0, 12));
|
|
|
}
|
|
|
|
|
|
void application::input()
|
|
@@ -47,6 +47,20 @@ void application::input()
|
|
|
{
|
|
|
this->running = false;
|
|
|
}
|
|
|
+
|
|
|
+ if (event.key.keysym.sym == SDLK_UP) this->pushForce.y = -50 * PIXELS_PER_METER;
|
|
|
+ if (event.key.keysym.sym == SDLK_RIGHT) this->pushForce.x = 50 * PIXELS_PER_METER;
|
|
|
+ if (event.key.keysym.sym == SDLK_DOWN) this->pushForce.y = 50 * PIXELS_PER_METER;
|
|
|
+ if (event.key.keysym.sym == SDLK_LEFT) this->pushForce.x = -50 * PIXELS_PER_METER;
|
|
|
+
|
|
|
+ break;
|
|
|
+
|
|
|
+ case SDL_KEYUP:
|
|
|
+ if (event.key.keysym.sym == SDLK_UP) this->pushForce.y = 0;
|
|
|
+ if (event.key.keysym.sym == SDLK_RIGHT) this->pushForce.x = 0;
|
|
|
+ if (event.key.keysym.sym == SDLK_DOWN) this->pushForce.y = 0;
|
|
|
+ if (event.key.keysym.sym == SDLK_LEFT) this->pushForce.x = 0;
|
|
|
+
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -88,6 +102,7 @@ void application::update()
|
|
|
for (auto part:this->particles)
|
|
|
{
|
|
|
part->addForce(wind);
|
|
|
+ part->addForce(this->pushForce);
|
|
|
part->addForce(weight * part->mass);
|
|
|
part->integrate(deltaTime);
|
|
|
|