mirror of https://github.com/flutter/pinball.git
feat: ramps sandbox (#168)
* feat: added LaunchRamp story * feat: added SpaceshipRail story * feat: added SpaceshipRamp story * feat: added new stories for ramps to dashbook * refactor: added priority and layer to Ball for BasicBallGame * refactor: changed renderBody to allow tracing on ramps * refactor: moved renderBody * fix: bug on spaceshiprail exit never reached * fix: spaceshiprail exit and basecamp ball blocked * refactor: set spaceship foreground priority at superpull/177/head
parent
69a88441a6
commit
d32192a4e3
@ -0,0 +1,36 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flame/input.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pinball_components/pinball_components.dart';
|
||||
import 'package:sandbox/stories/ball/basic_ball_game.dart';
|
||||
|
||||
class LaunchRampGame extends BasicBallGame {
|
||||
LaunchRampGame()
|
||||
: super(
|
||||
color: Colors.blue,
|
||||
ballPriority: LaunchRamp.ballPriorityInsideRamp,
|
||||
ballLayer: Layer.launcher,
|
||||
);
|
||||
|
||||
static const info = '''
|
||||
Shows how LaunchRamp 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();
|
||||
|
||||
camera
|
||||
..followVector2(Vector2(0, 0))
|
||||
..zoom = 7.5;
|
||||
|
||||
final launchRamp = LaunchRamp();
|
||||
unawaited(addFromBlueprint(launchRamp));
|
||||
|
||||
await traceAllBodies();
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
import 'package:dashbook/dashbook.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:sandbox/common/common.dart';
|
||||
import 'package:sandbox/stories/launch_ramp/launch_ramp_game.dart';
|
||||
|
||||
void addLaunchRampStories(Dashbook dashbook) {
|
||||
dashbook.storiesOf('LaunchRamp').add(
|
||||
'Basic',
|
||||
(context) => GameWidget(
|
||||
game: LaunchRampGame()..trace = context.boolProperty('Trace', true),
|
||||
),
|
||||
codeLink: buildSourceLink('launch_ramp/basic.dart'),
|
||||
info: LaunchRampGame.info,
|
||||
);
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flame/input.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pinball_components/pinball_components.dart';
|
||||
import 'package:sandbox/stories/ball/basic_ball_game.dart';
|
||||
|
||||
class SpaceshipRailGame extends BasicBallGame {
|
||||
SpaceshipRailGame()
|
||||
: super(
|
||||
color: Colors.blue,
|
||||
ballPriority: SpaceshipRail.ballPriorityInsideRail,
|
||||
ballLayer: Layer.spaceshipExitRail,
|
||||
);
|
||||
|
||||
static const info = '''
|
||||
Shows how SpaceshipRail 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();
|
||||
|
||||
camera.followVector2(Vector2(-30, -10));
|
||||
|
||||
final spaceshipRail = SpaceshipRail();
|
||||
unawaited(addFromBlueprint(spaceshipRail));
|
||||
|
||||
await traceAllBodies();
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
import 'package:dashbook/dashbook.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:sandbox/common/common.dart';
|
||||
import 'package:sandbox/stories/spaceship_rail/spaceship_rail_game.dart';
|
||||
|
||||
void addSpaceshipRailStories(Dashbook dashbook) {
|
||||
dashbook.storiesOf('SpaceshipRail').add(
|
||||
'Basic',
|
||||
(context) => GameWidget(
|
||||
game: SpaceshipRailGame()
|
||||
..trace = context.boolProperty('Trace', true),
|
||||
),
|
||||
codeLink: buildSourceLink('spaceship_rail/basic.dart'),
|
||||
info: SpaceshipRailGame.info,
|
||||
);
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flame/input.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pinball_components/pinball_components.dart';
|
||||
import 'package:sandbox/stories/ball/basic_ball_game.dart';
|
||||
|
||||
class SpaceshipRampGame extends BasicBallGame {
|
||||
SpaceshipRampGame()
|
||||
: super(
|
||||
color: Colors.blue,
|
||||
ballPriority: SpaceshipRamp.ballPriorityInsideRamp,
|
||||
ballLayer: Layer.spaceshipEntranceRamp,
|
||||
);
|
||||
|
||||
static const info = '''
|
||||
Shows how SpaceshipRamp 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();
|
||||
|
||||
camera.followVector2(Vector2(-10, -20));
|
||||
|
||||
final spaceshipRamp = SpaceshipRamp();
|
||||
unawaited(addFromBlueprint(spaceshipRamp));
|
||||
|
||||
await traceAllBodies();
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
import 'package:dashbook/dashbook.dart';
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:sandbox/common/common.dart';
|
||||
import 'package:sandbox/stories/spaceship_ramp/spaceship_ramp_game.dart';
|
||||
|
||||
void addSpaceshipRampStories(Dashbook dashbook) {
|
||||
dashbook.storiesOf('SpaceshipRamp').add(
|
||||
'Basic',
|
||||
(context) => GameWidget(
|
||||
game: SpaceshipRampGame()
|
||||
..trace = context.boolProperty('Trace', true),
|
||||
),
|
||||
codeLink: buildSourceLink('spaceship_ramp/basic.dart'),
|
||||
info: SpaceshipRampGame.info,
|
||||
);
|
||||
}
|
Loading…
Reference in new issue