From 90c8a0566c9c7c5c9ba05e139730ed99433d0b8d Mon Sep 17 00:00:00 2001 From: marco Date: Wed, 22 Sep 2021 16:31:32 -0600 Subject: [PATCH] Fixed #19 so that the backgrounds stay in position when resized on a game over. --- lib/circuit_background.dart | 15 ++++++++------- lib/runner.dart | 6 +++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/circuit_background.dart b/lib/circuit_background.dart index 661713a..da2f3b5 100644 --- a/lib/circuit_background.dart +++ b/lib/circuit_background.dart @@ -377,17 +377,18 @@ class CircuitBackground extends MovingObject { @override void resize(Vector2 newSize, double xRatio, double yRatio) { - background1Size = - Vector2(newSize.y * (background.width / background.height), newSize.y); + background1Position.x *= xRatio; + background1Position.y *= yRatio; + background1Size.x *= xRatio; + background1Size.y *= yRatio; + background2Position.x *= xRatio; + background2Position.y *= yRatio; + background2Size.x *= xRatio; + background2Size.y *= yRatio; windowA.position = background1Position; windowA.size = background1Size; overlayA.position = background1Position; overlayA.size = background1Size; - - background2Position = - Vector2(background1Position.x + background1Size.x - 1, 0); - background2Size = - Vector2(newSize.y * (background.width / background.height), newSize.y); windowB.position = background2Position; windowB.size = background2Size; overlayB.position = background2Position; diff --git a/lib/runner.dart b/lib/runner.dart index 12b3f45..1dc25d6 100644 --- a/lib/runner.dart +++ b/lib/runner.dart @@ -458,14 +458,14 @@ class Runner extends Component with HasGameRef { } } - for (List debrisLevel in gameRef.wallHolder.objects) { - for (int i = 0; i < debrisLevel.length; i++) { + for (List wallLevel in gameRef.wallHolder.objects) { + for (int i = 0; i < wallLevel.length; i++) { Rect slim = Rect.fromLTRB( runnerRect.left + sprite.width / 3, runnerRect.top + sprite.height / (runnerState == "duck" ? 3 : 6), runnerRect.right - sprite.width / 3, runnerRect.bottom - sprite.height / 3); - String intersectState = debrisLevel[i].intersect(slim); + String intersectState = wallLevel[i].intersect(slim); if (intersectState == "none") { continue; } else {