refactor: remove ballSize

pull/25/head
Allison Ryan 4 years ago
parent 6cbda5bac3
commit f2c55a8ecd

@ -12,11 +12,8 @@ class Ball extends PositionBodyComponent<PinballGame, SpriteComponent>
/// {@macro ball} /// {@macro ball}
Ball({ Ball({
required Vector2 position, required Vector2 position,
}) : _position = Vector2(position.x, position.y + ballSize.y), }) : _position = position,
super(size: ballSize); super(size: Vector2.all(2));
/// Dimensions of the [Ball].
static final ballSize = Vector2.all(2);
/// The initial position of the [Ball] body. /// The initial position of the [Ball] body.
final Vector2 _position; final Vector2 _position;
@ -41,7 +38,7 @@ class Ball extends PositionBodyComponent<PinballGame, SpriteComponent>
final bodyDef = BodyDef() final bodyDef = BodyDef()
..userData = this ..userData = this
..position = _position ..position = Vector2(_position.x, _position.y + size.y)
..type = BodyType.dynamic; ..type = BodyType.dynamic;
return world.createBody(bodyDef)..createFixture(fixtureDef); return world.createBody(bodyDef)..createFixture(fixtureDef);

@ -36,7 +36,7 @@ void main() {
final expectedPosition = Vector2( final expectedPosition = Vector2(
position.x, position.x,
position.y + Ball.ballSize.y, position.y + ball.size.y,
); );
expect(ball.body.position, equals(expectedPosition)); expect(ball.body.position, equals(expectedPosition));
}, },

Loading…
Cancel
Save