summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2022-03-14 17:55:38 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2022-03-14 17:55:38 -0400
commita3b8f0972ea1bbaa456a0c3ae70621e91a2c3ce7 (patch)
treeb898e9b1e22afa6529a62a30e89d007a61e9a9c1 /src
parent7e89f42c388b92f264f58c4750e8529745a1f9f4 (diff)
downloadether-a3b8f0972ea1bbaa456a0c3ae70621e91a2c3ce7.tar.gz
ether-a3b8f0972ea1bbaa456a0c3ae70621e91a2c3ce7.tar.bz2
ether-a3b8f0972ea1bbaa456a0c3ae70621e91a2c3ce7.zip
fixed flickering while walking
sort of. the (intentional) dust flicker is still there. might want to remove the player trailing dust as they walk.
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp2
-rw-r--r--src/renderer.cpp23
2 files changed, 18 insertions, 7 deletions
diff --git a/src/game.cpp b/src/game.cpp index af57b56..beabc55 100644 --- a/src/game.cpp +++ b/src/game.cpp
@@ -138,7 +138,7 @@ bool Game::movePlayer(int x, int y)
138 player_y = y; 138 player_y = y;
139 muxer.setPlayerLoc(x, y); 139 muxer.setPlayerLoc(x, y);
140 moving = true; 140 moving = true;
141 moveProgress.start(66); 141 moveProgress.start(1000/6);
142 dirtyLighting = true; 142 dirtyLighting = true;
143 143
144 int chunkX, chunkY, old_chunkX, old_chunkY; 144 int chunkX, chunkY, old_chunkX, old_chunkY;
diff --git a/src/renderer.cpp b/src/renderer.cpp index 1f51e0a..61aaf31 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp
@@ -251,9 +251,20 @@ void Renderer::renderGame(
251 251
252 int posToUseX = x - leftmost; 252 int posToUseX = x - leftmost;
253 int posToUseY = y - topmost; 253 int posToUseY = y - topmost;
254 int xInterp = 0;
255 int yInterp = 0;
254 if (game.map.at(x,y).lightType == Source::Player && game.moving) { 256 if (game.map.at(x,y).lightType == Source::Player && game.moving) {
255 posToUseX = game.moveProgress.getProgress((game.player_oldx) - leftmost, posToUseX); 257 if (game.player_x > game.player_oldx) {
256 posToUseY = game.moveProgress.getProgress((game.player_oldy) - topmost, posToUseY); 258 xInterp = game.moveProgress.getProgress(-TILE_WIDTH, 0);
259 } else if (game.player_x < game.player_oldx) {
260 xInterp = game.moveProgress.getProgress(TILE_WIDTH, 0);
261 }
262
263 if (game.player_y > game.player_oldy) {
264 yInterp = game.moveProgress.getProgress(-TILE_HEIGHT, 0);
265 } else if (game.player_y < game.player_oldy) {
266 yInterp = game.moveProgress.getProgress(TILE_HEIGHT, 0);
267 }
257 } 268 }
258 269
259 int fadeX = posToUseX - game.map.at(x,y).lightRadius; 270 int fadeX = posToUseX - game.map.at(x,y).lightRadius;
@@ -262,8 +273,8 @@ void Renderer::renderGame(
262 int fadeBottom = posToUseY + game.map.at(x,y).lightRadius; 273 int fadeBottom = posToUseY + game.map.at(x,y).lightRadius;
263 274
264 SDL_Rect fadeRect { 275 SDL_Rect fadeRect {
265 fadeX * TILE_WIDTH, 276 fadeX * TILE_WIDTH + xInterp,
266 fadeY * TILE_HEIGHT, 277 fadeY * TILE_HEIGHT + yInterp,
267 (game.map.at(x,y).lightRadius * 2 + 1) * TILE_WIDTH, 278 (game.map.at(x,y).lightRadius * 2 + 1) * TILE_WIDTH,
268 (game.map.at(x,y).lightRadius * 2 + 1) * TILE_HEIGHT}; 279 (game.map.at(x,y).lightRadius * 2 + 1) * TILE_HEIGHT};
269 280
@@ -288,8 +299,8 @@ void Renderer::renderGame(
288 if (!game.map.at(x,y).litTiles.count({sx, sy})) 299 if (!game.map.at(x,y).litTiles.count({sx, sy}))
289 { 300 {
290 SDL_Rect rect { 301 SDL_Rect rect {
291 (sx - leftmost) * TILE_WIDTH, 302 (sx - leftmost) * TILE_WIDTH + xInterp,
292 (sy - topmost) * TILE_HEIGHT, 303 (sy - topmost) * TILE_HEIGHT + yInterp,
293 TILE_WIDTH, 304 TILE_WIDTH,
294 TILE_HEIGHT}; 305 TILE_HEIGHT};
295 306