mirror of https://github.com/flutter/pinball.git
feat: add `Baseboard` assets (#106)
* feat: add baseboard assets * refactor: move to components package * test: coverage fix * chore: small suggestions * refactor: adjust size * style: make angle readablepull/133/head
parent
83e6cb892b
commit
90588d95c4
After Width: | Height: | Size: 63 KiB |
After Width: | Height: | Size: 64 KiB |
@ -0,0 +1,15 @@
|
|||||||
|
import 'package:dashbook/dashbook.dart';
|
||||||
|
import 'package:flame/game.dart';
|
||||||
|
import 'package:sandbox/common/common.dart';
|
||||||
|
import 'package:sandbox/stories/baseboard/basic.dart';
|
||||||
|
|
||||||
|
void addBaseboardStories(Dashbook dashbook) {
|
||||||
|
dashbook.storiesOf('Baseboard').add(
|
||||||
|
'Basic',
|
||||||
|
(context) => GameWidget(
|
||||||
|
game: BasicBaseboardGame(),
|
||||||
|
),
|
||||||
|
codeLink: buildSourceLink('baseboard/basic.dart'),
|
||||||
|
info: BasicBaseboardGame.info,
|
||||||
|
);
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
import 'package:flame_forge2d/flame_forge2d.dart';
|
||||||
|
import 'package:pinball_components/pinball_components.dart';
|
||||||
|
import 'package:sandbox/common/common.dart';
|
||||||
|
|
||||||
|
class BasicBaseboardGame extends BasicGame {
|
||||||
|
static const info = '''
|
||||||
|
Basic example of how a Baseboard works.
|
||||||
|
''';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> onLoad() async {
|
||||||
|
await super.onLoad();
|
||||||
|
|
||||||
|
final center = screenToWorld(camera.viewport.canvasSize! / 2);
|
||||||
|
|
||||||
|
final leftBaseboard = Baseboard(side: BoardSide.left)
|
||||||
|
..initialPosition = center - Vector2(25, 0);
|
||||||
|
final rightBaseboard = Baseboard(side: BoardSide.right)
|
||||||
|
..initialPosition = center + Vector2(25, 0);
|
||||||
|
|
||||||
|
await addAll([
|
||||||
|
leftBaseboard,
|
||||||
|
rightBaseboard,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,5 @@
|
|||||||
export 'ball/ball.dart';
|
export 'ball/ball.dart';
|
||||||
|
export 'baseboard/baseboard.dart';
|
||||||
|
export 'effects/effects.dart';
|
||||||
export 'flipper/flipper.dart';
|
export 'flipper/flipper.dart';
|
||||||
export 'layer/layer.dart';
|
export 'layer/layer.dart';
|
||||||
|
Loading…
Reference in new issue