Ensuring triggers don't get triggered in the first two seconds.
This commit is contained in:
parent
f87249b879
commit
1c25df78d5
6
main.cc
6
main.cc
@ -144,7 +144,6 @@ int main( int argc, char *argv[] )
|
|||||||
double showNextFPS = startTimeInSeconds + FPSdelay;
|
double showNextFPS = startTimeInSeconds + FPSdelay;
|
||||||
|
|
||||||
double lastUpdate=0.0f;
|
double lastUpdate=0.0f;
|
||||||
bool gameStarted = false;
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
||||||
@ -159,6 +158,7 @@ int main( int argc, char *argv[] )
|
|||||||
frameCount = 0;
|
frameCount = 0;
|
||||||
}
|
}
|
||||||
if (app.isGameStarted()) {
|
if (app.isGameStarted()) {
|
||||||
|
static float gameStart = now;
|
||||||
if (app.isLocked() && app.getIgnoredMouseUpdates() == 0) {
|
if (app.isLocked() && app.getIgnoredMouseUpdates() == 0) {
|
||||||
int stateW = glfwGetKey(window, GLFW_KEY_W);
|
int stateW = glfwGetKey(window, GLFW_KEY_W);
|
||||||
int stateA = glfwGetKey(window, GLFW_KEY_A);
|
int stateA = glfwGetKey(window, GLFW_KEY_A);
|
||||||
@ -170,13 +170,13 @@ int main( int argc, char *argv[] )
|
|||||||
double xpos, ypos;
|
double xpos, ypos;
|
||||||
glfwGetCursorPos(window, &xpos, &ypos);
|
glfwGetCursorPos(window, &xpos, &ypos);
|
||||||
glfwSetCursorPos(window, app.getGraphics()->getWindowSize().x/2, app.getGraphics()->getWindowSize().y/2);
|
glfwSetCursorPos(window, app.getGraphics()->getWindowSize().x/2, app.getGraphics()->getWindowSize().y/2);
|
||||||
app.getLevel()->update(now - lastUpdate, now,
|
app.getLevel()->update(now - lastUpdate, now - gameStart,
|
||||||
glm::vec2((float)ypos-app.getGraphics()->getWindowSize().y/2,
|
glm::vec2((float)ypos-app.getGraphics()->getWindowSize().y/2,
|
||||||
(float)xpos-app.getGraphics()->getWindowSize().x/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);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
app.getLevel()->update(now - lastUpdate, now, 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);
|
||||||
if (app.isLocked()) {
|
if (app.isLocked()) {
|
||||||
app.ignoredOneMouseUpdate();
|
app.ignoredOneMouseUpdate();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user