feat: plunger story

pull/152/head
RuiAlonso 4 years ago
parent 59ea135133
commit b15517a56d

@ -21,5 +21,6 @@ void main() {
addChromeDinoStories(dashbook);
addDashNestBumperStories(dashbook);
addKickerStories(dashbook);
addPlungerStories(dashbook);
runApp(dashbook);
}

@ -0,0 +1,33 @@
import 'package:flame/input.dart';
import 'package:flutter/material.dart';
import 'package:pinball_components/pinball_components.dart';
import 'package:sandbox/common/common.dart';
import 'package:sandbox/stories/ball/basic_ball_game.dart';
class PlungerGame extends BasicBallGame with HasKeyboardHandlerComponents {
PlungerGame({
required this.trace,
}) : super(color: const Color(0xFFFF0000));
static const info = '''
Shows how Plunger is rendered.
- Activate the "trace" parameter to overlay the body.
- Tap anywhere on the screen to spawn a ball into the game.
''';
final bool trace;
@override
Future<void> onLoad() async {
await super.onLoad();
final center = screenToWorld(camera.viewport.canvasSize! / 2);
final plunger = Plunger(compressionDistance: 29)
..initialPosition = Vector2(center.x - (Kicker.size.x * 2), center.y);
await add(plunger);
if (trace) plunger.trace();
}
}

@ -0,0 +1,17 @@
import 'package:dashbook/dashbook.dart';
import 'package:flame/game.dart';
import 'package:sandbox/common/common.dart';
import 'package:sandbox/stories/plunger/plunger_game.dart';
void addPlungerStories(Dashbook dashbook) {
dashbook.storiesOf('Plunger').add(
'Basic',
(context) => GameWidget(
game: PlungerGame(
trace: context.boolProperty('Trace', true),
),
),
codeLink: buildSourceLink('plunger_game/basic.dart'),
info: PlungerGame.info,
);
}

@ -5,4 +5,5 @@ export 'dash_nest_bumper/stories.dart';
export 'effects/stories.dart';
export 'flipper/stories.dart';
export 'layer/stories.dart';
export 'plunger/stories.dart';
export 'spaceship/stories.dart';

Loading…
Cancel
Save