diff options
Diffstat (limited to 'src/renderer.cpp')
-rw-r--r-- | src/renderer.cpp | 23 |
1 files changed, 17 insertions, 6 deletions
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 | ||