Only register keypresses after loading which are not escape.

This commit is contained in:
Faerbit 2015-03-15 15:02:30 +01:00
parent dd9997dc82
commit 5d52c9cdaf

View File

@ -13,7 +13,7 @@ static void resizeCallback(GLFWwindow* window, int newWidth, int newHeight)
static void keyCallback(GLFWwindow* _window, int _key, int, int _action, int) static void keyCallback(GLFWwindow* _window, int _key, int, int _action, int)
{ {
if (!app.isGameStarted() && _action == GLFW_PRESS) { if (!app.isGameStarted() && _action == GLFW_PRESS && _key != GLFW_KEY_ESCAPE) {
app.startGame(); app.startGame();
} }
if (_key == GLFW_KEY_ESCAPE && _action == GLFW_PRESS) { if (_key == GLFW_KEY_ESCAPE && _action == GLFW_PRESS) {
@ -145,10 +145,7 @@ int main( int argc, char *argv[] )
glfwSetInputMode(window, GLFW_STICKY_KEYS, 1); glfwSetInputMode(window, GLFW_STICKY_KEYS, 1);
// set Callbacks // set Callbacks
glfwSetWindowSizeCallback(window, resizeCallback); glfwSetWindowSizeCallback(window, resizeCallback);
glfwSetKeyCallback(window, keyCallback );
glfwSetScrollCallback(window, scrollCallback );
glfwSetWindowFocusCallback(window, focusCallback); glfwSetWindowFocusCallback(window, focusCallback);
glfwSetMouseButtonCallback(window, mouseCallback);
// Enable vertical sync (on cards that support it) with parameter 1 - 0 means off // Enable vertical sync (on cards that support it) with parameter 1 - 0 means off
glfwSwapInterval( 0 ); glfwSwapInterval( 0 );
@ -158,6 +155,10 @@ int main( int argc, char *argv[] )
glfwSwapBuffers(window); glfwSwapBuffers(window);
app.initLevel(); app.initLevel();
glfwSetKeyCallback(window, keyCallback );
glfwSetScrollCallback(window, scrollCallback );
glfwSetMouseButtonCallback(window, mouseCallback);
int frameCount = 0; int frameCount = 0;
const double FPSdelay = 2.0; const double FPSdelay = 2.0;