refactor: bottom boundary curve (#156)

* refactor: update bottom curve

* fix: unused import

* fix: disable golden tests

* refactor: use Traceable

* chore: re-enable zoom golden tests
pull/171/head
Allison Ryan 4 years ago committed by GitHub
parent bfba65823f
commit 98f25242b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 KiB

After

Width:  |  Height:  |  Size: 18 KiB

@ -30,9 +30,9 @@ class _BottomBoundary extends BodyComponent with InitialPosition {
final bottomLeftCurve = BezierCurveShape(
controlPoints: [
Vector2(-43.6, -44.4),
Vector2(-31, -43.4),
Vector2(-18.7, -52.1),
Vector2(-43.9, -41.8),
Vector2(-35.7, -43),
Vector2(-19.9, -51),
],
);
final bottomLeftCurveFixtureDef = FixtureDef(bottomLeftCurve);
@ -40,9 +40,9 @@ class _BottomBoundary extends BodyComponent with InitialPosition {
final bottomRightCurve = BezierCurveShape(
controlPoints: [
Vector2(31.8, -44.1),
Vector2(21.95, -47),
Vector2(12.3, -51.4),
Vector2(31.8, -44.8),
Vector2(21.95, -47.7),
Vector2(12.3, -52.1),
],
);
final bottomRightCurveFixtureDef = FixtureDef(bottomRightCurve);
@ -78,7 +78,7 @@ class _BottomBoundarySpriteComponent extends SpriteComponent with HasGameRef {
this.sprite = sprite;
size = sprite.originalSize / 10;
anchor = Anchor.center;
position = Vector2(-5.4, 57.4);
position = Vector2(-5.4, 55.8);
}
}
@ -114,7 +114,7 @@ class _OuterBoundary extends BodyComponent with InitialPosition {
final leftWall = EdgeShape()
..set(
Vector2(-32.3, 57.2),
Vector2(-44.1, -44.4),
Vector2(-43.9, -41.8),
);
final leftWallFixtureDef = FixtureDef(leftWall);
fixturesDefs.add(leftWallFixtureDef);

@ -12,8 +12,7 @@ extension BodyTrace on BodyComponent {
unawaited(
mounted.whenComplete(() {
final sprite = children.whereType<SpriteComponent>().first;
sprite.paint.color = sprite.paint.color.withOpacity(0.5);
children.whereType<SpriteComponent>().first.setOpacity(0.5);
descendants().whereType<JointAnchor>().forEach((anchor) {
final fixtureDef = FixtureDef(CircleShape()..radius = 0.5);

@ -24,5 +24,6 @@ void main() {
addSlingshotStories(dashbook);
addSparkyBumperStories(dashbook);
addZoomStories(dashbook);
addBoundariesStories(dashbook);
runApp(dashbook);
}

@ -0,0 +1,29 @@
import 'package:flame/extensions.dart';
import 'package:pinball_components/pinball_components.dart';
import 'package:sandbox/common/common.dart';
import 'package:sandbox/stories/ball/basic_ball_game.dart';
class BoundariesGame extends BasicBallGame with Traceable {
BoundariesGame() : super(color: const Color(0xFFFF0000));
static const info = '''
Shows how Boundaries 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 addFromBlueprint(Boundaries());
await ready();
camera
..followVector2(Vector2.zero())
..zoom = 6;
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/boundaries/boundaries_game.dart';
void addBoundariesStories(Dashbook dashbook) {
dashbook.storiesOf('Boundaries').add(
'Basic',
(context) => GameWidget(
game: BoundariesGame()..trace = context.boolProperty('Trace', true),
),
codeLink: buildSourceLink('boundaries_game/basic.dart'),
info: BoundariesGame.info,
);
}

@ -1,5 +1,6 @@
export 'ball/stories.dart';
export 'baseboard/stories.dart';
export 'boundaries/stories.dart';
export 'chrome_dino/stories.dart';
export 'effects/stories.dart';
export 'flipper/stories.dart';

Binary file not shown.

Before

Width:  |  Height:  |  Size: 324 KiB

After

Width:  |  Height:  |  Size: 153 KiB

Loading…
Cancel
Save