From 2c3a73d5563657d598e2fe36c7fb8c948a8620f2 Mon Sep 17 00:00:00 2001 From: Fabian Klemp Date: Mon, 9 Mar 2015 18:35:11 +0100 Subject: [PATCH] Added cheating teleport for presentation. --- level.cc | 16 +++++++++++++++- level.hh | 3 ++- main.cc | 9 +++++++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/level.cc b/level.cc index ec7eaf7..0659e18 100644 --- a/level.cc +++ b/level.cc @@ -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) diff --git a/level.hh b/level.hh index 5811b9e..60cf960 100644 --- a/level.hh +++ b/level.hh @@ -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* shadowVPs=0); glm::vec3 getAmbientLight(); diff --git a/main.cc b/main.cc index 318ed04..a02c794 100644 --- a/main.cc +++ b/main.cc @@ -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(); }