refactor: position ball internally

pull/25/head
Allison Ryan 4 years ago
parent 45b6d6b634
commit 1ee76a1dfb

@ -7,7 +7,7 @@ class Ball extends PositionBodyComponent<PinballGame, SpriteComponent>
with BlocComponent<GameBloc, GameState> { with BlocComponent<GameBloc, GameState> {
Ball({ Ball({
required Vector2 position, required Vector2 position,
}) : _position = position, }) : _position = Vector2(position.x, position.y + ballSize.y),
super(size: ballSize); super(size: ballSize);
static final ballSize = Vector2.all(2); static final ballSize = Vector2.all(2);

@ -44,14 +44,7 @@ class PinballGame extends Forge2DGame
} }
void spawnBall() { void spawnBall() {
add( add(Ball(position: plunger.body.position));
Ball(
position: Vector2(
plunger.body.position.x,
plunger.body.position.y + Ball.ballSize.y,
),
),
);
} }
void _addContactCallbacks() { void _addContactCallbacks() {
@ -138,7 +131,7 @@ class PinballGame extends Forge2DGame
position: screenToWorld( position: screenToWorld(
Vector2( Vector2(
camera.viewport.effectiveSize.x - 30, camera.viewport.effectiveSize.x - 30,
camera.viewport.effectiveSize.y - Plunger.compressionDistance, camera.viewport.effectiveSize.y,
), ),
), ),
), ),

Loading…
Cancel
Save