|
|
|
@ -1,110 +1,114 @@
|
|
|
|
|
// ignore_for_file: public_member_api_docs
|
|
|
|
|
|
|
|
|
|
import 'dart:math' as math;
|
|
|
|
|
|
|
|
|
|
import 'package:flame/components.dart';
|
|
|
|
|
import 'package:pinball_components/pinball_components.dart';
|
|
|
|
|
|
|
|
|
|
/// {@template pinball_priority}
|
|
|
|
|
/// {@template render_priority}
|
|
|
|
|
/// Priorities for the component rendering order in the pinball game.
|
|
|
|
|
/// {@endtemplate}
|
|
|
|
|
abstract class PinballPriority {
|
|
|
|
|
static const base = 0;
|
|
|
|
|
static const above = 1;
|
|
|
|
|
static const below = -1;
|
|
|
|
|
abstract class RenderPriority {
|
|
|
|
|
static const _base = 0;
|
|
|
|
|
static const _above = 1;
|
|
|
|
|
static const _below = -1;
|
|
|
|
|
|
|
|
|
|
// BALL
|
|
|
|
|
|
|
|
|
|
/// Render priority for the [Ball] while it's on the board.
|
|
|
|
|
static const int ballOnBoard = base;
|
|
|
|
|
static const int ballOnBoard = _base;
|
|
|
|
|
|
|
|
|
|
/// Render priority for the [Ball] while it's on the [SpaceshipRamp].
|
|
|
|
|
static const int ballOnSpaceshipRamp = above + spaceshipRampBackgroundRailing;
|
|
|
|
|
static const int ballOnSpaceshipRamp =
|
|
|
|
|
_above + spaceshipRampBackgroundRailing;
|
|
|
|
|
|
|
|
|
|
/// Render priority for the [Ball] while it's on the [Spaceship].
|
|
|
|
|
static const int ballOnSpaceship = above + spaceshipSaucer;
|
|
|
|
|
static const int ballOnSpaceship = _above + spaceshipSaucer;
|
|
|
|
|
|
|
|
|
|
/// Render priority for the [Ball] while it's on the [SpaceshipRail].
|
|
|
|
|
static const int ballOnSpaceshipRail = spaceshipRail;
|
|
|
|
|
|
|
|
|
|
/// Render priority for the [Ball] while it's on the [LaunchRamp].
|
|
|
|
|
static const int ballOnLaunchRamp = above + launchRamp;
|
|
|
|
|
static const int ballOnLaunchRamp = _above + launchRamp;
|
|
|
|
|
|
|
|
|
|
// BACKGROUND
|
|
|
|
|
|
|
|
|
|
static const int background = 3 * below + base;
|
|
|
|
|
static const int background = 3 * _below + _base;
|
|
|
|
|
|
|
|
|
|
// BOUNDARIES
|
|
|
|
|
|
|
|
|
|
static const int bottomBoundary = above + dinoBottomWall;
|
|
|
|
|
static const int bottomBoundary = _above + dinoBottomWall;
|
|
|
|
|
|
|
|
|
|
static const int outerBoudary = above + background;
|
|
|
|
|
static const int outerBoudary = _above + background;
|
|
|
|
|
|
|
|
|
|
// BOTTOM GROUP
|
|
|
|
|
|
|
|
|
|
static const int bottomGroup = above + ballOnBoard;
|
|
|
|
|
static const int bottomGroup = _above + ballOnBoard;
|
|
|
|
|
|
|
|
|
|
// LAUNCHER
|
|
|
|
|
|
|
|
|
|
static const int launchRamp = above + outerBoudary;
|
|
|
|
|
static const int launchRamp = _above + outerBoudary;
|
|
|
|
|
|
|
|
|
|
static const int launchRampForegroundRailing = above + ballOnLaunchRamp;
|
|
|
|
|
static const int launchRampForegroundRailing = _above + ballOnLaunchRamp;
|
|
|
|
|
|
|
|
|
|
static const int plunger = above + launchRamp;
|
|
|
|
|
static const int plunger = _above + launchRamp;
|
|
|
|
|
|
|
|
|
|
static const int rocket = above + bottomBoundary;
|
|
|
|
|
static const int rocket = _above + bottomBoundary;
|
|
|
|
|
|
|
|
|
|
// DINO LAND
|
|
|
|
|
|
|
|
|
|
static const int dinoTopWall = above + ballOnBoard;
|
|
|
|
|
static const int dinoTopWall = _above + ballOnBoard;
|
|
|
|
|
|
|
|
|
|
static const int dino = above + dinoTopWall;
|
|
|
|
|
static const int dino = _above + dinoTopWall;
|
|
|
|
|
|
|
|
|
|
static const int dinoBottomWall = above + dino;
|
|
|
|
|
static const int dinoBottomWall = _above + dino;
|
|
|
|
|
|
|
|
|
|
static const int slingshot = above + ballOnBoard;
|
|
|
|
|
static const int slingshot = _above + ballOnBoard;
|
|
|
|
|
|
|
|
|
|
// FLUTTER FOREST
|
|
|
|
|
|
|
|
|
|
static const int flutterSignPost = above + launchRampForegroundRailing;
|
|
|
|
|
static const int flutterSignPost = _above + launchRampForegroundRailing;
|
|
|
|
|
|
|
|
|
|
static const int dashBumper = above + ballOnBoard;
|
|
|
|
|
static const int dashBumper = _above + ballOnBoard;
|
|
|
|
|
|
|
|
|
|
static const int dashAnimatronic = above + launchRampForegroundRailing;
|
|
|
|
|
static const int dashAnimatronic = _above + launchRampForegroundRailing;
|
|
|
|
|
|
|
|
|
|
// SPARKY FIRE ZONE
|
|
|
|
|
|
|
|
|
|
static const int computerBase = below + ballOnBoard;
|
|
|
|
|
static const int computerBase = _below + ballOnBoard;
|
|
|
|
|
|
|
|
|
|
static const int computerTop = above + ballOnBoard;
|
|
|
|
|
static const int computerTop = _above + ballOnBoard;
|
|
|
|
|
|
|
|
|
|
static const int sparkyAnimatronic = above + spaceshipRampForegroundRailing;
|
|
|
|
|
static const int sparkyAnimatronic = _above + spaceshipRampForegroundRailing;
|
|
|
|
|
|
|
|
|
|
static const int sparkyBumper = above + ballOnBoard;
|
|
|
|
|
static const int sparkyBumper = _above + ballOnBoard;
|
|
|
|
|
|
|
|
|
|
// ANDROID SPACESHIP
|
|
|
|
|
|
|
|
|
|
static const int spaceshipRail = above + bottomGroup;
|
|
|
|
|
static const int spaceshipRail = _above + bottomGroup;
|
|
|
|
|
|
|
|
|
|
static const int spaceshipRailForeground = above + spaceshipRail;
|
|
|
|
|
static const int spaceshipRailForeground = _above + spaceshipRail;
|
|
|
|
|
|
|
|
|
|
static const int spaceshipSaucer = above + spaceshipRail;
|
|
|
|
|
static const int spaceshipSaucer = _above + spaceshipRail;
|
|
|
|
|
|
|
|
|
|
static const int spaceshipSaucerWall = above + spaceshipSaucer;
|
|
|
|
|
static const int spaceshipSaucerWall = _above + spaceshipSaucer;
|
|
|
|
|
|
|
|
|
|
static const int androidHead = above + spaceshipSaucer;
|
|
|
|
|
static const int androidHead = _above + spaceshipSaucer;
|
|
|
|
|
|
|
|
|
|
static const int spaceshipRamp = above + ballOnBoard;
|
|
|
|
|
static const int spaceshipRamp = _above + ballOnBoard;
|
|
|
|
|
|
|
|
|
|
static const int spaceshipRampBackgroundRailing = above + spaceshipRamp;
|
|
|
|
|
static const int spaceshipRampBackgroundRailing = _above + spaceshipRamp;
|
|
|
|
|
|
|
|
|
|
static const int spaceshipRampForegroundRailing = above + ballOnSpaceshipRamp;
|
|
|
|
|
static const int spaceshipRampForegroundRailing =
|
|
|
|
|
_above + ballOnSpaceshipRamp;
|
|
|
|
|
|
|
|
|
|
static const int spaceshipRampBoardOpening = below + ballOnBoard;
|
|
|
|
|
static const int spaceshipRampBoardOpening = _below + ballOnBoard;
|
|
|
|
|
|
|
|
|
|
static const int alienBumper = above + ballOnBoard;
|
|
|
|
|
static const int alienBumper = _above + ballOnBoard;
|
|
|
|
|
|
|
|
|
|
// SCORE TEXT
|
|
|
|
|
|
|
|
|
|
static const int scoreText = above + spaceshipRampForegroundRailing;
|
|
|
|
|
static const int scoreText = _above + spaceshipRampForegroundRailing;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Helper methods to change the [priority] of a [Component].
|
|
|
|
|