diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2022-03-19 09:57:04 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2022-03-19 09:57:04 -0400 |
commit | 0a39ccd0b0c5b855fa7b5dea2082ced774923a62 (patch) | |
tree | 266127270f4a706ed6a378c0c58116022b6fa3f1 /src/game.cpp | |
parent | d1ec962c788286d0eca331ac33b3dd1867618ddb (diff) | |
download | ether-0a39ccd0b0c5b855fa7b5dea2082ced774923a62.tar.gz ether-0a39ccd0b0c5b855fa7b5dea2082ced774923a62.tar.bz2 ether-0a39ccd0b0c5b855fa7b5dea2082ced774923a62.zip |
load line lag is better
Diffstat (limited to 'src/game.cpp')
-rw-r--r-- | src/game.cpp | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/src/game.cpp b/src/game.cpp index 8e4dac5..31c682c 100644 --- a/src/game.cpp +++ b/src/game.cpp | |||
@@ -15,6 +15,9 @@ Game::Game(std::mt19937& rng, Muxer& muxer, Renderer& renderer) : | |||
15 | losePopLampTimer.accumulate(losePopLampTimer.getDt()); | 15 | losePopLampTimer.accumulate(losePopLampTimer.getDt()); |
16 | 16 | ||
17 | loadMap(); | 17 | loadMap(); |
18 | tick(); | ||
19 | tick(); | ||
20 | tick(); | ||
18 | 21 | ||
19 | for (int y = -1; y <= 1; y++) | 22 | for (int y = -1; y <= 1; y++) |
20 | { | 23 | { |
@@ -105,6 +108,27 @@ void Game::tickDirty(bool onlyDark) { | |||
105 | std::swap(map.tiles(), mapDoubleBuffer); | 108 | std::swap(map.tiles(), mapDoubleBuffer); |
106 | } | 109 | } |
107 | 110 | ||
111 | void Game::tickOuter(bool onlyDark) { | ||
112 | mapDoubleBuffer = map.tiles(); | ||
113 | map.resetDirty(); | ||
114 | |||
115 | for (int y = 0; y < CHUNK_HEIGHT + 2; y++) { | ||
116 | for (int x = map.getLeft(); x < map.getRight(); x++) { | ||
117 | tickIndividual(*this, mapDoubleBuffer, x, map.getTop() + y, onlyDark); | ||
118 | tickIndividual(*this, mapDoubleBuffer, x, map.getBottom() - 1 - y, onlyDark); | ||
119 | } | ||
120 | } | ||
121 | |||
122 | for (int x = 0; x < CHUNK_WIDTH + 2; x++) { | ||
123 | for (int y = map.getTop() + CHUNK_HEIGHT + 2; y < map.getBottom() - CHUNK_HEIGHT - 2; y++) { | ||
124 | tickIndividual(*this, mapDoubleBuffer, map.getLeft() + x, y, onlyDark); | ||
125 | tickIndividual(*this, mapDoubleBuffer, map.getRight() - 1 - x, y, onlyDark); | ||
126 | } | ||
127 | } | ||
128 | |||
129 | std::swap(map.tiles(), mapDoubleBuffer); | ||
130 | } | ||
131 | |||
108 | void Game::tick( | 132 | void Game::tick( |
109 | int x1, | 133 | int x1, |
110 | int y1, | 134 | int y1, |
@@ -577,10 +601,7 @@ void Game::loadMap() { | |||
577 | newChunksVert, | 601 | newChunksVert, |
578 | rng); | 602 | rng); |
579 | 603 | ||
580 | tick(); | 604 | ticksNeeded = 3; |
581 | tick(); | ||
582 | tick(); | ||
583 | |||
584 | dirtyLighting = true; | 605 | dirtyLighting = true; |
585 | dirtyRender = true; | 606 | dirtyRender = true; |
586 | } | 607 | } |
@@ -909,6 +930,14 @@ void Game::updatePlaying(size_t frameTime) { | |||
909 | } | 930 | } |
910 | } | 931 | } |
911 | 932 | ||
933 | if (ticksNeeded > 0) { | ||
934 | gradualTickTimer.accumulate(frameTime); | ||
935 | if (gradualTickTimer.step()) { | ||
936 | ticksNeeded--; | ||
937 | tickOuter(); | ||
938 | } | ||
939 | } | ||
940 | |||
912 | if (dirtyLighting) | 941 | if (dirtyLighting) |
913 | { | 942 | { |
914 | recalculateLighting(); | 943 | recalculateLighting(); |