feat(pong): color the ball by speed and add contact sparks

Keep the headless pixel references aligned with the speed-dependent ball
palette and verify the first-contact color change alongside the local bounce.

Validation: make -C tooling verify passed in 20261127T035822Z-ec5d9266.
This commit is contained in:
2026-11-27 09:57:36 +00:00
parent 82ceb746ad
commit 802a13a6aa
2 changed files with 66 additions and 8 deletions
@@ -132,7 +132,7 @@ class HeadlessTaskIntegrationTest {
tasks.headless(root,task,TaskTools.HeadlessAction.SET_INPUT,null,Map.of("start",false,"a",true));
advance("pong-native-serve");
tasks.headless(root,task,TaskTools.HeadlessAction.CLEAR_INPUT,null,Map.of());
int previous=-1;boolean rightPaddleBounce=false;
int previous=-1;boolean rightPaddleBounce=false,contactColorObserved=false;
for(int i=0;i<80&&!rightPaddleBounce;i++) {
String request="pong-native-contact-"+i;
tasks.advance(root,task,request,1);
@@ -140,12 +140,17 @@ class HeadlessTaskIntegrationTest {
assertEquals(AutomationOutcome.Kind.SUCCEEDED,frame.runtimeResult().kind());
var image=new p.studio.app.evidence.PngEvidenceCodec().decode(frame.runtimeResult().capture().png());
byte[] rgba=image.rgba();int left=640,right=-1;
// Independent observation of the white ball/flash in the arena;
// HUD is above it, and neither paddle has this color.
// Independent colors from Pong's speed contract: pure white at 6,
// pale yellow at 7 after the first paddle contact. HUD, paddles
// and contact sparks use different colors.
for(int y=72;y<328;y++)for(int x=60;x<615;x++) {
int offset=(y*640+x)*4;
if(Byte.toUnsignedInt(rgba[offset])==236&&Byte.toUnsignedInt(rgba[offset+1])==244
&&Byte.toUnsignedInt(rgba[offset+2])==250) {left=Math.min(left,x);right=Math.max(right,x);}
int blue=Byte.toUnsignedInt(rgba[offset+2]);
if(Byte.toUnsignedInt(rgba[offset])==255&&Byte.toUnsignedInt(rgba[offset+1])==255
&&(blue==255||blue==127)&&Byte.toUnsignedInt(rgba[offset+3])==255) {
left=Math.min(left,x);right=Math.max(right,x);
if(blue==127)contactColorObserved=true;
}
}
assertTrue(right>=left,"Playing ball must remain observable before right contact");
int center=(left+right)/2;
@@ -155,6 +160,7 @@ class HeadlessTaskIntegrationTest {
previous=center;
}
assertTrue(rightPaddleBounce,"Actual guest ball must bounce off the paddle in the expanded arena");
assertTrue(contactColorObserved,"First paddle contact must change the ball from white to pale yellow");
}
}
@@ -211,7 +217,7 @@ class HeadlessTaskIntegrationTest {
String[] names={"menu-accent","serve-ball","moved-paddle"};
// Fixed expectations from the fixture's draw/input contract, never from a native capture.
Evidence.Rect[] regions={new Evidence.Rect(193,159,1,80),new Evidence.Rect(317,197,6,6),new Evidence.Rect(42,72,8,36)};
int[][] colors={{77,237,205},{236,244,250},{77,237,205}};
int[][] colors={{77,237,205},{255,255,255},{77,237,205}};
long totalPngBytes=0;
for(int i=0;i<names.length;i++) {
if(i==1)tasks.headless(root,task,TaskTools.HeadlessAction.SET_INPUT,null,Map.of("start",true));