diff --git a/lib/game/components/ball.dart b/lib/game/components/ball.dart index 6a06af47..a73b3a86 100644 --- a/lib/game/components/ball.dart +++ b/lib/game/components/ball.dart @@ -12,11 +12,8 @@ class Ball extends PositionBodyComponent /// {@macro ball} Ball({ required Vector2 position, - }) : _position = Vector2(position.x, position.y + ballSize.y), - super(size: ballSize); - - /// Dimensions of the [Ball]. - static final ballSize = Vector2.all(2); + }) : _position = position, + super(size: Vector2.all(2)); /// The initial position of the [Ball] body. final Vector2 _position; @@ -41,7 +38,7 @@ class Ball extends PositionBodyComponent final bodyDef = BodyDef() ..userData = this - ..position = _position + ..position = Vector2(_position.x, _position.y + size.y) ..type = BodyType.dynamic; return world.createBody(bodyDef)..createFixture(fixtureDef); diff --git a/test/game/components/ball_test.dart b/test/game/components/ball_test.dart index e91484f9..bd9f73e9 100644 --- a/test/game/components/ball_test.dart +++ b/test/game/components/ball_test.dart @@ -36,7 +36,7 @@ void main() { final expectedPosition = Vector2( position.x, - position.y + Ball.ballSize.y, + position.y + ball.size.y, ); expect(ball.body.position, equals(expectedPosition)); },