From bccce10cdb76796d9b94fd0f9689216adfd59a32 Mon Sep 17 00:00:00 2001 From: alestiago Date: Mon, 7 Mar 2022 17:52:10 +0000 Subject: [PATCH] refactor: used isLeft instead of isRight --- lib/game/components/flipper.dart | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/game/components/flipper.dart b/lib/game/components/flipper.dart index f0aebe6d..0691da34 100644 --- a/lib/game/components/flipper.dart +++ b/lib/game/components/flipper.dart @@ -76,13 +76,13 @@ class Flipper extends BodyComponent { List _createFixtureDefs() { final fixtures = []; - final isRight = side.isRight; + final isLeft = side.isLeft; const bigRadius = height / 2; final bigCircleShape = CircleShape() ..radius = bigRadius ..position.setValues( - isRight ? width - bigRadius : bigRadius, + isLeft ? bigRadius : width - bigRadius, -bigRadius, ); final bigCircleFixtureDef = FixtureDef(bigCircleShape); @@ -92,25 +92,25 @@ class Flipper extends BodyComponent { final smallCircleShape = CircleShape() ..radius = smallRadius ..position.setValues( - isRight ? smallRadius : width - smallRadius, + isLeft ? width - smallRadius : smallRadius, -2 * smallRadius, ); final smallCircleFixtureDef = FixtureDef(smallCircleShape); fixtures.add(smallCircleFixtureDef); const inclineSpace = (height - (2 * smallRadius)) / 2; - final trapeziumVertices = isRight + final trapeziumVertices = isLeft ? [ - Vector2(smallRadius, -inclineSpace), - Vector2(width - bigRadius, 0), - Vector2(width - bigRadius, -height), - Vector2(smallRadius, -height + inclineSpace), - ] - : [ Vector2(bigCircleShape.radius, 0), Vector2(width - smallCircleShape.radius, -inclineSpace), Vector2(width - smallCircleShape.radius, -height + inclineSpace), Vector2(bigCircleShape.radius, -height), + ] + : [ + Vector2(smallRadius, -inclineSpace), + Vector2(width - bigRadius, 0), + Vector2(width - bigRadius, -height), + Vector2(smallRadius, -height + inclineSpace), ]; final trapezium = PolygonShape()..set(trapeziumVertices); final trapeziumFixtureDef = FixtureDef(trapezium) @@ -180,7 +180,7 @@ class FlipperAnchorRevoluteJointDef extends RevoluteJointDef { ); enableLimit = true; - final angle = flipper.side.isRight ? -_sweepingAngle : _sweepingAngle; + final angle = flipper.side.isLeft ? _sweepingAngle : -_sweepingAngle; lowerAngle = angle; upperAngle = angle; }