Mario: only visit objects if they entered screen at least once

This commit is contained in:
2021-08-07 22:25:32 +02:00
parent f7002f0f38
commit 4f65dba2e0
3 changed files with 17 additions and 1 deletions
+5 -1
View File
@@ -142,8 +142,12 @@ void doInput( std::shared_ptr< SDLPP::Scene > scene ) {
std::lock_guard< std::mutex > lock( render_mutex );
scene->updateScene();
auto prev_coin_count = coin_count;
// TODO only start doing visits once the object has been on screen at least once
auto rightmost_x = renderer->getDoubleDimensions().getX();
for(size_t i = 0; i < moving_objects.size(); i++) {
moving_objects[i]->checkVisibility(rightmost_x);
if(!moving_objects[i]->wasVisible()) {
continue;
}
auto visitor =
getVisitor( *moving_objects[i], *scene, quit, coin_count, moving_objects );
scene->visitCollisions( *moving_objects[i], *visitor );