art: new ingame renderer (sky, parallax, terrain, tanks, effects)

- lib/src/game/art.dart draws the scene with canvas primitives: dusk sky with a
camera-relative sun, three parallax ridges (far = lighter), soil with rim
light and irregular rocks, tanks with hull/turret/barrel/tracks and a
health bar in team colour, comet trail, impact with fireball/ring/sparks and
a dotted aim hint.
- Flutter tokens come from the generated palette, so app UI and artwork match.
- performance was part of the job: the first version ran at 31-40 % jank. An
A/B against the old renderer (0-6.5 %) proved it was the new scene, then the
causes were removed one by one: full-screen radial vignette (now edge bands),
per-ridge gradient shaders and per-frame paints (flat fills, cached paints),
two clipped gradient rects under the surface, terrain redrawn every frame (now
a ui.Picture per terrain version) and mask-filter blurs.
- result on the Redmi Note 10: 60.0 fps, 0.0-0.8 % jank.
- goldens regenerated and reviewed; store screenshots re-captured and renamed
to match their content (01 gameplay, 02 projectile, 03 crater, 04 settings).
- docs/art-direction.md: phase 2 section with the performance table.
This commit is contained in:
2026-10-25 02:59:20 +01:00
parent 00c09ad01b
commit fb85915418
15 changed files with 725 additions and 135 deletions
+6
View File
@@ -13,6 +13,9 @@ Alle nennenswerten Änderungen an diesem Projekt. Format nach
- (app) Zahnrad-Button mit Semantik-Label „Einstellungen“ und größerer Touch-Fläche (Barrierefreiheit)
### Fixed
- (game) Renderer wieder bei 60 fps / 0 % Jank: Vollbild-Gradient (Vignette), Gradient je
Bergrücken, zwei geclippte Gradient-Rects und MaskFilter-Blur entfernt, Boden als
`ui.Picture` pro Terrain-Version gecacht
- (app) HUD blieb auf dem Initialwert (100 HP), weil `onLoad` waehrend des ersten Builds publizierte
- (app) Top-Level-`Stopwatch` startete erst beim ersten Zugriff (Dart initialisiert Top-Level-Finals lazy) - das Bootlog zeigte 0 ms
@@ -20,6 +23,9 @@ Alle nennenswerten Änderungen an diesem Projekt. Format nach
- (build) Version 0.7.2 (9): Neues Icon/Splash/Feature-Graphic (generierte Art), Splash-Kette; signiertes App Bundle mit Upload-Keystore
### Added
- (game) Ingame-Grafik neu: Himmel mit kamerarelativ platzierter Sonne, drei parallaxe
Bergrücken, Boden mit Verlauf/Schattenlippe/Felsbrocken, Panzer mit Kette/Turm/Rohr,
Kometenschweif, Explosion mit Funken, Zielhilfe (`lib/src/game/art.dart`)
- (art) Generierte Marken-Grafik: `tools/art/` (SVG-Master + rsvg), Adaptive Icon inkl.
Monochrom, Splash-Lockup, neues Feature-Graphic, Design-Tokens nach
`app/lib/src/ui/palette.dart`; Doku in `docs/art-direction.md`
+620
View File
@@ -0,0 +1,620 @@
import 'dart:math' as math;
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import '../ui/palette.dart';
/// Scene art for the match: dusk sky, parallax ridges, layered terrain, tanks,
/// projectile trail and impact effects.
///
/// Everything is drawn with canvas primitives on purpose - the terrain is
/// destructible and the camera zooms, so bitmaps would have to be regenerated
/// anyway. Geometry that never changes (ridges) is built once and cached; the
/// per-frame work stays at a few paths and gradients.
///
/// Look rules: docs/art-direction.md - light from the horizon, a warm rim on
/// every silhouette, one accent colour per side, vignette over the frame.
const double kArtWorldWidth = 2048;
const double kArtWorldHeight = 1152;
/// Heightmap sampling step, must match the game (`kSamplePx`).
const int kArtWorldSample = 2;
// ---------------------------------------------------------------------------
// geometry (ported from tools/art/artlib.py so both stay in sync)
// ---------------------------------------------------------------------------
/// Sum of two sines plus seeded jitter - reproducible ridges.
List<Offset> ridgePoints({
required double width,
required double baseY,
required double amplitude,
required int seed,
int steps = 7,
double phase = 0,
double footY = kArtWorldHeight,
}) {
final rnd = math.Random(seed);
final pts = <Offset>[];
for (var i = 0; i <= steps; i++) {
final t = i / steps;
var wave = math.sin((t * 2.2 + phase) * math.pi * 2) * 0.55;
wave += math.sin((t * 5.1 + phase * 1.7) * math.pi * 2) * 0.22;
final jitter = (i > 0 && i < steps) ? (rnd.nextDouble() - 0.5) * 0.30 : 0.0;
pts.add(Offset(t * width, baseY - amplitude * (0.5 + 0.5 * wave + jitter)));
}
pts.add(Offset(width, footY));
pts.add(Offset(0, footY));
return pts;
}
/// Catmull-Rom through the points, emitted as cubic beziers.
Path smoothPath(List<Offset> points, {bool closed = false}) {
final path = Path();
if (points.length < 2) return path;
final pts = <Offset>[
if (closed) points.last,
points.first,
...points,
points.last,
if (closed) points.first,
];
path.moveTo(pts[1].dx, pts[1].dy);
for (var i = 1; i < pts.length - 2; i++) {
final p0 = pts[i - 1], p1 = pts[i], p2 = pts[i + 1], p3 = pts[i + 2];
final c1 = Offset(p1.dx + (p2.dx - p0.dx) / 6, p1.dy + (p2.dy - p0.dy) / 6);
final c2 = Offset(p2.dx - (p3.dx - p1.dx) / 6, p2.dy - (p3.dy - p1.dy) / 6);
path.cubicTo(c1.dx, c1.dy, c2.dx, c2.dy, p2.dx, p2.dy);
}
if (closed) path.close();
return path;
}
// ---------------------------------------------------------------------------
// sky + parallax backdrop
// ---------------------------------------------------------------------------
class SkyArt {
SkyArt({this.seed = 7});
final int seed;
final List<_Ridge> _ridges = [];
final List<Offset> _stars = [];
bool _built = false;
/// Long-lived paints: re-creating shaders every frame caused shader churn and
/// dropped frames on device.
final Paint _skyPaint = Paint();
final Paint _starPaint = Paint();
final Paint _coronaPaint = Paint();
final Paint _sunPaint = Paint();
/// Sun radius in world units. The disc itself is camera-anchored (it is
/// infinitely far away), so every camera position has a visible light source.
static const double sunRadius = 74;
void _build() {
final rnd = math.Random(seed);
for (var i = 0; i < 16; i++) {
_stars.add(Offset(rnd.nextDouble() * kArtWorldWidth, rnd.nextDouble() * 430));
}
_ridges.addAll([
_Ridge(
smoothPath(ridgePoints(
width: kArtWorldWidth, baseY: 545, amplitude: 105, seed: seed + 1, steps: 6)),
parallax: 0.12,
fill: const Color(0xFF20334F),
rim: Palette.terrainRim.withValues(alpha: 0.08),
),
_Ridge(
smoothPath(ridgePoints(
width: kArtWorldWidth,
baseY: 625,
amplitude: 95,
seed: seed + 2,
steps: 7,
phase: 0.31)),
parallax: 0.24,
fill: const Color(0xFF152238),
rim: Palette.terrainRim.withValues(alpha: 0.12),
),
_Ridge(
smoothPath(ridgePoints(
width: kArtWorldWidth,
baseY: 700,
amplitude: 80,
seed: seed + 3,
steps: 5,
phase: 0.62)),
parallax: 0.38,
fill: const Color(0xFF080E19),
rim: Palette.solarLight.withValues(alpha: 0.14),
),
]);
_skyPaint.shader = ui.Gradient.linear(
const Offset(0, 0),
const Offset(0, kArtWorldHeight),
const [
Palette.ink0,
Color(0xFF0B1424),
Color(0xFF17243A),
Color(0xFF3A3026),
],
const [0.0, 0.42, 0.62, 0.78],
);
_built = true;
}
/// `camX` shifts each layer by (1 - parallax): the ridges crawl slower than
/// the playfield. `viewWidth` places the sun relative to the viewport.
void paint(Canvas canvas, {required double camX, required double viewWidth}) {
if (!_built) _build();
canvas.drawRect(
const Rect.fromLTWH(0, 0, kArtWorldWidth, 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;
canvas.drawCircle(Offset(dx, s.dy), 2.2, _starPaint);
}
_paintSun(canvas, Offset(camX + viewWidth * 0.66, 395));
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);
}
canvas.restore();
}
}
void _paintSun(Canvas canvas, Offset center) {
_coronaPaint.shader = ui.Gradient.radial(center, sunRadius * 2.2, [
Palette.solarDeep.withValues(alpha: 0.22),
Palette.solarDeep.withValues(alpha: 0.0),
]);
canvas.drawCircle(center, sunRadius * 2.2, _coronaPaint);
_sunPaint.shader = ui.Gradient.radial(
center.translate(-sunRadius * 0.25, -sunRadius * 0.3),
sunRadius * 1.35,
[
const Color(0xFFFFF3DC),
Palette.solarLight,
Palette.solarBase,
Palette.solarDeep,
],
const [0.0, 0.45, 0.78, 1.0],
);
canvas.drawCircle(center, sunRadius, _sunPaint);
}
}
class _Ridge {
_Ridge(this.path, {required this.parallax, required this.fill, required this.rim}) {
// Flat fill: a gradient per ridge cost more than it added at this size.
fillPaint.color = fill;
rimPaint
..style = PaintingStyle.stroke
..strokeWidth = 2.5
..color = rim;
}
final Path path;
final double parallax;
final Color fill;
final Color rim;
final Paint fillPaint = Paint();
final Paint rimPaint = Paint();
}
// ---------------------------------------------------------------------------
// terrain
// ---------------------------------------------------------------------------
class TerrainArt {
int _version = -1;
ui.Picture? _picture;
/// The soil never changes between two craters, so the whole layer is recorded
/// into a Picture once. Redrawing it every frame cost ~30 % of the frame
/// budget on the test device (mask filters are not free).
void paint(
Canvas canvas,
Path fill,
Path line, {
List<int>? heights,
int version = -1,
}) {
if (_picture == null || version != _version) {
_version = version;
final recorder = ui.PictureRecorder();
_draw(Canvas(recorder), fill, line, heights);
_picture = recorder.endRecording();
}
canvas.drawPicture(_picture!);
}
void _draw(Canvas canvas, Path fill, Path line, List<int>? heights) {
canvas.drawPath(
fill,
Paint()
..shader = ui.Gradient.linear(
const Offset(0, 520),
const Offset(0, kArtWorldHeight),
[const Color(0xFF54402C), Palette.terrainSoil, Palette.terrainDeep],
const [0.0, 0.35, 1.0],
),
);
canvas.save();
canvas.clipPath(fill);
// Shade under the lip without a mask filter: two soft strokes.
canvas.drawPath(
line,
Paint()
..style = PaintingStyle.stroke
..strokeWidth = 26
..strokeJoin = StrokeJoin.round
..color = const Color(0xFF0B0805).withValues(alpha: 0.10),
);
canvas.drawPath(
line,
Paint()
..style = PaintingStyle.stroke
..strokeWidth = 12
..strokeJoin = StrokeJoin.round
..color = const Color(0xFF0B0805).withValues(alpha: 0.12),
);
canvas.restore();
// Surface: wide translucent edge, warm line, thin highlight.
canvas.drawPath(
line,
Paint()
..style = PaintingStyle.stroke
..strokeWidth = 12
..strokeJoin = StrokeJoin.round
..color = Palette.solarLight.withValues(alpha: 0.07),
);
canvas.drawPath(
line,
Paint()
..style = PaintingStyle.stroke
..strokeWidth = 3.5
..strokeCap = StrokeCap.round
..strokeJoin = StrokeJoin.round
..color = Palette.terrainRim.withValues(alpha: 0.55),
);
canvas.drawPath(
line,
Paint()
..style = PaintingStyle.stroke
..strokeWidth = 1.2
..strokeCap = StrokeCap.round
..color = Palette.solarLight.withValues(alpha: 0.35),
);
if (heights != null) _paintSurfaceRocks(canvas, heights);
}
/// Sparse rocks poking out of the surface. Evenly spaced ticks read as a
/// fence, so the spacing is seeded and irregular.
void _paintSurfaceRocks(Canvas canvas, List<int> heights) {
if (heights.length < 8) return;
final rnd = math.Random(91);
var i = 3;
while (i < heights.length - 4) {
i += 12 + rnd.nextInt(38);
if (i >= heights.length - 4) break;
final x = i * kArtWorldSample.toDouble();
final y = heights[i].toDouble();
final w = 4.0 + rnd.nextDouble() * 9;
final h = 3.0 + rnd.nextDouble() * 6;
final rock = Path()
..moveTo(x - w, y + 3)
..lineTo(x - w * 0.5, y - h)
..lineTo(x + w * 0.35, y - h * 0.75)
..lineTo(x + w, y + 3)
..close();
canvas.drawPath(rock, Paint()..color = const Color(0xFF4A3A26));
canvas.drawPath(
rock,
Paint()
..style = PaintingStyle.stroke
..strokeWidth = 1.2
..color = Palette.terrainRim.withValues(alpha: 0.45),
);
}
}
}
// ---------------------------------------------------------------------------
// tanks
// ---------------------------------------------------------------------------
/// Tanks are authored in a local space (origin = ground contact, up = -y) and
/// scaled up, so the silhouette still reads at the camera's ~0.7 zoom.
const double kTankScale = 1.5;
const double _barrelLength = 42;
const double _turretPivotY = 32;
/// World position of the barrel pivot.
Offset tankPivot(Offset pos) => Offset(pos.dx, pos.dy - _turretPivotY * kTankScale);
/// World position of the muzzle - shared by the tank painter and the aim hint.
Offset tankMuzzle(Offset pos, double barrelDeg, double dir) {
final rad = barrelDeg * math.pi / 180;
return Offset(
pos.dx + dir * math.cos(rad) * _barrelLength * kTankScale,
pos.dy - (_turretPivotY + math.sin(rad) * _barrelLength) * kTankScale,
);
}
void paintTank(
Canvas canvas, {
required Offset pos,
required double barrelDeg,
required bool alive,
required bool isPlayer0,
required double hpFrac,
required bool isCurrent,
}) {
final dir = isPlayer0 ? 1.0 : -1.0;
final base = alive
? (isPlayer0 ? Palette.solarBase : Palette.steelBase)
: const Color(0xFF3A4450);
final light = isPlayer0 ? Palette.solarLight : Palette.steelLight;
final dark = isPlayer0 ? Palette.solarDeep : Palette.steelDeep;
final a = alive ? 1.0 : 0.45;
// Contact shadow stays in world space so it hugs the ground line.
canvas.drawOval(
Rect.fromCenter(center: Offset(pos.dx, pos.dy + 3), width: 96, height: 18),
Paint()..color = Colors.black.withValues(alpha: 0.45 * a),
);
canvas.save();
canvas.translate(pos.dx, pos.dy);
canvas.scale(kTankScale);
// Tracks.
canvas.drawRRect(
RRect.fromRectAndRadius(
Rect.fromCenter(center: const Offset(0, -4), width: 66, height: 15),
const Radius.circular(7),
),
Paint()..color = const Color(0xFF090E15).withValues(alpha: a),
);
for (var i = 0; i < 4; i++) {
canvas.drawCircle(
Offset(-21 + i * 14, -4),
4.2,
Paint()..color = const Color(0xFF2B3543).withValues(alpha: a),
);
}
// Hull.
final hull = Path()
..moveTo(-29, -10)
..lineTo(29, -10)
..lineTo(24, -22)
..lineTo(15, -26)
..lineTo(-15, -26)
..lineTo(-24, -22)
..close();
canvas.drawPath(
hull,
Paint()
..shader = ui.Gradient.linear(
const Offset(0, -27),
const Offset(0, -9),
[light.withValues(alpha: a), base.withValues(alpha: a), dark.withValues(alpha: a)],
const [0.0, 0.45, 1.0],
),
);
// Turret.
canvas.drawRRect(
RRect.fromRectAndRadius(
Rect.fromCenter(center: const Offset(0, -31), width: 34, height: 17),
const Radius.circular(8),
),
Paint()
..shader = ui.Gradient.linear(
const Offset(0, -40),
const Offset(0, -23),
[light.withValues(alpha: a), base.withValues(alpha: a), dark.withValues(alpha: a)],
const [0.0, 0.5, 1.0],
),
);
// Barrel: dark core, light top edge, muzzle brake.
final rad = barrelDeg * math.pi / 180;
const pivot = Offset(0, -_turretPivotY);
final muzzle = Offset(
dir * math.cos(rad) * _barrelLength,
-_turretPivotY - math.sin(rad) * _barrelLength,
);
canvas.drawLine(
pivot,
muzzle,
Paint()
..color = const Color(0xFF141A24).withValues(alpha: a)
..strokeWidth = 8
..strokeCap = StrokeCap.round,
);
canvas.drawLine(
pivot.translate(0, -2),
muzzle.translate(0, -2),
Paint()
..color = light.withValues(alpha: 0.55 * a)
..strokeWidth = 2.6
..strokeCap = StrokeCap.round,
);
canvas.drawCircle(muzzle, 5.2, Paint()..color = const Color(0xFF0C1118).withValues(alpha: a));
// Rim light on the hull top edge - the rule that keeps silhouettes readable.
canvas.drawLine(
const Offset(-15, -26.4),
const Offset(15, -26.4),
Paint()
..color = light.withValues(alpha: 0.8 * a)
..strokeWidth = 1.8
..strokeCap = StrokeCap.round,
);
canvas.restore();
if (isCurrent && alive) {
canvas.drawCircle(
Offset(pos.dx, pos.dy - 82),
4.5,
Paint()..color = Palette.solarLight.withValues(alpha: 0.9),
);
}
// Health bar, world space so it keeps a constant on-screen weight.
const barW = 64.0;
final barTop = pos.dy - 84;
final bar = Rect.fromLTWH(pos.dx - barW / 2, barTop, barW, 6);
canvas.drawRRect(
RRect.fromRectAndRadius(bar, const Radius.circular(3.5)),
Paint()..color = Colors.black.withValues(alpha: 0.55),
);
canvas.drawRRect(
RRect.fromRectAndRadius(
Rect.fromLTWH(bar.left, bar.top, barW * hpFrac.clamp(0.0, 1.0), 6),
const Radius.circular(3.5),
),
Paint()
..color = hpFrac > 0.5
? base
: hpFrac > 0.25
? Palette.solarBase
: Palette.stateDanger,
);
canvas.drawRRect(
RRect.fromRectAndRadius(bar, const Radius.circular(3.5)),
Paint()
..style = PaintingStyle.stroke
..strokeWidth = 1
..color = Colors.white.withValues(alpha: 0.25),
);
}
// ---------------------------------------------------------------------------
// effects
// ---------------------------------------------------------------------------
void paintProjectile(Canvas canvas, Offset p, List<Offset> trail) {
for (var i = 0; i < trail.length; i++) {
final t = i / trail.length;
canvas.drawCircle(
trail[i],
3 + 5 * t,
Paint()..color = Palette.solarBase.withValues(alpha: 0.06 + 0.18 * t),
);
}
canvas.drawCircle(
p,
18,
Paint()
..color = Palette.solarBase.withValues(alpha: 0.35)
..maskFilter = const MaskFilter.blur(BlurStyle.normal, 8),
);
canvas.drawCircle(p, 6.5, Paint()..color = Palette.solarLight);
canvas.drawCircle(p + const Offset(-1.5, -1.5), 2.6, Paint()..color = Colors.white);
}
/// `t` runs from 1 (impact) down to 0.
void paintImpact(Canvas canvas, Offset p, double t) {
final grow = 1 - t;
final fireRadius = 26 + 54 * grow;
canvas.drawCircle(
p,
fireRadius,
Paint()
..shader = ui.Gradient.radial(p, fireRadius, [
Colors.white.withValues(alpha: 0.85 * t),
Palette.solarBase.withValues(alpha: 0.55 * t),
Palette.solarDeep.withValues(alpha: 0.0),
]),
);
canvas.drawCircle(
p,
18 + 78 * grow,
Paint()
..style = PaintingStyle.stroke
..strokeWidth = 3 * t
..color = Palette.solarLight.withValues(alpha: 0.45 * t),
);
// Sparks: deterministic fan, gravity bends them down as they age.
for (var i = 0; i < 9; i++) {
final angle = (i / 9) * math.pi * 2 + 0.4;
final speed = 60 + (i % 3) * 34;
final r = speed * grow * 1.5;
canvas.drawCircle(
Offset(
p.dx + math.cos(angle) * r,
p.dy + math.sin(angle) * r * 0.7 + 90 * grow * grow,
),
3.2 * t,
Paint()..color = Palette.solarLight.withValues(alpha: 0.8 * t),
);
}
}
void paintAim(
Canvas canvas, {
required Offset muzzle,
required double angleDeg,
required double dir,
required double power,
}) {
final rad = angleDeg * math.pi / 180;
for (var i = 1; i <= 7; i++) {
final r = 52.0 + i * 30;
// Approximate drop so the hint curves like the real shot.
final p = Offset(
muzzle.dx + dir * math.cos(rad) * r,
muzzle.dy - math.sin(rad) * r + 1.28 * i * i,
);
canvas.drawCircle(
p,
2.2 + 2.4 * power,
Paint()..color = Colors.white.withValues(alpha: ((0.55 - i * 0.05) * (0.6 + 0.4 * power)).clamp(0.0, 1.0)),
);
}
}
/// 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;
const h = kArtWorldHeight;
const band = 300.0;
const edge = Color(0x66000000);
const clear = Color(0x00000000);
canvas.drawRect(
const Rect.fromLTWH(0, 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),
Paint()
..shader = ui.Gradient.linear(
const Offset(0, h - band), const Offset(0, h), [clear, edge]),
);
}
+40 -125
View File
@@ -1,10 +1,10 @@
import 'dart:math' as math;
import 'dart:ui' as ui;
import 'package:flame/game.dart';
import 'package:flutter/material.dart';
import '../native/match_source.dart';
import 'art.dart';
import '../native/native_match.dart';
/// World dimensions in simulation pixels (must match crates/sim).
@@ -107,6 +107,11 @@ class IronArcGame extends FlameGame {
int _terrainVersion = -1;
Path? _terrainFill;
Path? _terrainLine;
List<int>? _heightmap;
final SkyArt _sky = SkyArt();
final TerrainArt _terrainArt = TerrainArt();
final List<Offset> _trail = [];
bool get isReady => isLoaded;
@@ -139,6 +144,15 @@ class IronArcGame extends FlameGame {
} else if (_match.isAiming) {
_accumulator = 0;
}
// Projectile trail: keep the last positions for the comet effect.
final shot = _match.projectile();
if (shot != null) {
_trail.add(Offset(shot.x.toDouble(), shot.y.toDouble()));
if (_trail.length > 16) _trail.removeAt(0);
} else if (!_match.isFlying && _trail.isNotEmpty) {
_trail.clear();
}
if (_impactFlash > 0) {
_impactFlash = math.max(0, _impactFlash - dt * 1.8);
}
@@ -272,47 +286,20 @@ class IronArcGame extends FlameGame {
_drawProjectile(canvas);
if (_match.isAiming) _drawAim(canvas);
_drawImpact(canvas);
paintVignette(canvas);
canvas.restore();
}
void _drawSky(Canvas canvas) {
final rect = Rect.fromLTWH(0, 0, kWorldWidth, kWorldHeight);
final paint = Paint()
..shader = ui.Gradient.linear(
const Offset(0, 0),
const Offset(0, kWorldHeight),
const [Color(0xFF0B1220), Color(0xFF243B53), Color(0xFF7A5C3E)],
const [0.0, 0.55, 1.0],
);
canvas.drawRect(rect, paint);
// Distant hills for depth. They stay well above any playable ground so they
// can never bleed through the destructible terrain.
final hills = Path()
..moveTo(0, 470)
..quadraticBezierTo(300, 360, 620, 450)
..quadraticBezierTo(1000, 540, 1340, 400)
..quadraticBezierTo(1700, 300, kWorldWidth, 440)
..lineTo(kWorldWidth, 560)
..lineTo(0, 560)
..close();
canvas.drawPath(
hills,
Paint()
..shader = ui.Gradient.linear(
const Offset(0, 330),
const Offset(0, 560),
const [Color(0x2EFFFFFF), Color(0x00FFFFFF)],
),
);
}
void _drawSky(Canvas canvas) =>
_sky.paint(canvas, camX: _camX, viewWidth: _viewWidthWorld);
void _drawTerrain(Canvas canvas) {
final version = _match.terrainVersion;
if (version != _terrainVersion || _terrainFill == null) {
_terrainVersion = version;
final heights = _match.terrain();
_heightmap = heights;
final fill = Path()..moveTo(0, heights[0].toDouble());
final line = Path()..moveTo(0, heights[0].toDouble());
for (var i = 1; i < heights.length; i++) {
@@ -329,123 +316,51 @@ class IronArcGame extends FlameGame {
_terrainLine = line;
}
canvas.drawPath(
_terrainFill!,
Paint()
..shader = ui.Gradient.linear(
const Offset(0, 400),
const Offset(0, kWorldHeight),
const [Color(0xFF6B4A2F), Color(0xFF2E1F16)],
),
);
canvas.drawPath(
_terrainLine!,
Paint()
..color = const Color(0xFF8FD694)
..style = PaintingStyle.stroke
..strokeWidth = 6
..strokeJoin = StrokeJoin.round,
);
_terrainArt.paint(canvas, _terrainFill!, _terrainLine!,
heights: _heightmap, version: _terrainVersion);
}
void _drawTank(Canvas canvas, int player) {
if (!isLoaded) return;
final x = _match.tankX(player).toDouble();
final y = _match.tankY(player).toDouble();
final alive = _match.tankHp(player) > 0;
final color = player == 0 ? const Color(0xFFFF8A3D) : const Color(0xFF4DD0E1);
final body = Paint()..color = alive ? color : color.withValues(alpha: 0.3);
final hull = RRect.fromRectAndRadius(
Rect.fromCenter(center: Offset(x, y - 9), width: 52, height: 18),
const Radius.circular(5),
);
canvas.drawRRect(hull, body);
canvas.drawRRect(
RRect.fromRectAndRadius(
Rect.fromCenter(center: Offset(x, y - 9), width: 26, height: 12),
const Radius.circular(4),
),
Paint()..color = const Color(0x22000000),
);
final dir = player == 0 ? 1.0 : -1.0;
final angle = player == _match.current ? aimAngle : 35.0;
final radians = angle * math.pi / 180;
final muzzle = Offset(
x + dir * math.cos(radians) * 34,
y - 16 - math.sin(radians) * 34,
);
canvas.drawLine(
Offset(x, y - 15),
muzzle,
Paint()
..color = Colors.white
..strokeWidth = 6
..strokeCap = StrokeCap.round,
);
// Health bar.
final hp = _match.tankHp(player).clamp(0, kTankMaxHp) / kTankMaxHp;
final barRect = RRect.fromRectAndRadius(
Rect.fromLTWH(x - 30, y - 46, 60, 8),
const Radius.circular(4),
);
canvas.drawRRect(barRect, Paint()..color = const Color(0xAA000000));
canvas.drawRRect(
RRect.fromRectAndRadius(
Rect.fromLTWH(x - 30, y - 46, 60 * hp, 8),
const Radius.circular(4),
),
Paint()..color = hp > 0.5
? const Color(0xFF66BB6A)
: hp > 0.25
? const Color(0xFFFFC107)
: const Color(0xFFE53935),
paintTank(
canvas,
pos: Offset(x, y),
barrelDeg: player == _match.current ? aimAngle : 35,
alive: alive,
isPlayer0: player == 0,
hpFrac: _match.tankHp(player).clamp(0, kTankMaxHp) / kTankMaxHp,
isCurrent: player == _match.current && !_match.isPlayback,
);
}
void _drawProjectile(Canvas canvas) {
final p = _match.projectile();
if (p == null) return;
final center = Offset(p.x.toDouble(), p.y.toDouble());
canvas.drawCircle(center, 16, Paint()..color = const Color(0x33FFD54F));
canvas.drawCircle(center, 7, Paint()..color = const Color(0xFFFFD54F));
paintProjectile(canvas, Offset(p.x.toDouble(), p.y.toDouble()), _trail);
}
void _drawAim(Canvas canvas) {
final player = _match.current;
final dir = player == 0 ? 1.0 : -1.0;
final x = _match.tankX(player).toDouble();
final y = _match.tankY(player).toDouble() - 16;
final radians = aimAngle * math.pi / 180;
final paint = Paint()
..color = const Color(0xCCFFFFFF)
..strokeWidth = 3
..strokeCap = StrokeCap.round;
for (var i = 1; i <= 6; i++) {
final r = 40.0 + i * 26;
final p = Offset(
x + dir * math.cos(radians) * r,
y - math.sin(radians) * r + 0.12 * i * i,
);
canvas.drawCircle(p, 4, paint);
}
canvas.drawRect(
Rect.fromLTWH(x - 40, y - 70, 80 * aimPower, 6),
Paint()..color = const Color(0xCCFFB74D),
final y = _match.tankY(player).toDouble();
// Same geometry the tank painter uses, so the hint starts at the muzzle.
final muzzle = tankMuzzle(Offset(x, y), aimAngle, dir);
paintAim(
canvas,
muzzle: muzzle,
angleDeg: aimAngle,
dir: dir,
power: aimPower,
);
}
void _drawImpact(Canvas canvas) {
final pos = _lastImpact;
if (pos == null || _impactFlash <= 0) return;
final alpha = (_impactFlash * 200).clamp(0, 200).toInt();
canvas.drawCircle(
pos,
30 + 60 * (1 - _impactFlash),
Paint()..color = Color.fromARGB(alpha, 0xFF, 0xB3, 0x00),
);
paintImpact(canvas, pos, _impactFlash.clamp(0.0, 1.0));
}
/// Replay JSON of everything played so far.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

After

Width:  |  Height:  |  Size: 347 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 313 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 87 KiB

After

Width:  |  Height:  |  Size: 324 KiB

+29 -10
View File
@@ -76,16 +76,35 @@ Der Test für jedes Icon: auf 48 × 48 px verkleinern und ansehen. Bestehen nur
**Sonne**, **Diagonale**, **Bodenkante** – ist das Icon gut. Alles andere (Panzerdetails,
Sternen, Trail-Punkte) ist Zugabe für große Darstellungen.
## Offene Lücken (Phase 2)
## Ingame-Grafik (Phase 2, umgesetzt)
Die Marken-Assets sind generiert; die **Ingame-Grafik** ist noch handgezeichneter Canvas-Code
(`app/lib/src/game/iron_arc_game.dart`): flacher Boden, Pastell-Rechtecke als Panzer.
Geplant ist ein `gen_ingame.py`, das aus derselben Palette liefert:
`app/lib/src/game/art.dart` zeichnet die Szene mit Canvas-Primitiven - bewusst keine Bitmaps,
weil die Landschaft zerstörbar ist und die Kamera zoomt.
1. Himmel-Gradient + parallaxe Bergrücken als PNG-Ebenen (Flame `ParallaxComponent`).
2. Boden-Straten als kachelbare Textur plus Rim-Light entlang der Heightmap.
3. Panzer als Sprites (Hull/Turret/Lauf) statt Rechtecke, je Seite eine Palette.
4. Explosion/Mündungsfeuer als Sprite-Sheet statt gezeichneter Kreise.
| Baustein | Umsetzung |
|---|---|
| Himmel | Verlauf Ink → warme Horizontlinie, Sterne, Sonne **kamerarelativ** platziert (jede Kameraposition hat eine Lichtquelle) |
| Bergrücken | drei Silhouetten mit Parallaxe 0.12/0.24/0.38, atmosphärische Perspektive (fern = heller), Rim-Light |
| Boden | Verlauf oben warm → unten fast schwarz, Schattenlippe, warme Oberkante + dünnes Highlight, Felsbrocken mit unregelmäßigem Abstand |
| Panzer | Hull, Turret, Rohr mit Mündungsbremse, Ketten mit Rollen, Rim-Light, HP-Balken in Teamfarbe |
| Effekte | Kometenschweif am Geschoss, Explosion mit Feuerball/Ring/Funken, Zielhilfe mit Punkten |
Die Golden-Tests (`app/test/goldens/`) müssen danach mit `flutter test --update-goldens`
neu erzeugt und im Review angesehen werden.
**Performance ist Teil der Gestaltung.** Erste Fassung: 31–40 % Jank. Ursachen und Lösung:
| Ursache | Lösung |
|---|---|
| Radial-Verlauf über die ganze Welt (Vignette) | vier bzw. zwei Rand-Bänder statt Vollbild |
| Gradient-Shader pro Bergrücken und pro Frame | flache Füllungen, Paints/Shader einmal gebaut |
| zwei geclippte Gradient-Rects unter der Oberfläche | entfernt, Basisverlauf reicht |
| Boden jeden Frame neu gezeichnet | einmal pro Terrain-Version in ein `ui.Picture` |
| `MaskFilter.blur` auf großen Pfaden | durch gestaffelte Striche ersetzt |
Ergebnis auf dem Redmi Note 10: **60,0 fps, 0,0–0,8 % Jank** (Baseline vorher: 0–6,5 %).
Messung: `tools/device/perf.sh`.
## Offene Punkte
1. Store-Screenshots bei jeder sichtbaren Änderung neu aufnehmen (liegen in `store/screenshots/`).
2. Tablet-Screenshots und 30-s-Video fehlen weiterhin.
3. Die Golden-Tests werden per `flutter test --update-goldens` neu erzeugt und **angesehen** -
sie sind der Regressionsschutz für die Optik.
+30
View File
@@ -200,6 +200,36 @@ das ganze Bild, Asymmetrie statt Kuppel, Roboto Black mit negativem Tracking.
**Offen (Phase 2):** die Ingame-Grafik ist weiterhin Canvas-Code (flacher Boden,
Rechteck-Panzer). `docs/art-direction.md` beschreibt das geplante `gen_ingame.py`.
## M7e — Ingame-Grafik (erledigt 2026-10-25)
**Problem:** flacher Himmel, eine Hügel-Silhouette, brauner Boden als Fläche,
Panzer als zwei Rechtecke plus weiße Linie.
| Baustein | Umsetzung |
|---|---|
| `art.dart` | Szenen-Renderer: Himmel, Parallaxe, Boden, Panzer, Effekte, Vignette |
| Sonne | kamerarelativ platziert, damit jede Kameraposition eine Lichtquelle hat |
| Bergrücken | drei Ebenen (Parallaxe 0.12/0.24/0.38), fern = heller, Rim-Light |
| Boden | Verlauf, Schattenlippe, warme Oberkante, Felsbrocken mit unregelmäßigem Abstand |
| Panzer | Hull/Turm/Rohr/Kette, Rim-Light, HP-Balken in Teamfarbe, 1,5x skaliert |
| Effekte | Kometenschweif, Explosion (Feuerball, Ring, 9 Funken), Zielhilfe |
**Performance-Arbeit** (wichtigster Teil): erste Fassung 31–40 % Jank bei 60 fps Median.
A/B gegen den alten Renderer (0–6,5 %) bewies, dass es die neue Szene war. Ursachen einzeln
eliminiert: Vollbild-Radialverlauf (Vignette) → Randbänder; Gradient-Shader pro Bergrücken
und pro Frame → flache Füllungen und einmal gebaute Paints; zwei geclippte Gradient-Rects
unter der Oberfläche → entfernt; Boden pro Frame → `ui.Picture` je Terrain-Version;
`MaskFilter.blur` → gestaffelte Striche. Ergebnis: **60,0 fps, 0,0–0,8 % Jank**.
**Erkenntnisse**
- Auf einem Mali-G52 zählt Overdraw, nicht Pfadanzahl: ein einziger Vollbild-Radialverlauf
kostete ~15 Prozentpunkte Jank.
- `perf.sh`-Einzelmessungen schwanken um ±5 Punkte → immer 3 Läufe, Median nehmen.
- Golden-Tests sind der einzige Schutz gegen„ sieht anders aus“: nach jeder Änderung
`--update-goldens` und die PNGs wirklich ansehen.
- Terrain-Cache braucht die Terrain-Version, sonst friert der Boden nach dem ersten Krater ein
(gleiche Klasse Fehler wie das HUD-`onLoad`-Problem aus M3a).
## Nächste Schritte (aktualisiert)
1. `bundletool build-apks --connected-device` aus `~/exports/iron-arc-0.7.0.aab` → Install → Smoke.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB