feat: launcher final asset (#201)

* feat: launch backgroun railing asset

* refactor: launch ramp final assets

* refactor: updated assets and position for launcher ramp

* test: golden tests for launcher ramp

* fix: render order and positioning

* refactor: TODO for future refactor of final ramp shape

* refactor: extended launcher foreground rail until boundary bottom to avoid balls scape from dino

Co-authored-by: Allison Ryan <allisonryan0002@gmail.com>
Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com>
pull/211/head
Rui Miguel Alonso 3 years ago committed by GitHub
parent 2c879ab5b5
commit 14f7034d13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -22,6 +22,9 @@ extension PinballGameAssetsX on PinballGame {
images.load(
components.Assets.images.launchRamp.foregroundRailing.keyName,
),
images.load(
components.Assets.images.launchRamp.backgroundRailing.keyName,
),
images.load(components.Assets.images.dino.dinoLandTop.keyName),
images.load(components.Assets.images.dino.dinoLandBottom.keyName),
images.load(components.Assets.images.dash.animatronic.keyName),

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 KiB

After

Width:  |  Height:  |  Size: 128 KiB

@ -184,6 +184,10 @@ class $AssetsImagesKickerGen {
class $AssetsImagesLaunchRampGen {
const $AssetsImagesLaunchRampGen();
/// File path: assets/images/launch_ramp/background-railing.png
AssetGenImage get backgroundRailing =>
const AssetGenImage('assets/images/launch_ramp/background-railing.png');
/// File path: assets/images/launch_ramp/foreground-railing.png
AssetGenImage get foregroundRailing =>
const AssetGenImage('assets/images/launch_ramp/foreground-railing.png');

@ -42,10 +42,21 @@ class LaunchRamp extends Forge2DBlueprint {
/// {@endtemplate}
class _LaunchRampBase extends BodyComponent with InitialPosition, Layered {
/// {@macro launch_ramp_base}
_LaunchRampBase() : super(priority: Ball.launchRampPriority - 1) {
_LaunchRampBase()
: super(
priority: Ball.launchRampPriority - 1,
children: [
_LaunchRampBackgroundRailingSpriteComponent(),
_LaunchRampBaseSpriteComponent(),
],
) {
layer = Layer.launcher;
renderBody = false;
}
// TODO(ruimiguel): final asset differs slightly from the current shape. We
// need to fix shape with correct vertices, but right now merge them to have
// final assets at game and not be blocked.
List<FixtureDef> _createFixtureDefs() {
final fixturesDef = <FixtureDef>[];
@ -114,28 +125,36 @@ class _LaunchRampBase extends BodyComponent with InitialPosition, Layered {
return body;
}
}
class _LaunchRampBaseSpriteComponent extends SpriteComponent with HasGameRef {
@override
Future<void> onLoad() async {
await super.onLoad();
renderBody = false;
await add(_LaunchRampBaseSpriteComponent());
final sprite = await gameRef.loadSprite(
Assets.images.launchRamp.ramp.keyName,
);
this.sprite = sprite;
size = sprite.originalSize / 10;
anchor = Anchor.center;
position = Vector2(25.65, 0.7);
}
}
class _LaunchRampBaseSpriteComponent extends SpriteComponent with HasGameRef {
class _LaunchRampBackgroundRailingSpriteComponent extends SpriteComponent
with HasGameRef {
@override
Future<void> onLoad() async {
await super.onLoad();
final sprite = await gameRef.loadSprite(
Assets.images.launchRamp.ramp.keyName,
Assets.images.launchRamp.backgroundRailing.keyName,
);
this.sprite = sprite;
size = sprite.originalSize / 10;
anchor = Anchor.center;
position = Vector2(25.65, 0);
position = Vector2(25.6, -1.3);
}
}
@ -145,7 +164,13 @@ class _LaunchRampBaseSpriteComponent extends SpriteComponent with HasGameRef {
/// {@endtemplate}
class _LaunchRampForegroundRailing extends BodyComponent with InitialPosition {
/// {@macro launch_ramp_foreground_railing}
_LaunchRampForegroundRailing() : super(priority: Ball.launchRampPriority + 1);
_LaunchRampForegroundRailing()
: super(
priority: Ball.launchRampPriority + 1,
children: [_LaunchRampForegroundRailingSpriteComponent()],
) {
renderBody = false;
}
List<FixtureDef> _createFixtureDefs() {
final fixturesDef = <FixtureDef>[];
@ -153,7 +178,7 @@ class _LaunchRampForegroundRailing extends BodyComponent with InitialPosition {
final rightStraightShape = EdgeShape()
..set(
Vector2(27.6, -57.9),
Vector2(30, -35.1),
Vector2(38.1, 42.6),
);
final rightStraightFixtureDef = FixtureDef(rightStraightShape);
fixturesDef.add(rightStraightFixtureDef);
@ -189,14 +214,6 @@ class _LaunchRampForegroundRailing extends BodyComponent with InitialPosition {
return body;
}
@override
Future<void> onLoad() async {
await super.onLoad();
renderBody = false;
await add(_LaunchRampForegroundRailingSpriteComponent());
}
}
class _LaunchRampForegroundRailingSpriteComponent extends SpriteComponent
@ -211,7 +228,7 @@ class _LaunchRampForegroundRailingSpriteComponent extends SpriteComponent
this.sprite = sprite;
size = sprite.originalSize / 10;
anchor = Anchor.center;
position = Vector2(22.8, 0);
position = Vector2(22.8, 0.5);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 177 KiB

After

Width:  |  Height:  |  Size: 216 KiB

@ -16,6 +16,7 @@ void main() {
'renders correctly',
setUp: (game, tester) async {
await game.addFromBlueprint(LaunchRamp());
await game.ready();
game.camera.followVector2(Vector2.zero());
game.camera.zoom = 4.1;
},

Loading…
Cancel
Save