From d1ec962c788286d0eca331ac33b3dd1867618ddb Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 18 Mar 2022 23:04:04 -0400 Subject: fixed a lot of the zoom problems still looks weird while moving --- src/game.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/game.cpp') diff --git a/src/game.cpp b/src/game.cpp index 08c96ee..8e4dac5 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -163,6 +163,8 @@ bool Game::movePlayer(int x, int y) moveProgress.start(1000/6); dirtyLighting = true; + std::cout << player_x << "," << player_y << std::endl; + int chunkX, chunkY, old_chunkX, old_chunkY; toChunkPos(player_x, player_y, chunkX, chunkY); toChunkPos(player_oldx, player_oldy, old_chunkX, old_chunkY); @@ -394,7 +396,7 @@ void Game::recalculateRender() { if (wallRenders.at(renderDesc) == TilesetIndex(21, 12) && renderDesc != 255) { //std::cout << renderDesc << std::endl; - std::cout << ((renderDesc & (1 << 7)) ? 'X' : 'O'); + /*std::cout << ((renderDesc & (1 << 7)) ? 'X' : 'O'); std::cout << ((renderDesc & (1 << 6)) ? 'X' : 'O'); std::cout << ((renderDesc & (1 << 5)) ? 'X' : 'O'); std::cout << std::endl; @@ -405,7 +407,7 @@ void Game::recalculateRender() { std::cout << ((renderDesc & (1 << 1)) ? 'X' : 'O'); std::cout << ((renderDesc & (1 << 2)) ? 'X' : 'O'); std::cout << ((renderDesc & (1 << 3)) ? 'X' : 'O'); - std::cout << std::endl; + std::cout << std::endl;*/ } } } @@ -562,8 +564,9 @@ void Game::processKickup() } void Game::loadMap() { - int newChunksHoriz = std::ceil(static_cast(curZoom) * ZOOM_X_FACTOR / CHUNK_WIDTH) + 4; - int newChunksVert = std::ceil(static_cast(curZoom) * ZOOM_Y_FACTOR / CHUNK_HEIGHT) + 4; + double zoomBasis = getZoomBasis(); + int newChunksHoriz = std::ceil(zoomBasis * ZOOM_X_FACTOR / CHUNK_WIDTH) + 4; + int newChunksVert = std::ceil(zoomBasis * ZOOM_Y_FACTOR / CHUNK_HEIGHT) + 4; int curPlayerChunkX, curPlayerChunkY; toChunkPos(player_x, player_y, curPlayerChunkX, curPlayerChunkY); @@ -584,14 +587,14 @@ void Game::loadMap() { void Game::setZoom(size_t zoom) { - if (zoom == curZoom) + if (zoom == curZoom || zooming) { return; } /*zoomProgress = 0; zoomLength = std::abs(static_cast(zoom - curZoom)) * TILE_WIDTH;*/ - zoomProgress.start(62 * std::abs(static_cast(zoom - curZoom)) * TILE_WIDTH); + zoomProgress.start(62 * std::abs(static_cast(zoom) - curZoom) * TILE_WIDTH); oldZoom = curZoom; curZoom = zoom; zooming = true; -- cgit 1.4.1