summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2022-03-14 20:34:47 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2022-03-14 20:34:47 -0400
commitc3055098edaec16f844fc21731ecf391c8fefe33 (patch)
tree98389090978b7a7a5c65183fc04b33b48c8812b1 /src
parentbcefc1e2d87d57aaf6ae5ef8a05946081d259e41 (diff)
downloadether-c3055098edaec16f844fc21731ecf391c8fefe33.tar.gz
ether-c3055098edaec16f844fc21731ecf391c8fefe33.tar.bz2
ether-c3055098edaec16f844fc21731ecf391c8fefe33.zip
fixed weird shadows while moving
Diffstat (limited to 'src')
-rw-r--r--src/renderer.cpp26
-rw-r--r--src/renderer.h2
2 files changed, 2 insertions, 26 deletions
diff --git a/src/renderer.cpp b/src/renderer.cpp index 139b493..87e6553 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp
@@ -299,8 +299,8 @@ void Renderer::renderGame(
299 if (!game.map.at(x,y).litTiles.count({sx, sy})) 299 if (!game.map.at(x,y).litTiles.count({sx, sy}))
300 { 300 {
301 SDL_Rect rect { 301 SDL_Rect rect {
302 (sx - leftmost) * TILE_WIDTH + xInterp, 302 (sx - leftmost) * TILE_WIDTH,
303 (sy - topmost) * TILE_HEIGHT + yInterp, 303 (sy - topmost) * TILE_HEIGHT,
304 TILE_WIDTH, 304 TILE_WIDTH,
305 TILE_HEIGHT}; 305 TILE_HEIGHT};
306 306
@@ -390,28 +390,6 @@ void Renderer::renderTitle(int num, double fade) {
390 SDL_RenderPresent(ren_.get()); 390 SDL_RenderPresent(ren_.get());
391} 391}
392 392
393std::tuple<int, int, int, int> Renderer::calculateZoomRect(const Game& game)
394{
395 int w = game.curZoom * TILE_WIDTH * ZOOM_X_FACTOR;
396 int h = game.curZoom * TILE_HEIGHT * ZOOM_Y_FACTOR;
397 int x = (game.map.getTrueX(game.player_x) * TILE_WIDTH) - (w / 2);
398 int y = (game.map.getTrueY(game.player_y) * TILE_HEIGHT) - (h / 2);
399
400 /*if (game.zooming)
401 {
402 double interp =
403 static_cast<double>(game.zoomProgress) /
404 static_cast<double>(game.zoomLength);
405
406 x = (x - game.lastZoomLeft) * interp + game.lastZoomLeft;
407 y = (y - game.lastZoomTop) * interp + game.lastZoomTop;
408 w = (w - game.lastZoomWidth) * interp + game.lastZoomWidth;
409 h = (h - game.lastZoomHeight) * interp + game.lastZoomHeight;
410 }*/
411
412 return {x, y, w, h};
413}
414
415void Renderer::loadTextureFromFile(std::string_view path, texture_ptr& texture) { 393void Renderer::loadTextureFromFile(std::string_view path, texture_ptr& texture) {
416 surface_ptr pfs(IMG_Load(path.data())); 394 surface_ptr pfs(IMG_Load(path.data()));
417 if (!pfs) 395 if (!pfs)
diff --git a/src/renderer.h b/src/renderer.h index 4d5484c..1364550 100644 --- a/src/renderer.h +++ b/src/renderer.h
@@ -122,8 +122,6 @@ public:
122 122
123 void renderTitle(int num, double fade); 123 void renderTitle(int num, double fade);
124 124
125 static std::tuple<int, int, int, int> calculateZoomRect(const Game& game);
126
127private: 125private:
128 126
129 void loadTextureFromFile(std::string_view path, texture_ptr& texture); 127 void loadTextureFromFile(std::string_view path, texture_ptr& texture);