gameplay: dosable power and a playable landscape layout

Two findings from actually playing:

1. Shot power was hard to set and impossible to read. It was derived from the
   absolute distance to the tank (250 world px = 100 %) and only shown through
   the size of the aim dots, so direction and power changed together.
   Aiming is now a slingshot: the drag length sets the power (260 px = 100 %),
   the drag direction sets the shot direction, with a 6 px dead zone. Feedback:
   a dashed rubber band to the finger, a charge bar under the active tank with
   quarter marks, and a HUD row with angle plus a power bar and percentage.

2. Landscape was unplayable. The camera used zoom = max(fitHeight, fitWidth),
   so a wide view zoomed in and cropped the world top and bottom - and the
   camera never panned vertically, which put both tanks off-screen. The camera
   now always fits the world height, centres the world when the view is wider,
   and the background continues into the letterbox (ridges tiled, ground edge
   extended, vignette follows the visible range). Controls and paddings are
   compact in landscape.

- new golden test landscape.png (840x420) shows both tanks and guards the bug;
  18 tests green.
- verified on the device in both orientations: shots fire, measured power 47 %
  and 54 % mid-gesture, no RenderFlex overflow in logcat, perf.sh still
  60.0 fps / 0.0 % jank (p90 16.9 ms).
- store screenshots re-captured with the new HUD and re-framed to 16:9;
  play-console.md release notes and "how to play" updated for 0.9.1.
- release 0.9.1 (14).
This commit is contained in:
2026-10-25 15:14:02 +01:00
parent 77226b1469
commit 254e0d2675
24 changed files with 977 additions and 73 deletions
+93 -14
View File
@@ -98,8 +98,10 @@ class SkyArt {
void _build() {
final rnd = math.Random(seed);
for (var i = 0; i < 16; i++) {
_stars.add(Offset(rnd.nextDouble() * kArtWorldWidth, rnd.nextDouble() * 430));
for (var i = 0; i < 22; i++) {
// Wider than the world: landscape letterboxes the sides with sky.
_stars.add(Offset(
-700 + rnd.nextDouble() * (kArtWorldWidth + 1400), rnd.nextDouble() * 430));
}
_ridges.addAll([
_Ridge(
@@ -153,28 +155,36 @@ class SkyArt {
void paint(Canvas canvas, {required double camX, required double viewWidth}) {
if (!_built) _build();
final left = camX - 12;
final right = camX + viewWidth + 12;
canvas.drawRect(
const Rect.fromLTWH(0, 0, kArtWorldWidth, kArtWorldHeight),
Rect.fromLTRB(left, 0, right, kArtWorldHeight),
_skyPaint,
);
_starPaint.color = const Color(0xFFDCE6F5).withValues(alpha: 0.22);
for (final s in _stars) {
final dx = s.dx + camX * 0.85;
if (dx < -40 || dx > kArtWorldWidth + 40) continue;
if (dx < left - 40 || dx > right + 40) continue;
canvas.drawCircle(Offset(dx, s.dy), 2.2, _starPaint);
}
_paintSun(canvas, Offset(camX + viewWidth * 0.66, 395));
// Tile the ridges so the horizon continues into the letterbox area.
for (final ridge in _ridges) {
canvas.save();
canvas.translate(camX * (1 - ridge.parallax), 0);
canvas.drawPath(ridge.path, ridge.fillPaint);
if (ridge.rim.a > 0.01) {
canvas.drawPath(ridge.path, ridge.rimPaint);
final base = camX * (1 - ridge.parallax);
for (final tile in const [-kArtWorldWidth, 0.0, kArtWorldWidth]) {
final shift = base + tile;
if (shift > right || shift + kArtWorldWidth < left) continue;
canvas.save();
canvas.translate(shift, 0);
canvas.drawPath(ridge.path, ridge.fillPaint);
if (ridge.rim.a > 0.01) {
canvas.drawPath(ridge.path, ridge.rimPaint);
}
canvas.restore();
}
canvas.restore();
}
}
@@ -598,23 +608,92 @@ void paintAim(
/// Edge darkening without a full-screen radial gradient: four cheap bands.
/// A single radial fill over 2048x1152 tripled the jank rate on the test device.
void paintVignette(Canvas canvas) {
const w = kArtWorldWidth;
void paintVignette(Canvas canvas, {required double left, required double right}) {
final w = right - left;
const h = kArtWorldHeight;
const band = 300.0;
const edge = Color(0x66000000);
const clear = Color(0x00000000);
canvas.drawRect(
const Rect.fromLTWH(0, 0, w, band),
Rect.fromLTWH(left, 0, w, band),
Paint()
..shader = ui.Gradient.linear(
const Offset(0, 0), const Offset(0, band), [edge, clear]),
);
canvas.drawRect(
const Rect.fromLTWH(0, h - band, w, band),
Rect.fromLTWH(left, h - band, w, band),
Paint()
..shader = ui.Gradient.linear(
const Offset(0, h - band), const Offset(0, h), [clear, edge]),
);
}
/// Charge bar under the active tank: the value the player is setting right now.
void paintPowerBar(Canvas canvas, Offset tankPos, double power) {
const w = 104.0;
const h = 9.0;
final rect = Rect.fromLTWH(tankPos.dx - w / 2, tankPos.dy + 12, w, h);
canvas.drawRRect(
RRect.fromRectAndRadius(rect, const Radius.circular(4)),
Paint()..color = Colors.black.withValues(alpha: 0.55),
);
final fill = power.clamp(0.0, 1.0);
final color = fill < 0.5
? Palette.solarBase
: fill < 0.85
? const Color(0xFFFF8A3D)
: Palette.stateDanger;
canvas.drawRRect(
RRect.fromRectAndRadius(
Rect.fromLTWH(rect.left, rect.top, w * fill, h),
const Radius.circular(4),
),
Paint()..color = color,
);
// Quarter marks make a value readable without text on the canvas.
for (var i = 1; i < 4; i++) {
final x = rect.left + w * i / 4;
canvas.drawLine(
Offset(x, rect.top + 1),
Offset(x, rect.bottom - 1),
Paint()
..color = Colors.black.withValues(alpha: 0.35)
..strokeWidth = 1,
);
}
canvas.drawRRect(
RRect.fromRectAndRadius(rect, const Radius.circular(4)),
Paint()
..style = PaintingStyle.stroke
..strokeWidth = 1
..color = Colors.white.withValues(alpha: 0.28),
);
}
/// Rubber band from the barrel pivot to the finger while pulling back.
void paintPullBand(Canvas canvas, Offset pivot, Offset finger, double power) {
final band = Paint()
..color = Palette.solarLight.withValues(alpha: 0.45)
..strokeWidth = 3
..strokeCap = StrokeCap.round;
// Dashed, so it never competes with the trajectory hint.
final total = (finger - pivot).distance;
if (total < 4) return;
final dir = (finger - pivot) / total;
var travelled = 0.0;
while (travelled < total) {
final from = pivot + dir * travelled;
final to = pivot + dir * math.min(travelled + 12, total);
canvas.drawLine(from, to, band);
travelled += 22;
}
canvas.drawCircle(
finger,
14 + 10 * power,
Paint()
..style = PaintingStyle.stroke
..strokeWidth = 2
..color = Palette.solarLight.withValues(alpha: 0.5),
);
}