mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-01 10:38:17 +08:00
chore: Enable DCM rule double-literal-format (#3248)
Enable DCM rule double-literal-format. More details [here](https://dcm.dev/docs/rules/common/double-literal-format/). This both forbids trailing zeroes and mandates leading zeroes. If we would prefer a different style (e.g. prefer no leading zero instead), just lmk :)
This commit is contained in:
@ -24,7 +24,7 @@ class SequenceEffectGame extends FlameGame {
|
|||||||
EffectController(duration: 0.5),
|
EffectController(duration: 0.5),
|
||||||
),
|
),
|
||||||
ScaleEffect.by(
|
ScaleEffect.by(
|
||||||
Vector2.all(.75),
|
Vector2.all(0.75),
|
||||||
EffectController(duration: 0.2, alternate: true),
|
EffectController(duration: 0.2, alternate: true),
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
|
|||||||
@ -12,7 +12,7 @@ class TableauPile extends PositionComponent implements Pile {
|
|||||||
/// Which cards are currently placed onto this pile.
|
/// Which cards are currently placed onto this pile.
|
||||||
final List<Card> _cards = [];
|
final List<Card> _cards = [];
|
||||||
final Vector2 _fanOffset1 = Vector2(0, KlondikeGame.cardHeight * 0.05);
|
final Vector2 _fanOffset1 = Vector2(0, KlondikeGame.cardHeight * 0.05);
|
||||||
final Vector2 _fanOffset2 = Vector2(0, KlondikeGame.cardHeight * 0.20);
|
final Vector2 _fanOffset2 = Vector2(0, KlondikeGame.cardHeight * 0.2);
|
||||||
|
|
||||||
//#region Pile API
|
//#region Pile API
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,7 @@ class TableauPile extends PositionComponent implements Pile {
|
|||||||
/// Which cards are currently placed onto this pile.
|
/// Which cards are currently placed onto this pile.
|
||||||
final List<Card> _cards = [];
|
final List<Card> _cards = [];
|
||||||
final Vector2 _fanOffset1 = Vector2(0, KlondikeGame.cardHeight * 0.05);
|
final Vector2 _fanOffset1 = Vector2(0, KlondikeGame.cardHeight * 0.05);
|
||||||
final Vector2 _fanOffset2 = Vector2(0, KlondikeGame.cardHeight * 0.20);
|
final Vector2 _fanOffset2 = Vector2(0, KlondikeGame.cardHeight * 0.2);
|
||||||
|
|
||||||
//#region Pile API
|
//#region Pile API
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ class WaterEnemy extends SpriteAnimationComponent
|
|||||||
SpriteAnimationData.sequenced(
|
SpriteAnimationData.sequenced(
|
||||||
amount: 2,
|
amount: 2,
|
||||||
textureSize: Vector2.all(16),
|
textureSize: Vector2.all(16),
|
||||||
stepTime: 0.70,
|
stepTime: 0.7,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
position = Vector2(
|
position = Vector2(
|
||||||
|
|||||||
@ -27,10 +27,10 @@ class Star extends SpriteComponent with HasGameReference<EmberQuestGame> {
|
|||||||
add(RectangleHitbox(collisionType: CollisionType.passive));
|
add(RectangleHitbox(collisionType: CollisionType.passive));
|
||||||
add(
|
add(
|
||||||
SizeEffect.by(
|
SizeEffect.by(
|
||||||
Vector2(-24, -24),
|
Vector2.all(-24),
|
||||||
EffectController(
|
EffectController(
|
||||||
duration: .75,
|
duration: 0.75,
|
||||||
reverseDuration: .5,
|
reverseDuration: 0.5,
|
||||||
infinite: true,
|
infinite: true,
|
||||||
curve: Curves.easeOut,
|
curve: Curves.easeOut,
|
||||||
),
|
),
|
||||||
|
|||||||
@ -52,7 +52,7 @@ class Player extends SpriteAnimationComponent
|
|||||||
'player.png',
|
'player.png',
|
||||||
SpriteAnimationData.sequenced(
|
SpriteAnimationData.sequenced(
|
||||||
amount: 4,
|
amount: 4,
|
||||||
stepTime: .2,
|
stepTime: 0.2,
|
||||||
textureSize: Vector2(32, 48),
|
textureSize: Vector2(32, 48),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -64,7 +64,7 @@ class Player extends SpriteAnimationComponent
|
|||||||
'player.png',
|
'player.png',
|
||||||
SpriteAnimationData.sequenced(
|
SpriteAnimationData.sequenced(
|
||||||
amount: 4,
|
amount: 4,
|
||||||
stepTime: .2,
|
stepTime: 0.2,
|
||||||
textureSize: Vector2(32, 48),
|
textureSize: Vector2(32, 48),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -72,7 +72,7 @@ class Player extends SpriteAnimationComponent
|
|||||||
position = game.size / 2;
|
position = game.size / 2;
|
||||||
|
|
||||||
_bulletSpawner = SpawnComponent(
|
_bulletSpawner = SpawnComponent(
|
||||||
period: .2,
|
period: 0.2,
|
||||||
selfPositioning: true,
|
selfPositioning: true,
|
||||||
factory: (index) {
|
factory: (index) {
|
||||||
return Bullet(
|
return Bullet(
|
||||||
@ -119,7 +119,7 @@ class Bullet extends SpriteAnimationComponent
|
|||||||
'bullet.png',
|
'bullet.png',
|
||||||
SpriteAnimationData.sequenced(
|
SpriteAnimationData.sequenced(
|
||||||
amount: 4,
|
amount: 4,
|
||||||
stepTime: .2,
|
stepTime: 0.2,
|
||||||
textureSize: Vector2(8, 16),
|
textureSize: Vector2(8, 16),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -75,7 +75,7 @@ class Player extends SpriteAnimationComponent
|
|||||||
'player.png',
|
'player.png',
|
||||||
SpriteAnimationData.sequenced(
|
SpriteAnimationData.sequenced(
|
||||||
amount: 4,
|
amount: 4,
|
||||||
stepTime: .2,
|
stepTime: 0.2,
|
||||||
textureSize: Vector2(32, 48),
|
textureSize: Vector2(32, 48),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -83,7 +83,7 @@ class Player extends SpriteAnimationComponent
|
|||||||
position = game.size / 2;
|
position = game.size / 2;
|
||||||
|
|
||||||
_bulletSpawner = SpawnComponent(
|
_bulletSpawner = SpawnComponent(
|
||||||
period: .2,
|
period: 0.2,
|
||||||
selfPositioning: true,
|
selfPositioning: true,
|
||||||
factory: (index) {
|
factory: (index) {
|
||||||
return Bullet(
|
return Bullet(
|
||||||
@ -130,7 +130,7 @@ class Bullet extends SpriteAnimationComponent
|
|||||||
'bullet.png',
|
'bullet.png',
|
||||||
SpriteAnimationData.sequenced(
|
SpriteAnimationData.sequenced(
|
||||||
amount: 4,
|
amount: 4,
|
||||||
stepTime: .2,
|
stepTime: 0.2,
|
||||||
textureSize: Vector2(8, 16),
|
textureSize: Vector2(8, 16),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -167,7 +167,7 @@ class Enemy extends SpriteAnimationComponent
|
|||||||
'enemy.png',
|
'enemy.png',
|
||||||
SpriteAnimationData.sequenced(
|
SpriteAnimationData.sequenced(
|
||||||
amount: 4,
|
amount: 4,
|
||||||
stepTime: .2,
|
stepTime: 0.2,
|
||||||
textureSize: Vector2.all(16),
|
textureSize: Vector2.all(16),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -77,7 +77,7 @@ class Player extends SpriteAnimationComponent
|
|||||||
'player.png',
|
'player.png',
|
||||||
SpriteAnimationData.sequenced(
|
SpriteAnimationData.sequenced(
|
||||||
amount: 4,
|
amount: 4,
|
||||||
stepTime: .2,
|
stepTime: 0.2,
|
||||||
textureSize: Vector2(32, 48),
|
textureSize: Vector2(32, 48),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -85,7 +85,7 @@ class Player extends SpriteAnimationComponent
|
|||||||
position = game.size / 2;
|
position = game.size / 2;
|
||||||
|
|
||||||
_bulletSpawner = SpawnComponent(
|
_bulletSpawner = SpawnComponent(
|
||||||
period: .2,
|
period: 0.2,
|
||||||
selfPositioning: true,
|
selfPositioning: true,
|
||||||
factory: (index) {
|
factory: (index) {
|
||||||
return Bullet(
|
return Bullet(
|
||||||
@ -132,7 +132,7 @@ class Bullet extends SpriteAnimationComponent
|
|||||||
'bullet.png',
|
'bullet.png',
|
||||||
SpriteAnimationData.sequenced(
|
SpriteAnimationData.sequenced(
|
||||||
amount: 4,
|
amount: 4,
|
||||||
stepTime: .2,
|
stepTime: 0.2,
|
||||||
textureSize: Vector2(8, 16),
|
textureSize: Vector2(8, 16),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -175,7 +175,7 @@ class Enemy extends SpriteAnimationComponent
|
|||||||
'enemy.png',
|
'enemy.png',
|
||||||
SpriteAnimationData.sequenced(
|
SpriteAnimationData.sequenced(
|
||||||
amount: 4,
|
amount: 4,
|
||||||
stepTime: .2,
|
stepTime: 0.2,
|
||||||
textureSize: Vector2.all(16),
|
textureSize: Vector2.all(16),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -227,7 +227,7 @@ class Explosion extends SpriteAnimationComponent
|
|||||||
'explosion.png',
|
'explosion.png',
|
||||||
SpriteAnimationData.sequenced(
|
SpriteAnimationData.sequenced(
|
||||||
amount: 6,
|
amount: 6,
|
||||||
stepTime: .1,
|
stepTime: 0.1,
|
||||||
textureSize: Vector2.all(32),
|
textureSize: Vector2.all(32),
|
||||||
loop: false,
|
loop: false,
|
||||||
),
|
),
|
||||||
|
|||||||
@ -36,7 +36,7 @@ class GameOverText extends SpriteComponent with HasGameReference<TRexGame> {
|
|||||||
void onGameResize(Vector2 size) {
|
void onGameResize(Vector2 size) {
|
||||||
super.onGameResize(size);
|
super.onGameResize(size);
|
||||||
x = size.x / 2;
|
x = size.x / 2;
|
||||||
y = size.y * .25;
|
y = size.y * 0.25;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,6 +56,6 @@ class GameOverRestart extends SpriteComponent with HasGameReference<TRexGame> {
|
|||||||
void onGameResize(Vector2 size) {
|
void onGameResize(Vector2 size) {
|
||||||
super.onGameResize(size);
|
super.onGameResize(size);
|
||||||
x = size.x / 2;
|
x = size.x / 2;
|
||||||
y = size.y * .75;
|
y = size.y * 0.75;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -71,8 +71,8 @@ class CircleShuffler extends BodyComponent {
|
|||||||
final fixtureDef = FixtureDef(
|
final fixtureDef = FixtureDef(
|
||||||
shape,
|
shape,
|
||||||
density: 50.0,
|
density: 50.0,
|
||||||
friction: .1,
|
friction: 0.1,
|
||||||
restitution: .9,
|
restitution: 0.9,
|
||||||
);
|
);
|
||||||
|
|
||||||
body.createFixture(fixtureDef);
|
body.createFixture(fixtureDef);
|
||||||
|
|||||||
@ -173,7 +173,7 @@ class AntWorld extends World {
|
|||||||
add(
|
add(
|
||||||
Ant()
|
Ant()
|
||||||
..color = baseColor.withHue(random.nextDouble() * 360).toColor()
|
..color = baseColor.withHue(random.nextDouble() * 360).toColor()
|
||||||
..scale = Vector2.all(.4)
|
..scale = Vector2.all(0.4)
|
||||||
..setTravelPath(curve.path),
|
..setTravelPath(curve.path),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -263,7 +263,7 @@ class CollidableSnowman extends MyCollidable {
|
|||||||
);
|
);
|
||||||
final middle = SnowmanPart(
|
final middle = SnowmanPart(
|
||||||
size.x * 0.4,
|
size.x * 0.4,
|
||||||
Vector2(size.x / 2, size.y * 0.40),
|
Vector2(size.x / 2, size.y * 0.4),
|
||||||
Colors.yellow,
|
Colors.yellow,
|
||||||
);
|
);
|
||||||
final bottom = SnowmanPart(
|
final bottom = SnowmanPart(
|
||||||
|
|||||||
@ -22,7 +22,7 @@ class _Rectangle extends RectangleComponent {
|
|||||||
children: [
|
children: [
|
||||||
RotateEffect.by(
|
RotateEffect.by(
|
||||||
pi * 2,
|
pi * 2,
|
||||||
EffectController(duration: .4, infinite: true),
|
EffectController(duration: 0.4, infinite: true),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
@ -169,7 +169,7 @@ class ParticlesExample extends FlameGame {
|
|||||||
return Particle.generate(
|
return Particle.generate(
|
||||||
count: 5,
|
count: 5,
|
||||||
generator: (i) => MovingParticle(
|
generator: (i) => MovingParticle(
|
||||||
to: randomCellVector2()..scale(.5),
|
to: randomCellVector2()..scale(0.5),
|
||||||
child: CircleParticle(
|
child: CircleParticle(
|
||||||
radius: 5 + rnd.nextDouble() * 5,
|
radius: 5 + rnd.nextDouble() * 5,
|
||||||
paint: Paint()..color = Colors.deepOrange,
|
paint: Paint()..color = Colors.deepOrange,
|
||||||
@ -185,7 +185,7 @@ class ParticlesExample extends FlameGame {
|
|||||||
count: 5,
|
count: 5,
|
||||||
generator: (i) => MovingParticle(
|
generator: (i) => MovingParticle(
|
||||||
curve: Curves.easeOutQuad,
|
curve: Curves.easeOutQuad,
|
||||||
to: randomCellVector2()..scale(.5),
|
to: randomCellVector2()..scale(0.5),
|
||||||
child: CircleParticle(
|
child: CircleParticle(
|
||||||
radius: 5 + rnd.nextDouble() * 5,
|
radius: 5 + rnd.nextDouble() * 5,
|
||||||
paint: Paint()..color = Colors.deepPurple,
|
paint: Paint()..color = Colors.deepPurple,
|
||||||
@ -203,8 +203,8 @@ class ParticlesExample extends FlameGame {
|
|||||||
return Particle.generate(
|
return Particle.generate(
|
||||||
count: 5,
|
count: 5,
|
||||||
generator: (i) => MovingParticle(
|
generator: (i) => MovingParticle(
|
||||||
curve: const Interval(.2, .6, curve: Curves.easeInOutCubic),
|
curve: const Interval(0.2, 0.6, curve: Curves.easeInOutCubic),
|
||||||
to: randomCellVector2()..scale(.5),
|
to: randomCellVector2()..scale(0.5),
|
||||||
child: CircleParticle(
|
child: CircleParticle(
|
||||||
radius: 5 + rnd.nextDouble() * 5,
|
radius: 5 + rnd.nextDouble() * 5,
|
||||||
paint: Paint()..color = Colors.greenAccent,
|
paint: Paint()..color = Colors.greenAccent,
|
||||||
@ -269,8 +269,8 @@ class ParticlesExample extends FlameGame {
|
|||||||
|
|
||||||
return Particle.generate(
|
return Particle.generate(
|
||||||
generator: (i) => MovingParticle(
|
generator: (i) => MovingParticle(
|
||||||
curve: Interval(rnd.nextDouble() * .1, rnd.nextDouble() * .8 + .1),
|
curve: Interval(rnd.nextDouble() * 0.1, rnd.nextDouble() * 0.8 + 0.1),
|
||||||
to: randomCellVector2()..scale(.5),
|
to: randomCellVector2()..scale(0.5),
|
||||||
child: reusableParticle!,
|
child: reusableParticle!,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -327,8 +327,11 @@ class ParticlesExample extends FlameGame {
|
|||||||
Particle acceleratedParticles() {
|
Particle acceleratedParticles() {
|
||||||
return Particle.generate(
|
return Particle.generate(
|
||||||
generator: (i) => AcceleratedParticle(
|
generator: (i) => AcceleratedParticle(
|
||||||
speed:
|
speed: Vector2(
|
||||||
Vector2(rnd.nextDouble() * 600 - 300, -rnd.nextDouble() * 600) * .2,
|
rnd.nextDouble() * 600 - 300,
|
||||||
|
-rnd.nextDouble() * 600,
|
||||||
|
) *
|
||||||
|
0.2,
|
||||||
acceleration: Vector2(0, 200),
|
acceleration: Vector2(0, 200),
|
||||||
child: rotatingImage(initialAngle: rnd.nextDouble() * pi),
|
child: rotatingImage(initialAngle: rnd.nextDouble() * pi),
|
||||||
),
|
),
|
||||||
@ -373,7 +376,7 @@ class ParticlesExample extends FlameGame {
|
|||||||
Particle spriteParticle() {
|
Particle spriteParticle() {
|
||||||
return SpriteParticle(
|
return SpriteParticle(
|
||||||
sprite: Sprite(images.fromCache('zap.png')),
|
sprite: Sprite(images.fromCache('zap.png')),
|
||||||
size: cellSize * .5,
|
size: cellSize * 0.5,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,8 +395,8 @@ class ParticlesExample extends FlameGame {
|
|||||||
/// which is independent from the parent [Particle].
|
/// which is independent from the parent [Particle].
|
||||||
Particle componentParticle() {
|
Particle componentParticle() {
|
||||||
return MovingParticle(
|
return MovingParticle(
|
||||||
from: -halfCellSize * .2,
|
from: -halfCellSize * 0.2,
|
||||||
to: halfCellSize * .2,
|
to: halfCellSize * 0.2,
|
||||||
curve: SineCurve(),
|
curve: SineCurve(),
|
||||||
child: ComponentParticle(component: trafficLight),
|
child: ComponentParticle(component: trafficLight),
|
||||||
);
|
);
|
||||||
@ -435,7 +438,7 @@ class ParticlesExample extends FlameGame {
|
|||||||
Offset.zero,
|
Offset.zero,
|
||||||
// Closer to the end of lifespan particles
|
// Closer to the end of lifespan particles
|
||||||
// will turn into larger glaring circles
|
// will turn into larger glaring circles
|
||||||
rnd.nextDouble() * particle.progress > .6
|
rnd.nextDouble() * particle.progress > 0.6
|
||||||
? rnd.nextDouble() * (50 * particle.progress)
|
? rnd.nextDouble() * (50 * particle.progress)
|
||||||
: 2 + (3 * particle.progress),
|
: 2 + (3 * particle.progress),
|
||||||
paint,
|
paint,
|
||||||
|
|||||||
@ -20,7 +20,7 @@ final class TapConfig {
|
|||||||
/// Min delay to long tap delay is defined below.
|
/// Min delay to long tap delay is defined below.
|
||||||
/// Values too low don't make sense because they
|
/// Values too low don't make sense because they
|
||||||
/// would be basically a regular tap.
|
/// would be basically a regular tap.
|
||||||
static const double _minLongTapDelay = 0.150;
|
static const double _minLongTapDelay = 0.15;
|
||||||
|
|
||||||
/// Default long tap delay is 0.3 seconds.
|
/// Default long tap delay is 0.3 seconds.
|
||||||
static const double _defaultLongTapDelay = 0.3;
|
static const double _defaultLongTapDelay = 0.3;
|
||||||
|
|||||||
@ -57,7 +57,7 @@ abstract class Particle {
|
|||||||
Particle({
|
Particle({
|
||||||
double? lifespan,
|
double? lifespan,
|
||||||
}) {
|
}) {
|
||||||
setLifespan(lifespan ?? .5);
|
setLifespan(lifespan ?? 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Getter for the current lifespan of this [Particle].
|
/// Getter for the current lifespan of this [Particle].
|
||||||
|
|||||||
@ -14,7 +14,7 @@ void main() {
|
|||||||
|
|
||||||
test('longTapDelay cannot be set to a value lower than 0.150', () {
|
test('longTapDelay cannot be set to a value lower than 0.150', () {
|
||||||
TapConfig.longTapDelay = 0.1;
|
TapConfig.longTapDelay = 0.1;
|
||||||
expect(TapConfig.longTapDelay, 0.150);
|
expect(TapConfig.longTapDelay, 0.15);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,7 +47,7 @@ void main() {
|
|||||||
' and then restores', () {
|
' and then restores', () {
|
||||||
final canvas = _MocktailCanvas();
|
final canvas = _MocktailCanvas();
|
||||||
when(canvas.save).thenReturn(null);
|
when(canvas.save).thenReturn(null);
|
||||||
when(() => canvas.rotate(.5)).thenReturn(null);
|
when(() => canvas.rotate(0.5)).thenReturn(null);
|
||||||
when(() => canvas.translateVector(Vector2(1, 1))).thenReturn(null);
|
when(() => canvas.translateVector(Vector2(1, 1))).thenReturn(null);
|
||||||
when(() => canvas.translateVector(Vector2(-1, -1))).thenReturn(null);
|
when(() => canvas.translateVector(Vector2(-1, -1))).thenReturn(null);
|
||||||
when(canvas.restore).thenReturn(null);
|
when(canvas.restore).thenReturn(null);
|
||||||
@ -57,7 +57,7 @@ void main() {
|
|||||||
canvas.renderRotated(0.5, Vector2(1, 1), drawFunction.call);
|
canvas.renderRotated(0.5, Vector2(1, 1), drawFunction.call);
|
||||||
verify(canvas.save).called(1);
|
verify(canvas.save).called(1);
|
||||||
verify(() => canvas.translateVector(Vector2(1, 1))).called(1);
|
verify(() => canvas.translateVector(Vector2(1, 1))).called(1);
|
||||||
verify(() => canvas.rotate(.5)).called(1);
|
verify(() => canvas.rotate(0.5)).called(1);
|
||||||
verify(() => drawFunction(canvas)).called(1);
|
verify(() => drawFunction(canvas)).called(1);
|
||||||
verify(() => canvas.translateVector(Vector2(-1, -1))).called(1);
|
verify(() => canvas.translateVector(Vector2(-1, -1))).called(1);
|
||||||
verify(canvas.restore).called(1);
|
verify(canvas.restore).called(1);
|
||||||
|
|||||||
@ -81,9 +81,9 @@ void main() {
|
|||||||
// create points left, above, right and under
|
// create points left, above, right and under
|
||||||
|
|
||||||
// y position [0, 1] but left to rect's left
|
// y position [0, 1] but left to rect's left
|
||||||
final left = Vector2(-.5, r.nextDouble() * 1);
|
final left = Vector2(-0.5, r.nextDouble() * 1);
|
||||||
// x position [0, 1] but above rect's top
|
// x position [0, 1] but above rect's top
|
||||||
final above = Vector2(r.nextDouble() * 1, -.5);
|
final above = Vector2(r.nextDouble() * 1, -0.5);
|
||||||
// y position [0, 1] but right to rect's right
|
// y position [0, 1] but right to rect's right
|
||||||
final right = Vector2(1.5, r.nextDouble() * 1);
|
final right = Vector2(1.5, r.nextDouble() * 1);
|
||||||
// x position [0, 1] but under rect's bottom
|
// x position [0, 1] but under rect's bottom
|
||||||
@ -96,22 +96,22 @@ void main() {
|
|||||||
expect(rect.intersectsSegment(under, above), true);
|
expect(rect.intersectsSegment(under, above), true);
|
||||||
|
|
||||||
// above the rect and left to rect's left
|
// above the rect and left to rect's left
|
||||||
final aboveLeft = Vector2(-.5, r.nextDouble() * 1 - 1);
|
final aboveLeft = Vector2(-0.5, r.nextDouble() * 1 - 1);
|
||||||
// above the rect and left to rect's left
|
// above the rect and left to rect's left
|
||||||
final aboveRight = Vector2(1.5, r.nextDouble() * 1 - 1);
|
final aboveRight = Vector2(1.5, r.nextDouble() * 1 - 1);
|
||||||
// under the rect and right to rect's right
|
// under the rect and right to rect's right
|
||||||
final underRight = Vector2(1.5, r.nextDouble() * 1 + 1);
|
final underRight = Vector2(1.5, r.nextDouble() * 1 + 1);
|
||||||
// under the rect and left to rect's left
|
// under the rect and left to rect's left
|
||||||
final underLeft = Vector2(-.5, r.nextDouble() * 1 + 1);
|
final underLeft = Vector2(-0.5, r.nextDouble() * 1 + 1);
|
||||||
expect(rect.intersectsSegment(aboveLeft, aboveRight), false);
|
expect(rect.intersectsSegment(aboveLeft, aboveRight), false);
|
||||||
expect(rect.intersectsSegment(aboveLeft, underLeft), false);
|
expect(rect.intersectsSegment(aboveLeft, underLeft), false);
|
||||||
expect(rect.intersectsSegment(underLeft, underRight), false);
|
expect(rect.intersectsSegment(underLeft, underRight), false);
|
||||||
expect(rect.intersectsSegment(underRight, aboveRight), false);
|
expect(rect.intersectsSegment(underRight, aboveRight), false);
|
||||||
|
|
||||||
// any y position but left to rect's left
|
// any y position but left to rect's left
|
||||||
final nearLeft = Vector2(-.25, r.nextDouble() * 256);
|
final nearLeft = Vector2(-0.25, r.nextDouble() * 256);
|
||||||
// any x position but above rect's top
|
// any x position but above rect's top
|
||||||
final nearAbove = Vector2(r.nextDouble() * 256, -.25);
|
final nearAbove = Vector2(r.nextDouble() * 256, -0.25);
|
||||||
// any y position but right to rect's right
|
// any y position but right to rect's right
|
||||||
final nearRight = Vector2(1.25, r.nextDouble() * 256);
|
final nearRight = Vector2(1.25, r.nextDouble() * 256);
|
||||||
// any x position but under rect's bottom
|
// any x position but under rect's bottom
|
||||||
|
|||||||
@ -17,8 +17,8 @@ void main() {
|
|||||||
'default viewport does not change size',
|
'default viewport does not change size',
|
||||||
(game) async {
|
(game) async {
|
||||||
game.onGameResize(Vector2(100.0, 200.0));
|
game.onGameResize(Vector2(100.0, 200.0));
|
||||||
expect(game.canvasSize, Vector2(100.0, 200.00));
|
expect(game.canvasSize, Vector2(100.0, 200.0));
|
||||||
expect(game.size, Vector2(100.0, 200.00));
|
expect(game.size, Vector2(100.0, 200.0));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -556,7 +556,7 @@ void main() {
|
|||||||
game.handleForcePressStart(
|
game.handleForcePressStart(
|
||||||
ForcePressDetails(
|
ForcePressDetails(
|
||||||
globalPosition: const Offset(10, 10),
|
globalPosition: const Offset(10, 10),
|
||||||
pressure: .4,
|
pressure: 0.4,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -573,7 +573,7 @@ void main() {
|
|||||||
game.handleForcePressUpdate(
|
game.handleForcePressUpdate(
|
||||||
ForcePressDetails(
|
ForcePressDetails(
|
||||||
globalPosition: const Offset(10, 10),
|
globalPosition: const Offset(10, 10),
|
||||||
pressure: .7,
|
pressure: 0.7,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -590,7 +590,7 @@ void main() {
|
|||||||
game.handleForcePressPeak(
|
game.handleForcePressPeak(
|
||||||
ForcePressDetails(
|
ForcePressDetails(
|
||||||
globalPosition: const Offset(10, 10),
|
globalPosition: const Offset(10, 10),
|
||||||
pressure: .9,
|
pressure: 0.9,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -607,7 +607,7 @@ void main() {
|
|||||||
game.handleForcePressEnd(
|
game.handleForcePressEnd(
|
||||||
ForcePressDetails(
|
ForcePressDetails(
|
||||||
globalPosition: const Offset(10, 10),
|
globalPosition: const Offset(10, 10),
|
||||||
pressure: .2,
|
pressure: 0.2,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(game.forcePressEnded, equals(1));
|
expect(game.forcePressEnded, equals(1));
|
||||||
|
|||||||
@ -18,7 +18,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
final particle = rect.scaling(to: .5, curve: Curves.easeIn);
|
final particle = rect.scaling(to: 0.5, curve: Curves.easeIn);
|
||||||
|
|
||||||
final component = ParticleSystemComponent(
|
final component = ParticleSystemComponent(
|
||||||
particle: particle,
|
particle: particle,
|
||||||
@ -28,7 +28,7 @@ void main() {
|
|||||||
await game.ready();
|
await game.ready();
|
||||||
game.update(1);
|
game.update(1);
|
||||||
|
|
||||||
expect(particle.scale, .841796875);
|
expect(particle.scale, 0.841796875);
|
||||||
expect(particle.curve, Curves.easeIn);
|
expect(particle.curve, Curves.easeIn);
|
||||||
expect(particle.progress, 0.31640625);
|
expect(particle.progress, 0.31640625);
|
||||||
expect(particle.child, isInstanceOf<ComputedParticle>());
|
expect(particle.child, isInstanceOf<ComputedParticle>());
|
||||||
|
|||||||
@ -238,7 +238,7 @@ void main() {
|
|||||||
final animation = AnimationSelection.fromJson({
|
final animation = AnimationSelection.fromJson({
|
||||||
'id': 'bomb_ptero',
|
'id': 'bomb_ptero',
|
||||||
'frameCount': 1,
|
'frameCount': 1,
|
||||||
'stepTime': .2,
|
'stepTime': 0.2,
|
||||||
'loop': true,
|
'loop': true,
|
||||||
'x': 0,
|
'x': 0,
|
||||||
'y': 0,
|
'y': 0,
|
||||||
@ -249,7 +249,7 @@ void main() {
|
|||||||
|
|
||||||
expect(animation.id, 'bomb_ptero');
|
expect(animation.id, 'bomb_ptero');
|
||||||
expect(animation.frameCount, 1);
|
expect(animation.frameCount, 1);
|
||||||
expect(animation.stepTime, .2);
|
expect(animation.stepTime, 0.2);
|
||||||
expect(animation.loop, isTrue);
|
expect(animation.loop, isTrue);
|
||||||
expect(animation.x, 0);
|
expect(animation.x, 0);
|
||||||
expect(animation.y, 0);
|
expect(animation.y, 0);
|
||||||
@ -268,14 +268,14 @@ void main() {
|
|||||||
h: 16,
|
h: 16,
|
||||||
),
|
),
|
||||||
frameCount: 1,
|
frameCount: 1,
|
||||||
stepTime: .2,
|
stepTime: 0.2,
|
||||||
loop: true,
|
loop: true,
|
||||||
group: 'enemies',
|
group: 'enemies',
|
||||||
);
|
);
|
||||||
final json = animation.toJson();
|
final json = animation.toJson();
|
||||||
expect(json['id'], 'bomb_ptero');
|
expect(json['id'], 'bomb_ptero');
|
||||||
expect(json['frameCount'], 1);
|
expect(json['frameCount'], 1);
|
||||||
expect(json['stepTime'], .2);
|
expect(json['stepTime'], 0.2);
|
||||||
expect(json['loop'], isTrue);
|
expect(json['loop'], isTrue);
|
||||||
expect(json['x'], 0);
|
expect(json['x'], 0);
|
||||||
expect(json['y'], 0);
|
expect(json['y'], 0);
|
||||||
@ -295,7 +295,7 @@ void main() {
|
|||||||
h: 16,
|
h: 16,
|
||||||
),
|
),
|
||||||
frameCount: 1,
|
frameCount: 1,
|
||||||
stepTime: .2,
|
stepTime: 0.2,
|
||||||
loop: true,
|
loop: true,
|
||||||
group: 'enemies',
|
group: 'enemies',
|
||||||
);
|
);
|
||||||
@ -304,7 +304,7 @@ void main() {
|
|||||||
expect(copy.group, 'new_group');
|
expect(copy.group, 'new_group');
|
||||||
expect(copy.id, 'bomb_ptero');
|
expect(copy.id, 'bomb_ptero');
|
||||||
expect(copy.frameCount, 1);
|
expect(copy.frameCount, 1);
|
||||||
expect(copy.stepTime, .2);
|
expect(copy.stepTime, 0.2);
|
||||||
expect(copy.loop, isTrue);
|
expect(copy.loop, isTrue);
|
||||||
expect(copy.x, 0);
|
expect(copy.x, 0);
|
||||||
expect(copy.y, 0);
|
expect(copy.y, 0);
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
class Grass extends PositionComponent with Terrain {
|
class Grass extends PositionComponent with Terrain {
|
||||||
static final _color = Paint()..color = const Color(0xff567d46);
|
static final _color = Paint()..color = const Color(0xff567d46);
|
||||||
static final _debugColor = Paint()..color = Colors.black.withOpacity(.5);
|
static final _debugColor = Paint()..color = Colors.black.withOpacity(0.5);
|
||||||
|
|
||||||
late final _rect = size.toRect();
|
late final _rect = size.toRect();
|
||||||
late final _rect2 = Rect.fromCenter(
|
late final _rect2 = Rect.fromCenter(
|
||||||
|
|||||||
@ -15,5 +15,6 @@ dart_code_metrics:
|
|||||||
ignore-mixins: true
|
ignore-mixins: true
|
||||||
- avoid-unnecessary-type-assertions:
|
- avoid-unnecessary-type-assertions:
|
||||||
ignore-mixins: true
|
ignore-mixins: true
|
||||||
|
- double-literal-format
|
||||||
# flutter rules
|
# flutter rules
|
||||||
- prefer-define-hero-tag
|
- prefer-define-hero-tag
|
||||||
@ -31,7 +31,7 @@ class MyGame extends FlameGame with TapDetector {
|
|||||||
SpriteAnimationData.sequenced(
|
SpriteAnimationData.sequenced(
|
||||||
textureSize: Vector2(48, 32),
|
textureSize: Vector2(48, 32),
|
||||||
amount: 4,
|
amount: 4,
|
||||||
stepTime: .2,
|
stepTime: 0.2,
|
||||||
),
|
),
|
||||||
size: Vector2(100, 50),
|
size: Vector2(100, 50),
|
||||||
anchor: Anchor.center,
|
anchor: Anchor.center,
|
||||||
|
|||||||
@ -19,7 +19,7 @@ class FlameStudioToolbar extends ConsumerWidget {
|
|||||||
];
|
];
|
||||||
|
|
||||||
final height = ref.watch(toolbarHeightProvider);
|
final height = ref.watch(toolbarHeightProvider);
|
||||||
final gap = height * 0.10;
|
final gap = height * 0.1;
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
constraints: BoxConstraints.tightFor(height: height),
|
constraints: BoxConstraints.tightFor(height: height),
|
||||||
|
|||||||
@ -54,7 +54,7 @@ class TiledGame extends FlameGame {
|
|||||||
coins,
|
coins,
|
||||||
SpriteAnimationData.sequenced(
|
SpriteAnimationData.sequenced(
|
||||||
amount: 8,
|
amount: 8,
|
||||||
stepTime: .15,
|
stepTime: 0.15,
|
||||||
textureSize: Vector2.all(20),
|
textureSize: Vector2.all(20),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -67,8 +67,8 @@ class OrthogonalTileLayer extends FlameTileLayer {
|
|||||||
|
|
||||||
late double offsetX;
|
late double offsetX;
|
||||||
late double offsetY;
|
late double offsetY;
|
||||||
offsetX = (tx + .5) * size.x;
|
offsetX = (tx + 0.5) * size.x;
|
||||||
offsetY = (ty + .5) * size.y;
|
offsetY = (ty + 0.5) * size.y;
|
||||||
|
|
||||||
offsetX += tileset.tileOffset?.x ?? 0;
|
offsetX += tileset.tileOffset?.x ?? 0;
|
||||||
offsetY += tileset.tileOffset?.y ?? 0;
|
offsetY += tileset.tileOffset?.y ?? 0;
|
||||||
|
|||||||
@ -969,27 +969,27 @@ void main() {
|
|||||||
|
|
||||||
final waterAnimation = layer.animations.first;
|
final waterAnimation = layer.animations.first;
|
||||||
final spikeAnimation = layer.animations.last;
|
final spikeAnimation = layer.animations.last;
|
||||||
expect(waterAnimation.frames.durations, [.18, .17, .15]);
|
expect(waterAnimation.frames.durations, [0.18, 0.17, 0.15]);
|
||||||
expect(spikeAnimation.frames.durations, [.176, .176, .176, .176]);
|
expect(spikeAnimation.frames.durations, [0.176, 0.176, 0.176, 0.176]);
|
||||||
|
|
||||||
map.update(.177);
|
map.update(0.177);
|
||||||
expect(waterAnimation.frame, 0);
|
expect(waterAnimation.frame, 0);
|
||||||
expect(waterAnimation.frames.frameTime, .177);
|
expect(waterAnimation.frames.frameTime, 0.177);
|
||||||
expect(
|
expect(
|
||||||
waterAnimation.batchedSource.toRect(),
|
waterAnimation.batchedSource.toRect(),
|
||||||
waterAnimation.frames.sources[0],
|
waterAnimation.frames.sources[0],
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(spikeAnimation.frame, 1);
|
expect(spikeAnimation.frame, 1);
|
||||||
expect(spikeAnimation.frames.frameTime, moreOrLessEquals(.001));
|
expect(spikeAnimation.frames.frameTime, moreOrLessEquals(0.001));
|
||||||
expect(
|
expect(
|
||||||
spikeAnimation.batchedSource.toRect(),
|
spikeAnimation.batchedSource.toRect(),
|
||||||
spikeAnimation.frames.sources[1],
|
spikeAnimation.frames.sources[1],
|
||||||
);
|
);
|
||||||
|
|
||||||
map.update(.003);
|
map.update(0.003);
|
||||||
expect(waterAnimation.frame, 1);
|
expect(waterAnimation.frame, 1);
|
||||||
expect(waterAnimation.frames.frameTime, moreOrLessEquals(.0));
|
expect(waterAnimation.frames.frameTime, moreOrLessEquals(0.0));
|
||||||
expect(spikeAnimation.frame, 1);
|
expect(spikeAnimation.frame, 1);
|
||||||
expect(spikeAnimation.frames.frameTime, moreOrLessEquals(0.004));
|
expect(spikeAnimation.frames.frameTime, moreOrLessEquals(0.004));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user