modified the update in level.cc. Now the ball no longer goes bouncy.

This commit is contained in:
Jasper 2015-03-04 15:04:46 +01:00
parent d0b56e3cf1
commit d03bfb61bc

View File

@ -57,7 +57,6 @@ void Level::render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass,
} }
void Level::update(float runTimeSinceLastUpdate, float runTime, glm::vec2 mouseDelta, bool wPressed, bool aPressed, bool sPressed, bool dPressed,bool kPressed, bool lPressed) { void Level::update(float runTimeSinceLastUpdate, float runTime, glm::vec2 mouseDelta, bool wPressed, bool aPressed, bool sPressed, bool dPressed,bool kPressed, bool lPressed) {
physics.takeUpdateStep(runTimeSinceLastUpdate);
// Ignore first two mouse updates, because they are incorrect // Ignore first two mouse updates, because they are incorrect
// DON'T try to move this functionallity elsewhere // DON'T try to move this functionallity elsewhere
@ -65,25 +64,32 @@ void Level::update(float runTimeSinceLastUpdate, float runTime, glm::vec2 mouseD
if (i <2) { if (i <2) {
i++; i++;
} }
else {
int runs = 2;
for(int j = runs; j > 0; j--)
{
physics.takeUpdateStep(runTimeSinceLastUpdate/runs);
if(i>=2)
{
mouseDelta.x = -mouseDelta.x; mouseDelta.x = -mouseDelta.x;
camera.updateRotation(mouseDelta/100.0f); camera.updateRotation(mouseDelta/100.0f/(float)runs);
physics.updateCameraPos(mouseDelta, 50, camera.getDistance()); physics.updateCameraPos(mouseDelta, 50/runs, camera.getDistance());
camera.setPosition(physics.getCameraPosition()); camera.setPosition(physics.getCameraPosition());
camera.setDirection(physics.getCameraToPlayer()); camera.setDirection(physics.getCameraToPlayer());
} }
if(wPressed){ if(wPressed){
physics.rollForward(camera.getVector(),strength); physics.rollForward(camera.getVector(),strength/runs);
} }
if(aPressed) { if(aPressed) {
physics.rollLeft(camera.getVector(),strength); physics.rollLeft(camera.getVector(),strength/runs);
} }
if(sPressed) { if(sPressed) {
physics.rollBack(camera.getVector(),strength); physics.rollBack(camera.getVector(),strength/runs);
} }
if(dPressed){ if(dPressed){
physics.rollRight(camera.getVector(),strength); physics.rollRight(camera.getVector(),strength/runs);
}
} }
if(kPressed) if(kPressed)