diff options
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp index 2a1d9ea..ec485e7 100644 --- a/src/main.cpp +++ b/src/main.cpp | |||
@@ -30,20 +30,31 @@ int main() | |||
30 | glfwSwapInterval(1); | 30 | glfwSwapInterval(1); |
31 | glfwSetKeyCallback(window, key_callback); | 31 | glfwSetKeyCallback(window, key_callback); |
32 | 32 | ||
33 | Map* m = new Map("../maps/bigmap.txt"); | 33 | Map* m = new Map("../maps/embarass.txt"); |
34 | Map* m2 = new Map("../maps/cozy.txt"); | 34 | //Map* m2 = new Map("../maps/cozy.txt"); |
35 | 35 | ||
36 | m->setLeftMap(m2); | 36 | //m->setLeftMap(m2); |
37 | m2->setRightMap(m); | 37 | //m2->setRightMap(m); |
38 | 38 | ||
39 | curGameState = new MapView(m, 100, 100); | 39 | curGameState = new MapView(m, 100, 100); |
40 | 40 | ||
41 | Texture* buffer = createTexture(GAME_WIDTH, GAME_HEIGHT); | 41 | Texture* buffer = createTexture(GAME_WIDTH, GAME_HEIGHT); |
42 | 42 | ||
43 | double lastTime = glfwGetTime(); | ||
44 | double accum = 0.0; | ||
45 | |||
43 | while (!(quit || glfwWindowShouldClose(window))) | 46 | while (!(quit || glfwWindowShouldClose(window))) |
44 | { | 47 | { |
45 | // Tick! | 48 | // Tick! |
46 | curGameState->tick(); | 49 | accum += (glfwGetTime() - lastTime); |
50 | if (accum < 0) accum = 0; | ||
51 | while (accum > SECONDS_PER_FRAME) | ||
52 | { | ||
53 | curGameState->tick(); | ||
54 | accum -= SECONDS_PER_FRAME; | ||
55 | } | ||
56 | |||
57 | lastTime = glfwGetTime(); | ||
47 | 58 | ||
48 | // Do rendering | 59 | // Do rendering |
49 | curGameState->render(buffer); | 60 | curGameState->render(buffer); |