Skip to content

Commit

Permalink
Optimize pipe lifting
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Senichev <[email protected]>
  • Loading branch information
artemsen committed Jan 23, 2024
1 parent 91609c7 commit c074bda
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ void Game::draw_puzzle()

// pipes shadow
const int shadow_shift = layout.cell_size / 20;
const int lift_shift = layout.cell_size / 16;
for (size_t y = 0; y < level.height; ++y) {
for (size_t x = 0; x < level.width; ++x) {
const Cell& cell = level.get_cell({ x, y });
Expand All @@ -197,9 +198,9 @@ void Game::draw_puzzle()
continue;
}
if (cell.rotation()) {
const double phase = cell.phase();
dst.x += shadow_shift * sin(M_PI * phase);
dst.y += shadow_shift * sin(M_PI * phase);
const int shift = lift_shift * sin(M_PI * cell.phase());
dst.x += shift;
dst.y += shift;
}
render.draw(tid, dst, cell.angle(), 0.3);
}
Expand Down Expand Up @@ -232,9 +233,9 @@ void Game::draw_puzzle()
continue;
}
if (cell.rotation()) {
const double phase = cell.phase();
dst.x -= shadow_shift * sin(M_PI * phase);
dst.y -= shadow_shift * sin(M_PI * phase);
const int shift = lift_shift * sin(M_PI * cell.phase());
dst.x -= shift;
dst.y -= shift;
}
render.draw(tid, dst, cell.angle());
}
Expand Down

0 comments on commit c074bda

Please sign in to comment.