fix: sanbox stories (#219)

pull/241/head
Allison Ryan 3 years ago committed by GitHub
parent 38602c8dba
commit 29ec61ff97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,38 @@
import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:pinball_components/pinball_components.dart';
import 'package:sandbox/common/common.dart';
import 'package:sandbox/stories/ball/basic_ball_game.dart';
class BaseboardGame extends BasicBallGame with Traceable {
static const info = '''
Shows how the Baseboards are rendered.
- Activate the "trace" parameter to overlay the body.
- Tap anywhere on the screen to spawn a ball into the game.
''';
@override
Future<void> onLoad() async {
await super.onLoad();
await images.loadAll([
Assets.images.baseboard.left.keyName,
Assets.images.baseboard.right.keyName,
]);
final center = screenToWorld(camera.viewport.canvasSize! / 2);
final leftBaseboard = Baseboard(side: BoardSide.left)
..initialPosition = center - Vector2(25, 0)
..priority = 1;
final rightBaseboard = Baseboard(side: BoardSide.right)
..initialPosition = center + Vector2(25, 0)
..priority = 1;
await addAll([
leftBaseboard,
rightBaseboard,
]);
await traceAllBodies();
}
}

@ -1,24 +0,0 @@
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 = 'Shows 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,15 +1,15 @@
import 'package:dashbook/dashbook.dart';
import 'package:flame/game.dart';
import 'package:sandbox/common/common.dart';
import 'package:sandbox/stories/baseboard/basic_baseboard_game.dart';
import 'package:sandbox/stories/baseboard/baseboard_game.dart';
void addBaseboardStories(Dashbook dashbook) {
dashbook.storiesOf('Baseboard').add(
'Basic',
(context) => GameWidget(
game: BasicBaseboardGame(),
game: BaseboardGame()..trace = context.boolProperty('Trace', true),
),
codeLink: buildSourceLink('baseboard/basic.dart'),
info: BasicBaseboardGame.info,
codeLink: buildSourceLink('baseboard_game/basic.dart'),
info: BaseboardGame.info,
);
}

@ -16,6 +16,11 @@ class BoundariesGame extends BasicBallGame with Traceable {
Future<void> onLoad() async {
await super.onLoad();
await images.loadAll([
Assets.images.boundary.outer.keyName,
Assets.images.boundary.bottom.keyName,
]);
await addFromBlueprint(Boundaries());
await ready();

@ -33,6 +33,11 @@ class FlipperGame extends BasicBallGame with KeyboardEvents, Traceable {
Future<void> onLoad() async {
await super.onLoad();
await images.loadAll([
Assets.images.flipper.left.keyName,
Assets.images.flipper.right.keyName,
]);
final center = screenToWorld(camera.viewport.canvasSize! / 2);
leftFlipper = Flipper(side: BoardSide.left)

@ -15,6 +15,12 @@ class SlingshotGame extends BasicBallGame with Traceable {
@override
Future<void> onLoad() async {
await super.onLoad();
await images.loadAll([
Assets.images.slingshot.upper.keyName,
Assets.images.slingshot.lower.keyName,
]);
await addFromBlueprint(Slingshots());
camera.followVector2(Vector2.zero());
await traceAllBodies();

Loading…
Cancel
Save