fix: fixed merge conflicts

pull/130/head
RuiAlonso 4 years ago
commit 0e21e43ef2

@ -1,11 +1,8 @@
export 'board.dart';
export 'bonus_word.dart';
export 'chrome_dino.dart';
export 'controlled_ball.dart';
export 'controlled_flipper.dart';
export 'flutter_forest.dart';
export 'jetpack_ramp.dart';
export 'kicker.dart';
export 'launcher_ramp.dart';
export 'plunger.dart';
export 'score_points.dart';

@ -21,6 +21,7 @@ extension PinballGameAssetsX on PinballGame {
images.load(components.Assets.images.dashBumper.b.inactive.keyName),
images.load(components.Assets.images.dashBumper.main.active.keyName),
images.load(components.Assets.images.dashBumper.main.inactive.keyName),
<<<<<<< HEAD
images.load(
components.Assets.images.spaceshipRamp.spaceshipDropTube.keyName,
),
@ -28,6 +29,17 @@ extension PinballGameAssetsX on PinballGame {
images.load(Assets.images.components.spaceshipRamp.path),
images.load(Assets.images.components.spaceshipRailingBg.path),
images.load(Assets.images.components.spaceshipRailingFg.path),
=======
images.load(components.Assets.images.spaceshipRamp.spaceshipRamp.keyName),
images.load(
components.Assets.images.spaceshipRamp.spaceshipRailingBg.keyName,
),
images.load(
components.Assets.images.spaceshipRamp.spaceshipRailingFg.keyName,
),
images.load(Assets.images.components.background.path),
images.load(Assets.images.components.spaceshipDropTube.path),
>>>>>>> main
]);
}
}

@ -92,9 +92,7 @@ class PinballGame extends Forge2DGame
}
Future<void> _addPaths() async {
unawaited(
addFromBlueprint(Jetpack()),
);
unawaited(addFromBlueprint(SpaceshipRamp()));
unawaited(addFromBlueprint(Launcher()));
}

@ -21,17 +21,9 @@ class $AssetsImagesComponentsGen {
AssetGenImage get background =>
const AssetGenImage('assets/images/components/background.png');
/// File path: assets/images/components/spaceship_railing_bg.png
AssetGenImage get spaceshipRailingBg =>
const AssetGenImage('assets/images/components/spaceship_railing_bg.png');
/// File path: assets/images/components/spaceship_railing_fg.png
AssetGenImage get spaceshipRailingFg =>
const AssetGenImage('assets/images/components/spaceship_railing_fg.png');
/// File path: assets/images/components/spaceship_ramp.png
AssetGenImage get spaceshipRamp =>
const AssetGenImage('assets/images/components/spaceship_ramp.png');
/// File path: assets/images/components/spaceship-drop-tube.png
AssetGenImage get spaceshipDropTube =>
const AssetGenImage('assets/images/components/spaceship-drop-tube.png');
}
class Assets {

@ -83,9 +83,17 @@ class $AssetsImagesFlipperGen {
class $AssetsImagesSpaceshipRampGen {
const $AssetsImagesSpaceshipRampGen();
/// File path: assets/images/spaceship_ramp/spaceship-drop-tube.png
AssetGenImage get spaceshipDropTube => const AssetGenImage(
'assets/images/spaceship_ramp/spaceship-drop-tube.png');
/// File path: assets/images/spaceship_ramp/spaceship_railing_bg.png
AssetGenImage get spaceshipRailingBg => const AssetGenImage(
'assets/images/spaceship_ramp/spaceship_railing_bg.png');
/// File path: assets/images/spaceship_ramp/spaceship_railing_fg.png
AssetGenImage get spaceshipRailingFg => const AssetGenImage(
'assets/images/spaceship_ramp/spaceship_railing_fg.png');
/// File path: assets/images/spaceship_ramp/spaceship_ramp.png
AssetGenImage get spaceshipRamp =>
const AssetGenImage('assets/images/spaceship_ramp/spaceship_ramp.png');
}
class $AssetsImagesDashBumperAGen {

@ -43,7 +43,7 @@ class ChromeDino extends BodyComponent with InitialPosition {
await add(
TimerComponent(
period: 1,
onTick: joint.swivel,
onTick: joint._swivel,
repeat: true,
),
);
@ -150,7 +150,7 @@ class _ChromeDinoJoint extends RevoluteJoint {
_ChromeDinoJoint(_ChromeDinoAnchorRevoluteJointDef def) : super(def);
/// Sweeps the [ChromeDino] up and down repeatedly.
void swivel() {
void _swivel() {
setMotorSpeed(-motorSpeed);
}
}

@ -2,6 +2,7 @@ export 'ball.dart';
export 'baseboard.dart';
export 'board_dimensions.dart';
export 'board_side.dart';
export 'chrome_dino.dart';
export 'dash_nest_bumper.dart';
export 'dino_walls.dart';
export 'fire_effect.dart';
@ -9,8 +10,10 @@ export 'flipper.dart';
export 'flutter_sign_post.dart';
export 'initial_position.dart';
export 'joint_anchor.dart';
export 'kicker.dart';
export 'layer.dart';
export 'ramp_opening.dart';
export 'shapes/shapes.dart';
export 'spaceship.dart';
export 'spaceship_exit_rail.dart';
export 'spaceship_ramp.dart';

@ -53,8 +53,8 @@ enum Layer {
/// Collide only with ramps opening elements.
opening,
/// Collide only with Jetpack group elements.
jetpack,
/// Collide only with Spaceship entrance ramp group elements.
spaceshipEntranceRamp,
/// Collide only with Launcher group elements.
launcher,
@ -86,7 +86,7 @@ extension LayerMaskBits on Layer {
return 0x0001;
case Layer.opening:
return 0x0007;
case Layer.jetpack:
case Layer.spaceshipEntranceRamp:
return 0x0002;
case Layer.launcher:
return 0x0005;

@ -1,63 +1,66 @@
// ignore_for_file: public_member_api_docs, avoid_renaming_method_parameters
// ignore_for_file: avoid_renaming_method_parameters, comment_references
import 'dart:math' as math;
import 'package:flame/components.dart';
import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:pinball/game/game.dart';
import 'package:pinball/gen/assets.gen.dart';
import 'package:pinball_components/gen/assets.gen.dart';
import 'package:pinball_components/pinball_components.dart' hide Assets;
/// A [Blueprint] which creates the [JetpackRamp].
class Jetpack extends Forge2DBlueprint {
/// {@macro spaceship}
Jetpack();
/// {@template spaceship_ramp}
/// A [Blueprint] which creates the [_SpaceshipRampBackground].
/// {@endtemplate}
class SpaceshipRamp extends Forge2DBlueprint {
/// {@macro spaceship_ramp}
SpaceshipRamp();
/// Base priority for wall while be in the ramp.
static const int ballPriorityInsideRamp = 4;
@override
void build(_) {
addAllContactCallback([
RampOpeningBallContactCallback<_JetpackRampOpening>(),
RampOpeningBallContactCallback<_SpaceshipRampOpening>(),
]);
final rightOpening = _JetpackRampOpening(
final rightOpening = _SpaceshipRampOpening(
// TODO(ruimiguel): set Board priority when defined.
outsidePriority: 1,
rotation: math.pi,
)
..initialPosition = Vector2(1.7, 19)
..layer = Layer.opening;
final leftOpening = _JetpackRampOpening(
final leftOpening = _SpaceshipRampOpening(
outsideLayer: Layer.spaceship,
outsidePriority: Spaceship.ballPriorityWhenOnSpaceship,
rotation: math.pi,
)
..initialPosition = Vector2(-13.7, 19)
..layer = Layer.jetpack;
..layer = Layer.spaceshipEntranceRamp;
final jetpackRamp = JetpackRamp();
final spaceshipRamp = _SpaceshipRampBackground();
final jetpackRampWallFg = _JetpackRampForegroundRailing();
final spaceshipRampForegroundRailing = _SpaceshipRampForegroundRailing();
final baseRight = _JetpackBase()..initialPosition = Vector2(1.7, 20);
final baseRight = _SpaceshipRampBase()..initialPosition = Vector2(1.7, 20);
addAll([
rightOpening,
leftOpening,
baseRight,
jetpackRamp,
jetpackRampWallFg,
spaceshipRamp,
spaceshipRampForegroundRailing,
]);
}
}
/// {@template jetpack_ramp}
/// Represents the upper left blue ramp of the [Board].
/// {@endtemplate}
class JetpackRamp extends BodyComponent with InitialPosition, Layered {
JetpackRamp() : super(priority: Jetpack.ballPriorityInsideRamp - 1) {
layer = Layer.jetpack;
/// Represents the upper left blue ramp of the [Board] with its background
/// railing.
class _SpaceshipRampBackground extends BodyComponent
with InitialPosition, Layered {
_SpaceshipRampBackground()
: super(priority: SpaceshipRamp.ballPriorityInsideRamp - 1) {
layer = Layer.spaceshipEntranceRamp;
}
/// Width between walls of the ramp.
@ -113,7 +116,7 @@ class JetpackRamp extends BodyComponent with InitialPosition, Layered {
Future<void> _loadSprites() async {
final spriteRamp = await gameRef.loadSprite(
Assets.images.components.spaceshipRamp.path,
Assets.images.spaceshipRamp.spaceshipRamp.keyName,
);
final spriteRampComponent = SpriteComponent(
@ -124,7 +127,7 @@ class JetpackRamp extends BodyComponent with InitialPosition, Layered {
);
final spriteRailingBg = await gameRef.loadSprite(
Assets.images.components.spaceshipRailingBg.path,
Assets.images.spaceshipRamp.spaceshipRailingBg.keyName,
);
final spriteRailingBgComponent = SpriteComponent(
sprite: spriteRailingBg,
@ -140,11 +143,12 @@ class JetpackRamp extends BodyComponent with InitialPosition, Layered {
}
}
class _JetpackRampForegroundRailing extends BodyComponent
/// Represents the foreground of the railing upper left blue ramp.
class _SpaceshipRampForegroundRailing extends BodyComponent
with InitialPosition, Layered {
_JetpackRampForegroundRailing()
: super(priority: Jetpack.ballPriorityInsideRamp + 1) {
layer = Layer.jetpack;
_SpaceshipRampForegroundRailing()
: super(priority: SpaceshipRamp.ballPriorityInsideRamp + 1) {
layer = Layer.spaceshipEntranceRamp;
}
List<FixtureDef> _createFixtureDefs() {
@ -197,7 +201,7 @@ class _JetpackRampForegroundRailing extends BodyComponent
Future<void> _loadSprites() async {
final spriteRailingFg = await gameRef.loadSprite(
Assets.images.components.spaceshipRailingFg.path,
Assets.images.spaceshipRamp.spaceshipRailingFg.keyName,
);
final spriteRailingFgComponent = SpriteComponent(
sprite: spriteRailingFg,
@ -210,8 +214,9 @@ class _JetpackRampForegroundRailing extends BodyComponent
}
}
class _JetpackBase extends BodyComponent with InitialPosition, Layered {
_JetpackBase() {
/// Represents the ground right base of the [SpaceshipRamp].
class _SpaceshipRampBase extends BodyComponent with InitialPosition, Layered {
_SpaceshipRampBase() {
layer = Layer.board;
}
@ -240,28 +245,28 @@ class _JetpackBase extends BodyComponent with InitialPosition, Layered {
}
}
/// {@template jetpack_ramp_opening}
/// [RampOpening] with [Layer.jetpack] to filter [Ball] collisions
/// inside [JetpackRamp].
/// {@template spaceship_ramp_opening}
/// [RampOpening] with [Layer.spaceshipEntranceRamp] to filter [Ball] collisions
/// inside [_SpaceshipRampBackground].
/// {@endtemplate}
class _JetpackRampOpening extends RampOpening {
/// {@macro jetpack_ramp_opening}
_JetpackRampOpening({
class _SpaceshipRampOpening extends RampOpening {
/// {@macro spaceship_ramp_opening}
_SpaceshipRampOpening({
Layer? outsideLayer,
int? outsidePriority,
required double rotation,
}) : _rotation = rotation,
super(
insideLayer: Layer.jetpack,
insideLayer: Layer.spaceshipEntranceRamp,
outsideLayer: outsideLayer,
orientation: RampOrientation.down,
insidePriority: Jetpack.ballPriorityInsideRamp,
insidePriority: SpaceshipRamp.ballPriorityInsideRamp,
outsidePriority: outsidePriority,
);
final double _rotation;
static final Vector2 _size = Vector2(JetpackRamp.width / 4, .1);
static final Vector2 _size = Vector2(_SpaceshipRampBackground.width / 4, .1);
@override
Shape get shape {

@ -35,7 +35,7 @@ class BigSquare extends BodyComponent with InitialPosition, Layered {
paint = Paint()
..color = const Color.fromARGB(255, 8, 218, 241)
..style = PaintingStyle.stroke;
layer = Layer.jetpack;
layer = Layer.spaceshipEntranceRamp;
}
@override

@ -25,7 +25,7 @@ class BasicSpaceship extends BasicGame with TapDetector {
add(
Ball(baseColor: Colors.blue)
..initialPosition = info.eventPosition.game
..layer = Layer.jetpack,
..layer = Layer.spaceshipEntranceRamp,
);
}
}

@ -0,0 +1,38 @@
// ignore_for_file: cascade_invocations
import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:flame_test/flame_test.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pinball_components/pinball_components.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
final flameTester = FlameTester(Forge2DGame.new);
group('ChromeDino', () {
flameTester.test(
'loads correctly',
(game) async {
final chromeDino = ChromeDino();
await game.ensureAdd(chromeDino);
expect(game.contains(chromeDino), isTrue);
},
);
flameTester.test(
'swivels',
(game) async {
// TODO(alestiago): Write golden tests to check the
// swivel animation.
final chromeDino = ChromeDino();
await game.ensureAdd(chromeDino);
final previousPosition = chromeDino.body.position.clone();
game.update(64);
expect(chromeDino.body.position, isNot(equals(previousPosition)));
},
);
});
}

@ -3,7 +3,6 @@
import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:flame_test/flame_test.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pinball/game/game.dart';
import 'package:pinball_components/pinball_components.dart';
void main() {

@ -46,14 +46,15 @@ void main() {
});
test('correctly sets and gets', () {
final component = TestLayeredBodyComponent()..layer = Layer.jetpack;
expect(component.layer, Layer.jetpack);
final component = TestLayeredBodyComponent()
..layer = Layer.spaceshipEntranceRamp;
expect(component.layer, Layer.spaceshipEntranceRamp);
});
flameTester.test(
'layers correctly before being loaded',
(game) async {
const expectedLayer = Layer.jetpack;
const expectedLayer = Layer.spaceshipEntranceRamp;
final component = TestLayeredBodyComponent()..layer = expectedLayer;
await game.ensureAdd(component);
// TODO(alestiago): modify once component.loaded is available.
@ -71,7 +72,8 @@ void main() {
'when multiple different sets',
(game) async {
const expectedLayer = Layer.launcher;
final component = TestLayeredBodyComponent()..layer = Layer.jetpack;
final component = TestLayeredBodyComponent()
..layer = Layer.spaceshipEntranceRamp;
expect(component.layer, isNot(equals(expectedLayer)));
component.layer = expectedLayer;
@ -90,7 +92,7 @@ void main() {
flameTester.test(
'layers correctly after being loaded',
(game) async {
const expectedLayer = Layer.jetpack;
const expectedLayer = Layer.spaceshipEntranceRamp;
final component = TestLayeredBodyComponent();
await game.ensureAdd(component);
component.layer = expectedLayer;
@ -109,7 +111,7 @@ void main() {
final component = TestLayeredBodyComponent();
await game.ensureAdd(component);
component.layer = Layer.jetpack;
component.layer = Layer.spaceshipEntranceRamp;
expect(component.layer, isNot(equals(expectedLayer)));
component.layer = expectedLayer;
@ -133,7 +135,7 @@ void main() {
flameTester.test(
'nested Layered children will keep their layer',
(game) async {
const parentLayer = Layer.jetpack;
const parentLayer = Layer.spaceshipEntranceRamp;
const childLayer = Layer.board;
final component = TestLayeredBodyComponent()..layer = parentLayer;
@ -152,7 +154,7 @@ void main() {
flameTester.test(
'nested children will keep their layer',
(game) async {
const parentLayer = Layer.jetpack;
const parentLayer = Layer.spaceshipEntranceRamp;
final component = TestLayeredBodyComponent()..layer = parentLayer;
final childComponent = TestBodyComponent();

@ -44,7 +44,7 @@ void main() {
(game) async {
final ramp = TestRampOpening(
orientation: RampOrientation.down,
pathwayLayer: Layer.jetpack,
pathwayLayer: Layer.spaceshipEntranceRamp,
);
await game.ready();
await game.ensureAdd(ramp);
@ -59,7 +59,7 @@ void main() {
(game) async {
final ramp = TestRampOpening(
orientation: RampOrientation.down,
pathwayLayer: Layer.jetpack,
pathwayLayer: Layer.spaceshipEntranceRamp,
);
await game.ensureAdd(ramp);
@ -68,7 +68,7 @@ void main() {
);
group('first fixture', () {
const pathwayLayer = Layer.jetpack;
const pathwayLayer = Layer.spaceshipEntranceRamp;
const openingLayer = Layer.opening;
flameTester.test(
@ -124,7 +124,7 @@ void main() {
final body = MockBody();
final area = TestRampOpening(
orientation: RampOrientation.down,
pathwayLayer: Layer.jetpack,
pathwayLayer: Layer.spaceshipEntranceRamp,
);
final callback = TestRampOpeningBallContactCallback();
@ -145,7 +145,7 @@ void main() {
final body = MockBody();
final area = TestRampOpening(
orientation: RampOrientation.up,
pathwayLayer: Layer.jetpack,
pathwayLayer: Layer.spaceshipEntranceRamp,
);
final callback = TestRampOpeningBallContactCallback();
@ -165,7 +165,7 @@ void main() {
final body = MockBody();
final area = TestRampOpening(
orientation: RampOrientation.down,
pathwayLayer: Layer.jetpack,
pathwayLayer: Layer.spaceshipEntranceRamp,
)..initialPosition = Vector2(0, 10);
final callback = TestRampOpeningBallContactCallback();
@ -189,7 +189,7 @@ void main() {
final body = MockBody();
final area = TestRampOpening(
orientation: RampOrientation.up,
pathwayLayer: Layer.jetpack,
pathwayLayer: Layer.spaceshipEntranceRamp,
)..initialPosition = Vector2(0, 10);
final callback = TestRampOpeningBallContactCallback();
@ -213,7 +213,7 @@ void main() {
final body = MockBody();
final area = TestRampOpening(
orientation: RampOrientation.down,
pathwayLayer: Layer.jetpack,
pathwayLayer: Layer.spaceshipEntranceRamp,
)..initialPosition = Vector2(0, 10);
final callback = TestRampOpeningBallContactCallback();

@ -0,0 +1,27 @@
// ignore_for_file: cascade_invocations
import 'package:flame_test/flame_test.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pinball_components/pinball_components.dart';
import '../../helpers/helpers.dart';
void main() {
group('SpaceshipRamp', () {
TestWidgetsFlutterBinding.ensureInitialized();
final flameTester = FlameTester(TestGame.new);
flameTester.test(
'loads correctly',
(game) async {
final spaceshipEntranceRamp = SpaceshipRamp();
await game.addFromBlueprint(spaceshipEntranceRamp);
await game.ready();
for (final element in spaceshipEntranceRamp.components) {
expect(game.contains(element), isTrue);
}
},
);
});
}

@ -1,23 +0,0 @@
import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:flame_test/flame_test.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pinball/game/game.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
final flameTester = FlameTester(Forge2DGame.new);
group('ChromeDino', () {
flameTester.test(
'loads correctly',
(game) async {
final chromeDino = ChromeDino();
await game.ready();
await game.ensureAdd(chromeDino);
expect(game.contains(chromeDino), isTrue);
},
);
});
}
Loading…
Cancel
Save