This commit is contained in:
sfroitzheim 2015-03-09 19:05:18 +01:00
commit cbb65848d9
5 changed files with 26 additions and 5 deletions

View File

@ -70,7 +70,8 @@ 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,
bool f1Pressed, bool f2Pressed, bool f3Pressed, bool f4Pressed) {
// Ignore first two mouse updates, because they are incorrect
// DON'T try to move this functionallity elsewhere
@ -111,6 +112,19 @@ void Level::update(float runTimeSinceLastUpdate, float runTime, glm::vec2 mouseD
}
}
if(f1Pressed) {
physics.forcePlayer(glm::vec3(17.5, 21.0, 87.0));
}
if(f2Pressed) {
physics.forcePlayer(glm::vec3(-78.5, 21.75, 4.5));
}
if(f3Pressed) {
physics.forcePlayer(glm::vec3(-169.5, 21.5, 58.5));
}
if(f4Pressed) {
physics.forcePlayer(glm::vec3(-180.5, 21.75, 58.5));
}
if(kPressed)
camera.setIsPhysicsCamera(true);
if(lPressed)

View File

@ -25,7 +25,8 @@ class Level {
Level();
~Level();
void load();
void update(float runTimeSinceLastUpdate, float runTime, glm::vec2 mouseDelta,bool wPressed, bool aPressed,bool sPressed, bool dPressed, bool kPressed, bool lPressed);
void update(float runTimeSinceLastUpdate, float runTime, glm::vec2 mouseDelta,bool wPressed, bool aPressed,bool sPressed, bool dPressed, bool kPressed, bool lPressed,
bool f1Pressed, bool f2Pressed, bool f3Pressed, bool f4Pressed );
void render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass,
glm::mat4* viewProjectionMatrix, std::vector<glm::mat4>* shadowVPs=0);
glm::vec3 getAmbientLight();

View File

@ -166,6 +166,10 @@ int main( int argc, char *argv[] )
int stateD = glfwGetKey(window, GLFW_KEY_D);
int stateK = glfwGetKey(window, GLFW_KEY_K);
int stateL = glfwGetKey(window, GLFW_KEY_L);
int stateF1 = glfwGetKey(window, GLFW_KEY_F1);
int stateF2 = glfwGetKey(window, GLFW_KEY_F2);
int stateF3 = glfwGetKey(window, GLFW_KEY_F3);
int stateF4 = glfwGetKey(window, GLFW_KEY_F4);
double xpos, ypos;
glfwGetCursorPos(window, &xpos, &ypos);
@ -173,10 +177,11 @@ int main( int argc, char *argv[] )
app.getLevel()->update(now - lastUpdate, now - gameStart,
glm::vec2((float)ypos-app.getGraphics()->getWindowSize().y/2,
(float)xpos-app.getGraphics()->getWindowSize().x/2),
stateW == GLFW_PRESS,stateA == GLFW_PRESS,stateS == GLFW_PRESS,stateD == GLFW_PRESS,stateK == GLFW_PRESS,stateL == GLFW_PRESS);
stateW == GLFW_PRESS,stateA == GLFW_PRESS,stateS == GLFW_PRESS,stateD == GLFW_PRESS,stateK == GLFW_PRESS,stateL == GLFW_PRESS, stateF1 == GLFW_PRESS,
stateF2 == GLFW_PRESS, stateF3 == GLFW_PRESS, stateF4 == GLFW_PRESS);
}
else {
app.getLevel()->update(now - lastUpdate, now-gameStart, glm::vec2(0.0f, 0.0f), false, false, false, false,false,false);
app.getLevel()->update(now - lastUpdate, now-gameStart, glm::vec2(0.0f, 0.0f), false, false, false, false,false,false,false,false,false,false);
if (app.isLocked()) {
app.ignoredOneMouseUpdate();
}

View File

@ -43,6 +43,7 @@ void Physics::takeUpdateStep(float timeDiff)
currentDirection = playerBall->getCenterOfMassPosition();
currentDirection.setY(0);
currentDirection.normalize();
cameraDistance = 15;
}
btVector3 position = currentDirection;

View File

@ -88,7 +88,7 @@ class Physics {
bool simulationActive = true;
bool sinking = true;
bool endgame = false;
btVector3 currentDirection = btVector3(1,1,1);
btVector3 currentDirection = btVector3(-1,1,1);
btRigidBody* playerBall; //allows for easier access to the ball
btRigidBody* terrainBody; //duh
btRigidBody* cameraBody;