diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2022-03-18 23:04:04 -0400 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2022-03-18 23:04:04 -0400 |
| commit | d1ec962c788286d0eca331ac33b3dd1867618ddb (patch) | |
| tree | 75a69270a8e53b68b3e5c721651e63b70b268be2 /src/game.cpp | |
| parent | 4e228fc4ea0189be7f28eba68d59b99841f91aab (diff) | |
| download | ether-d1ec962c788286d0eca331ac33b3dd1867618ddb.tar.gz ether-d1ec962c788286d0eca331ac33b3dd1867618ddb.tar.bz2 ether-d1ec962c788286d0eca331ac33b3dd1867618ddb.zip | |
fixed a lot of the zoom problems
still looks weird while moving
Diffstat (limited to 'src/game.cpp')
| -rw-r--r-- | src/game.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
| 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) | |||
| 163 | moveProgress.start(1000/6); | 163 | moveProgress.start(1000/6); |
| 164 | dirtyLighting = true; | 164 | dirtyLighting = true; |
| 165 | 165 | ||
| 166 | std::cout << player_x << "," << player_y << std::endl; | ||
| 167 | |||
| 166 | int chunkX, chunkY, old_chunkX, old_chunkY; | 168 | int chunkX, chunkY, old_chunkX, old_chunkY; |
| 167 | toChunkPos(player_x, player_y, chunkX, chunkY); | 169 | toChunkPos(player_x, player_y, chunkX, chunkY); |
| 168 | toChunkPos(player_oldx, player_oldy, old_chunkX, old_chunkY); | 170 | toChunkPos(player_oldx, player_oldy, old_chunkX, old_chunkY); |
| @@ -394,7 +396,7 @@ void Game::recalculateRender() { | |||
| 394 | 396 | ||
| 395 | if (wallRenders.at(renderDesc) == TilesetIndex(21, 12) && renderDesc != 255) { | 397 | if (wallRenders.at(renderDesc) == TilesetIndex(21, 12) && renderDesc != 255) { |
| 396 | //std::cout << renderDesc << std::endl; | 398 | //std::cout << renderDesc << std::endl; |
| 397 | std::cout << ((renderDesc & (1 << 7)) ? 'X' : 'O'); | 399 | /*std::cout << ((renderDesc & (1 << 7)) ? 'X' : 'O'); |
| 398 | std::cout << ((renderDesc & (1 << 6)) ? 'X' : 'O'); | 400 | std::cout << ((renderDesc & (1 << 6)) ? 'X' : 'O'); |
| 399 | std::cout << ((renderDesc & (1 << 5)) ? 'X' : 'O'); | 401 | std::cout << ((renderDesc & (1 << 5)) ? 'X' : 'O'); |
| 400 | std::cout << std::endl; | 402 | std::cout << std::endl; |
| @@ -405,7 +407,7 @@ void Game::recalculateRender() { | |||
| 405 | std::cout << ((renderDesc & (1 << 1)) ? 'X' : 'O'); | 407 | std::cout << ((renderDesc & (1 << 1)) ? 'X' : 'O'); |
| 406 | std::cout << ((renderDesc & (1 << 2)) ? 'X' : 'O'); | 408 | std::cout << ((renderDesc & (1 << 2)) ? 'X' : 'O'); |
| 407 | std::cout << ((renderDesc & (1 << 3)) ? 'X' : 'O'); | 409 | std::cout << ((renderDesc & (1 << 3)) ? 'X' : 'O'); |
| 408 | std::cout << std::endl; | 410 | std::cout << std::endl;*/ |
| 409 | } | 411 | } |
| 410 | } | 412 | } |
| 411 | } | 413 | } |
| @@ -562,8 +564,9 @@ void Game::processKickup() | |||
| 562 | } | 564 | } |
| 563 | 565 | ||
| 564 | void Game::loadMap() { | 566 | void Game::loadMap() { |
| 565 | int newChunksHoriz = std::ceil(static_cast<double>(curZoom) * ZOOM_X_FACTOR / CHUNK_WIDTH) + 4; | 567 | double zoomBasis = getZoomBasis(); |
| 566 | int newChunksVert = std::ceil(static_cast<double>(curZoom) * ZOOM_Y_FACTOR / CHUNK_HEIGHT) + 4; | 568 | int newChunksHoriz = std::ceil(zoomBasis * ZOOM_X_FACTOR / CHUNK_WIDTH) + 4; |
| 569 | int newChunksVert = std::ceil(zoomBasis * ZOOM_Y_FACTOR / CHUNK_HEIGHT) + 4; | ||
| 567 | int curPlayerChunkX, curPlayerChunkY; | 570 | int curPlayerChunkX, curPlayerChunkY; |
| 568 | toChunkPos(player_x, player_y, curPlayerChunkX, curPlayerChunkY); | 571 | toChunkPos(player_x, player_y, curPlayerChunkX, curPlayerChunkY); |
| 569 | 572 | ||
| @@ -584,14 +587,14 @@ void Game::loadMap() { | |||
| 584 | 587 | ||
| 585 | void Game::setZoom(size_t zoom) | 588 | void Game::setZoom(size_t zoom) |
| 586 | { | 589 | { |
| 587 | if (zoom == curZoom) | 590 | if (zoom == curZoom || zooming) |
| 588 | { | 591 | { |
| 589 | return; | 592 | return; |
| 590 | } | 593 | } |
| 591 | 594 | ||
| 592 | /*zoomProgress = 0; | 595 | /*zoomProgress = 0; |
| 593 | zoomLength = std::abs(static_cast<long>(zoom - curZoom)) * TILE_WIDTH;*/ | 596 | zoomLength = std::abs(static_cast<long>(zoom - curZoom)) * TILE_WIDTH;*/ |
| 594 | zoomProgress.start(62 * std::abs(static_cast<long>(zoom - curZoom)) * TILE_WIDTH); | 597 | zoomProgress.start(62 * std::abs(static_cast<long>(zoom) - curZoom) * TILE_WIDTH); |
| 595 | oldZoom = curZoom; | 598 | oldZoom = curZoom; |
| 596 | curZoom = zoom; | 599 | curZoom = zoom; |
| 597 | zooming = true; | 600 | zooming = true; |
