Fixes nits
This commit is contained in:
@@ -8,6 +8,9 @@ abstract class Constraint {
|
||||
}
|
||||
|
||||
double _dampenRotation(double src, double dst, double dampening) {
|
||||
if (dampening == null)
|
||||
return dst;
|
||||
|
||||
double delta = dst - src;
|
||||
while (delta > 180.0) delta -= 360;
|
||||
while (delta < -180) delta += 360;
|
||||
@@ -36,10 +39,7 @@ class ConstraintRotationToMovement {
|
||||
Offset offset = node.position - _lastPosition;
|
||||
double target = degrees(GameMath.atan2(offset.dy, offset.dx)) + baseRotation;
|
||||
|
||||
if (dampening == null)
|
||||
node.rotation = target;
|
||||
else
|
||||
node.rotation = _dampenRotation(node.rotation, target, dampening);
|
||||
node.rotation = _dampenRotation(node.rotation, target, dampening);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,9 +62,6 @@ class ConstraintRotationToNode {
|
||||
|
||||
double target = degrees(GameMath.atan2(offset.dy, offset.dx)) + baseRotation;
|
||||
|
||||
if (dampening == null)
|
||||
node.rotation = target;
|
||||
else
|
||||
node.rotation = _dampenRotation(node.rotation, target, dampening);
|
||||
node.rotation = _dampenRotation(node.rotation, target, dampening);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -394,7 +394,7 @@ abstract class Asteroid extends Obstacle {
|
||||
void setupActions() {
|
||||
// Rotate obstacle
|
||||
int direction = 1;
|
||||
if (randomDouble() < 0.5) direction = -1;
|
||||
if (randomBool()) direction = -1;
|
||||
ActionTween rotate = new ActionTween(
|
||||
(a) => _sprt.rotation = a,
|
||||
0.0, 360.0 * direction, 5.0 + 5.0 * randomDouble());
|
||||
@@ -442,21 +442,25 @@ class MovingEnemy extends Obstacle {
|
||||
final double _swirlSpacing = 80.0;
|
||||
|
||||
_addRandomSquare(List<Offset> offsets, double x, double y) {
|
||||
double xMove = (randomDouble() < 0.5) ? _swirlSpacing : -_swirlSpacing;
|
||||
double yMove = (randomDouble() < 0.5) ? _swirlSpacing : -_swirlSpacing;
|
||||
double xMove = (randomBool()) ? _swirlSpacing : -_swirlSpacing;
|
||||
double yMove = (randomBool()) ? _swirlSpacing : -_swirlSpacing;
|
||||
|
||||
if (randomDouble() < 0.5) {
|
||||
offsets.add(new Offset(x, y));
|
||||
offsets.add(new Offset(xMove + x, y));
|
||||
offsets.add(new Offset(xMove + x, yMove + y));
|
||||
offsets.add(new Offset(x, yMove + y));
|
||||
offsets.add(new Offset(x, y));
|
||||
if (randomBool()) {
|
||||
offsets.addAll([
|
||||
new Offset(x, y),
|
||||
new Offset(xMove + x, y),
|
||||
new Offset(xMove + x, yMove + y),
|
||||
new Offset(x, yMove + y),
|
||||
new Offset(x, y)
|
||||
]);
|
||||
} else {
|
||||
offsets.add(new Offset(x, y));
|
||||
offsets.add(new Offset(x, y + yMove));
|
||||
offsets.add(new Offset(xMove + x, yMove + y));
|
||||
offsets.add(new Offset(xMove + x, y));
|
||||
offsets.add(new Offset(x, y));
|
||||
offsets.addAll([
|
||||
new Offset(x, y),
|
||||
new Offset(x, y + yMove),
|
||||
new Offset(xMove + x, yMove + y),
|
||||
new Offset(xMove + x, y),
|
||||
new Offset(x, y)
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,10 @@ int randomInt(int max) {
|
||||
return _random.nextInt(max);
|
||||
}
|
||||
|
||||
bool randomBool() {
|
||||
return _random.nextDouble() < 0.5;
|
||||
}
|
||||
|
||||
// atan2
|
||||
|
||||
class _Atan2Constants {
|
||||
|
||||
Reference in New Issue
Block a user