feat: applying assets to the spaceship (#101)
* feat: applying assets to the spaceship * fix: rebase issues * feat: adding missing coverage * fix: lint * feat: improving test * Apply suggestions from code review Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: pr suggestions * feat: pr suggestions * Update packages/pinball_components/lib/src/components/spaceship.dart Co-authored-by: Alejandro Santiago <dev@alestiago.com> * feat: pr suggestions * fix: rebase issues Co-authored-by: Allison Ryan <77211884+allisonryan0002@users.noreply.github.com> Co-authored-by: Alejandro Santiago <dev@alestiago.com>pull/108/head
Before Width: | Height: | Size: 9.5 KiB |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 9.8 KiB |
Before Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 7.7 KiB |
After Width: | Height: | Size: 231 KiB |
After Width: | Height: | Size: 38 KiB |
@ -1,17 +1,16 @@
|
|||||||
// ignore_for_file: avoid_renaming_method_parameters
|
// ignore_for_file: avoid_renaming_method_parameters
|
||||||
|
|
||||||
import 'package:flame_forge2d/flame_forge2d.dart';
|
import 'package:flame_forge2d/flame_forge2d.dart';
|
||||||
import 'package:pinball/game/game.dart';
|
|
||||||
import 'package:pinball_components/pinball_components.dart';
|
import 'package:pinball_components/pinball_components.dart';
|
||||||
|
|
||||||
/// {@template ramp_orientation}
|
/// {@template ramp_orientation}
|
||||||
/// Determines if a ramp is facing [up] or [down] on the [Board].
|
/// Determines if a ramp is facing [up] or [down] on the Board.
|
||||||
/// {@endtemplate}
|
/// {@endtemplate}
|
||||||
enum RampOrientation {
|
enum RampOrientation {
|
||||||
/// Facing up on the [Board].
|
/// Facing up on the Board.
|
||||||
up,
|
up,
|
||||||
|
|
||||||
/// Facing down on the [Board].
|
/// Facing down on the Board.
|
||||||
down,
|
down,
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
|||||||
|
export 'blueprint.dart';
|
@ -1 +1,2 @@
|
|||||||
export 'components/components.dart';
|
export 'components/components.dart';
|
||||||
|
export 'flame/flame.dart';
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flame/input.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:pinball_components/pinball_components.dart';
|
||||||
|
import 'package:sandbox/common/common.dart';
|
||||||
|
|
||||||
|
class BasicSpaceship extends BasicGame with TapDetector {
|
||||||
|
static String info = 'Renders a spaceship and allows balls to be '
|
||||||
|
'spawned upon click to test their interactions';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> onLoad() async {
|
||||||
|
await super.onLoad();
|
||||||
|
|
||||||
|
camera.followVector2(Vector2.zero());
|
||||||
|
|
||||||
|
unawaited(
|
||||||
|
addFromBlueprint(Spaceship(position: Vector2.zero())),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void onTapUp(TapUpInfo info) {
|
||||||
|
add(
|
||||||
|
Ball(baseColor: Colors.blue)
|
||||||
|
..initialPosition = info.eventPosition.game
|
||||||
|
..layer = Layer.jetpack,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
import 'package:dashbook/dashbook.dart';
|
||||||
|
import 'package:flame/game.dart';
|
||||||
|
import 'package:sandbox/common/common.dart';
|
||||||
|
import 'package:sandbox/stories/spaceship/basic.dart';
|
||||||
|
|
||||||
|
void addSpaceshipStories(Dashbook dashbook) {
|
||||||
|
dashbook.storiesOf('Spaceship').add(
|
||||||
|
'Basic',
|
||||||
|
(context) => GameWidget(game: BasicSpaceship()),
|
||||||
|
codeLink: buildSourceLink('spaceship/basic.dart'),
|
||||||
|
info: BasicSpaceship.info,
|
||||||
|
);
|
||||||
|
}
|
@ -1,5 +1,26 @@
|
|||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
|
import 'package:flame_forge2d/flame_forge2d.dart';
|
||||||
import 'package:mocktail/mocktail.dart';
|
import 'package:mocktail/mocktail.dart';
|
||||||
|
import 'package:pinball_components/pinball_components.dart';
|
||||||
|
|
||||||
class MockCanvas extends Mock implements Canvas {}
|
class MockCanvas extends Mock implements Canvas {}
|
||||||
|
|
||||||
|
class MockFilter extends Mock implements Filter {}
|
||||||
|
|
||||||
|
class MockFixture extends Mock implements Fixture {}
|
||||||
|
|
||||||
|
class MockBody extends Mock implements Body {}
|
||||||
|
|
||||||
|
class MockBall extends Mock implements Ball {}
|
||||||
|
|
||||||
|
class MockGame extends Mock implements Forge2DGame {}
|
||||||
|
|
||||||
|
class MockSpaceshipEntrance extends Mock implements SpaceshipEntrance {}
|
||||||
|
|
||||||
|
class MockSpaceshipHole extends Mock implements SpaceshipHole {}
|
||||||
|
|
||||||
|
class MockContact extends Mock implements Contact {}
|
||||||
|
|
||||||
|
class MockContactCallback extends Mock
|
||||||
|
implements ContactCallback<Object, Object> {}
|
||||||
|
After Width: | Height: | Size: 79 KiB |