Merge branch 'main' into feat/bonus-word-effect

pull/44/head^2
Erick 4 years ago committed by GitHub
commit 22910c7c26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -15,6 +15,7 @@ class GameBloc extends Bloc<GameEvent, GameState> {
} }
static const bonusWord = 'GOOGLE'; static const bonusWord = 'GOOGLE';
static const bonusWordScore = 10000;
void _onBallLost(BallLost event, Emitter emit) { void _onBallLost(BallLost event, Emitter emit) {
if (state.balls > 0) { if (state.balls > 0) {
@ -44,6 +45,7 @@ class GameBloc extends Bloc<GameEvent, GameState> {
], ],
), ),
); );
add(const Scored(points: bonusWordScore));
} else { } else {
emit( emit(
state.copyWith(activatedBonusLetters: newBonusLetters), state.copyWith(activatedBonusLetters: newBonusLetters),

@ -74,6 +74,25 @@ class Plunger extends BodyComponent with KeyboardHandler {
return true; return true;
} }
/// Anchors the [Plunger] to the [PrismaticJoint] that controls its vertical
/// motion.
Future<void> _anchorToJoint() async {
final anchor = PlungerAnchor(plunger: this);
await add(anchor);
final jointDef = PlungerAnchorPrismaticJointDef(
plunger: this,
anchor: anchor,
);
world.createJoint(jointDef);
}
@override
Future<void> onLoad() async {
await super.onLoad();
await _anchorToJoint();
}
} }
/// {@template plunger_anchor} /// {@template plunger_anchor}

@ -101,7 +101,6 @@ class PinballGame extends Forge2DGame
} }
Future<void> _addPlunger() async { Future<void> _addPlunger() async {
late PlungerAnchor plungerAnchor;
final compressionDistance = camera.viewport.effectiveSize.y / 12; final compressionDistance = camera.viewport.effectiveSize.y / 12;
await add( await add(
@ -115,14 +114,6 @@ class PinballGame extends Forge2DGame
compressionDistance: compressionDistance, compressionDistance: compressionDistance,
), ),
); );
await add(plungerAnchor = PlungerAnchor(plunger: plunger));
world.createJoint(
PlungerAnchorPrismaticJointDef(
plunger: plunger,
anchor: plungerAnchor,
),
);
} }
Future<void> _addBaseboards() async { Future<void> _addBaseboards() async {

@ -177,6 +177,12 @@ void main() {
activatedBonusLetters: [], activatedBonusLetters: [],
bonusHistory: [GameBonus.word], bonusHistory: [GameBonus.word],
), ),
GameState(
score: GameBloc.bonusWordScore,
balls: 3,
activatedBonusLetters: [],
bonusHistory: [GameBonus.word],
),
], ],
); );
}); });

Loading…
Cancel
Save