refactor: update bottom curve

pull/156/head
Allison Ryan 4 years ago
parent daebb0b749
commit 3a89c101c0

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);
@ -77,7 +77,7 @@ class _BottomBoundary extends BodyComponent with InitialPosition {
sprite: sprite,
size: sprite.originalSize / 10,
anchor: Anchor.center,
position: Vector2(-5.4, 57.4),
position: Vector2(-5.4, 55.8),
),
);
}
@ -115,7 +115,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);

@ -11,8 +11,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);
}),
);
}

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

@ -0,0 +1,42 @@
import 'dart:math' as math;
import 'package:flame/extensions.dart';
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 BoundariesGame extends BasicBallGame {
BoundariesGame({
required this.trace,
}) : 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.
''';
final bool trace;
@override
Future<void> onLoad() async {
await super.onLoad();
await addFromBlueprint(Boundaries());
await ready();
camera
..followVector2(Vector2.zero())
..zoom = 6;
final bottomBoundary = children.whereType<BodyComponent>().first;
final outerBoundary = children.whereType<BodyComponent>().last;
if (trace) {
bottomBoundary.trace();
outerBoundary.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/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 'dash_nest_bumper/stories.dart';
export 'effects/stories.dart';

Binary file not shown.

Before

Width:  |  Height:  |  Size: 324 KiB

After

Width:  |  Height:  |  Size: 153 KiB

Loading…
Cancel
Save