feat(studio): adopt the 640x360 native graphics contract
Update the new JavaFX UI's frame sizing and pointer cancellation while preserving zoom and scrolling. Adapt Pong, Fragments and the camera scene to the native viewport, and update exact visual references and IPC fixtures. Build and run all three examples against qualified installed runtimes. Observe an actual Pong paddle collision and verify native frame captures. Retain the qualification evidence generated for the tested native bundles. Validated by the complete verify and desktop integration gates, including the existing 30-second Play measurement and 20 Play/Stop cycles. Work: WRK-0016 / DEC-0001 / PLN-0001 Commit and push explicitly authorized by the user after completion.
This commit is contained in:
@@ -106,7 +106,7 @@ FX polls the latest complete frame on a pulse, copies it to an FX-owned
|
||||
per frame. Logs and frontend projections MUST remain bounded.
|
||||
|
||||
Zoom choices MUST be x1, x2 and x4 with nearest-neighbor presentation. At x1 a
|
||||
480×270 game occupies 480×270 logical pixels, respecting OS scale; it does not mean
|
||||
640×360 game occupies 640×360 logical pixels, respecting OS scale; it does not mean
|
||||
one physical display pixel. Oversized images MUST retain zoom and scroll. The UI
|
||||
MUST NOT silently fit the image or change zoom.
|
||||
|
||||
@@ -117,6 +117,14 @@ shortcuts. Pad keys are arrows, A/D/W/S for A/B/X/Y, Q/E for L/R, Z for Start an
|
||||
Shift for Select. Focus loss and lifecycle changes MUST neutralize held input;
|
||||
native epochs reject input from older execution phases.
|
||||
|
||||
The only native machine output is 640×360 RGBA8888 at 60 Hz. The new JavaFX 2
|
||||
viewport obtains dimensions from complete runtime publications; it MUST NOT keep
|
||||
an independent fallback resolution. Leaving the image cancels an active contact;
|
||||
dragging back while still held MUST NOT recapture without a new press inside.
|
||||
Zoom and scroll continue to operate in JavaFX logical coordinates, with scene
|
||||
transforms accounting for host display scaling. These frontend changes apply to
|
||||
the new UI only; the old UI is outside the current graphics migration scope.
|
||||
|
||||
## Verification and limits
|
||||
|
||||
The product baseline is Java 25, retaining JavaFX 23.0.2. The bundled image uses an
|
||||
|
||||
@@ -99,6 +99,138 @@
|
||||
"prometeu-headless": "a1662aaae81794a0f1eedfdbe386a52601ca133cf1634845d82c882fa130c942",
|
||||
"prometeu-runtime": "918ff7a8eccf3e7263cbfb265a27fd2d015a317d5bb0dcb25a801a04a7c969f6"
|
||||
}
|
||||
},
|
||||
{
|
||||
"profile": {
|
||||
"contractVersion": 1,
|
||||
"profileId": "native-bundle-43069a2a4e9c94dfaae0c6a681461f2f5810ff6dc38be45da22987febfe5c371",
|
||||
"runtimeVersion": "0.1.0",
|
||||
"executableSha256": "ff1f910a0fa2f88828f03985767bb55c9364ec3ece25e46cf5965cd3faf1ceff",
|
||||
"limits": {
|
||||
"glyph": 16,
|
||||
"scene": 16
|
||||
},
|
||||
"evidence": [
|
||||
{
|
||||
"bankType": "glyph",
|
||||
"acceptedPreloads": 16,
|
||||
"rejectedPreloads": 17,
|
||||
"evidencePath": "asset-capacity/evidence/native-bundle-43069a2a4e9c94dfaae0c6a681461f2f5810ff6dc38be45da22987febfe5c371.json",
|
||||
"evidenceSha256": "612d7b9c53d327748ae2a98f0b20e71ddbffae21a621f8ab3e2c8e2e7f00b44d"
|
||||
},
|
||||
{
|
||||
"bankType": "scene",
|
||||
"acceptedPreloads": 16,
|
||||
"rejectedPreloads": 17,
|
||||
"evidencePath": "asset-capacity/evidence/native-bundle-43069a2a4e9c94dfaae0c6a681461f2f5810ff6dc38be45da22987febfe5c371.json",
|
||||
"evidenceSha256": "612d7b9c53d327748ae2a98f0b20e71ddbffae21a621f8ab3e2c8e2e7f00b44d"
|
||||
}
|
||||
]
|
||||
},
|
||||
"executables": {
|
||||
"prometeu": "ff1f910a0fa2f88828f03985767bb55c9364ec3ece25e46cf5965cd3faf1ceff",
|
||||
"prometeu-headless": "61a879c044097087b15fd6e4088ad8f93cb547c71cf2f7e05cf3ae586d78fada",
|
||||
"prometeu-runtime": "8259e3f707f1a006349fd1756979245f7a71668ac04fc896269084045d14a4e2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"profile": {
|
||||
"contractVersion": 1,
|
||||
"profileId": "native-bundle-f1f8224d1adeafea62bbf388c3c083361a145e52f084d6c48ccbb4c6060b97e2",
|
||||
"runtimeVersion": "0.1.0",
|
||||
"executableSha256": "ff1f910a0fa2f88828f03985767bb55c9364ec3ece25e46cf5965cd3faf1ceff",
|
||||
"limits": {
|
||||
"glyph": 16,
|
||||
"scene": 16
|
||||
},
|
||||
"evidence": [
|
||||
{
|
||||
"bankType": "glyph",
|
||||
"acceptedPreloads": 16,
|
||||
"rejectedPreloads": 17,
|
||||
"evidencePath": "asset-capacity/evidence/native-bundle-f1f8224d1adeafea62bbf388c3c083361a145e52f084d6c48ccbb4c6060b97e2.json",
|
||||
"evidenceSha256": "f909a77726f9d3c132f8ec8f172347021cf9b7d91a6424df905330c34f85b197"
|
||||
},
|
||||
{
|
||||
"bankType": "scene",
|
||||
"acceptedPreloads": 16,
|
||||
"rejectedPreloads": 17,
|
||||
"evidencePath": "asset-capacity/evidence/native-bundle-f1f8224d1adeafea62bbf388c3c083361a145e52f084d6c48ccbb4c6060b97e2.json",
|
||||
"evidenceSha256": "f909a77726f9d3c132f8ec8f172347021cf9b7d91a6424df905330c34f85b197"
|
||||
}
|
||||
]
|
||||
},
|
||||
"executables": {
|
||||
"prometeu": "ff1f910a0fa2f88828f03985767bb55c9364ec3ece25e46cf5965cd3faf1ceff",
|
||||
"prometeu-headless": "61a879c044097087b15fd6e4088ad8f93cb547c71cf2f7e05cf3ae586d78fada",
|
||||
"prometeu-runtime": "8e0e005de4b11b649088b77ed9fdfb4e97e851f3604fd4a09c2abadd272e231d"
|
||||
}
|
||||
},
|
||||
{
|
||||
"profile": {
|
||||
"contractVersion": 1,
|
||||
"profileId": "native-bundle-2cb9ab9296f9395fad196f7dd0b899f9e1c01ccc2e48cfe3b8dff37e628d419b",
|
||||
"runtimeVersion": "0.1.0",
|
||||
"executableSha256": "ff1f910a0fa2f88828f03985767bb55c9364ec3ece25e46cf5965cd3faf1ceff",
|
||||
"limits": {
|
||||
"glyph": 16,
|
||||
"scene": 16
|
||||
},
|
||||
"evidence": [
|
||||
{
|
||||
"bankType": "glyph",
|
||||
"acceptedPreloads": 16,
|
||||
"rejectedPreloads": 17,
|
||||
"evidencePath": "asset-capacity/evidence/native-bundle-2cb9ab9296f9395fad196f7dd0b899f9e1c01ccc2e48cfe3b8dff37e628d419b.json",
|
||||
"evidenceSha256": "deffbb51c56aa7958c53b83674ffa486364e7965f7ec629d74951b5889aec9ea"
|
||||
},
|
||||
{
|
||||
"bankType": "scene",
|
||||
"acceptedPreloads": 16,
|
||||
"rejectedPreloads": 17,
|
||||
"evidencePath": "asset-capacity/evidence/native-bundle-2cb9ab9296f9395fad196f7dd0b899f9e1c01ccc2e48cfe3b8dff37e628d419b.json",
|
||||
"evidenceSha256": "deffbb51c56aa7958c53b83674ffa486364e7965f7ec629d74951b5889aec9ea"
|
||||
}
|
||||
]
|
||||
},
|
||||
"executables": {
|
||||
"prometeu": "ff1f910a0fa2f88828f03985767bb55c9364ec3ece25e46cf5965cd3faf1ceff",
|
||||
"prometeu-headless": "61a879c044097087b15fd6e4088ad8f93cb547c71cf2f7e05cf3ae586d78fada",
|
||||
"prometeu-runtime": "02a7008a2efa2213fb34dd7de3057bec9c6a99c25656f9ab47ddd9338808234b"
|
||||
}
|
||||
},
|
||||
{
|
||||
"profile": {
|
||||
"contractVersion": 1,
|
||||
"profileId": "native-bundle-64979a224cd9c4f664b0a070285e4179df0b2ab4ac65d0637f4e843dcb677d70",
|
||||
"runtimeVersion": "0.1.0",
|
||||
"executableSha256": "ff1f910a0fa2f88828f03985767bb55c9364ec3ece25e46cf5965cd3faf1ceff",
|
||||
"limits": {
|
||||
"glyph": 16,
|
||||
"scene": 16
|
||||
},
|
||||
"evidence": [
|
||||
{
|
||||
"bankType": "glyph",
|
||||
"acceptedPreloads": 16,
|
||||
"rejectedPreloads": 17,
|
||||
"evidencePath": "asset-capacity/evidence/native-bundle-64979a224cd9c4f664b0a070285e4179df0b2ab4ac65d0637f4e843dcb677d70.json",
|
||||
"evidenceSha256": "f794f9802ba60925f595f302522cdd45f8a875add6cd73f0305da997a36b0bfd"
|
||||
},
|
||||
{
|
||||
"bankType": "scene",
|
||||
"acceptedPreloads": 16,
|
||||
"rejectedPreloads": 17,
|
||||
"evidencePath": "asset-capacity/evidence/native-bundle-64979a224cd9c4f664b0a070285e4179df0b2ab4ac65d0637f4e843dcb677d70.json",
|
||||
"evidenceSha256": "f794f9802ba60925f595f302522cdd45f8a875add6cd73f0305da997a36b0bfd"
|
||||
}
|
||||
]
|
||||
},
|
||||
"executables": {
|
||||
"prometeu": "ff1f910a0fa2f88828f03985767bb55c9364ec3ece25e46cf5965cd3faf1ceff",
|
||||
"prometeu-headless": "16aa375c2f79884f45d4a54f62bcaa25d62949ff96295422bc4a8e41d10e66a0",
|
||||
"prometeu-runtime": "2ba89830c9588e2854ee9feed0dea92506f22b08224523cea66d5701f66e0046"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
+1675
File diff suppressed because it is too large
Load Diff
+1675
File diff suppressed because it is too large
Load Diff
+1675
File diff suppressed because it is too large
Load Diff
+1675
File diff suppressed because it is too large
Load Diff
@@ -89,8 +89,8 @@ class StudioPlayDesktopTest {
|
||||
fx(()->{assertTrue(stage.getScene().lookup("#runtime-path").isDisabled());return null;});
|
||||
assertThrows(p.studio.api.automation.ControlDeniedException.class,()->access.enterManual(root));
|
||||
fx(()->{ComboBox<Integer> zoom=(ComboBox<Integer>)stage.getScene().lookup("#viewport-zoom");zoom.setValue(4);
|
||||
var image=(ImageView)stage.getScene().lookup("#game-image");assertEquals(1920,image.getFitWidth());assertFalse(image.isSmooth());
|
||||
zoom.setValue(2);assertEquals(960,image.getFitWidth());zoom.setValue(1);assertEquals(480,image.getFitWidth());return null;});
|
||||
var image=(ImageView)stage.getScene().lookup("#game-image");assertEquals(2560,image.getFitWidth());assertFalse(image.isSmooth());
|
||||
zoom.setValue(2);assertEquals(1280,image.getFitWidth());zoom.setValue(1);assertEquals(640,image.getFitWidth());return null;});
|
||||
// Deliver a real key edge through the viewport; Pong leaves its static menu.
|
||||
// Zoom popup/native activation can transfer desktop focus. Establish the
|
||||
// input precondition explicitly; the later focus-loss checks never resume.
|
||||
@@ -219,6 +219,7 @@ class StudioPlayDesktopTest {
|
||||
assertEquals(16,image.getFitWidth());
|
||||
pointer(image,MouseEvent.MOUSE_PRESSED,6,6);assertEquals(new ExecutionInput(4096,1,1),input.get());
|
||||
pointer(image,MouseEvent.MOUSE_DRAGGED,-1,6);assertEquals(0,input.get().buttons());assertEquals(-1,input.get().touchX());
|
||||
pointer(image,MouseEvent.MOUSE_DRAGGED,6,6);assertEquals(0,input.get().buttons(),"Reentry while held must not recapture");
|
||||
pointer(image,MouseEvent.MOUSE_PRESSED,14,6);assertEquals(new ExecutionInput(4096,3,1),input.get());
|
||||
pointer(image,MouseEvent.MOUSE_RELEASED,30,30);assertEquals(0,input.get().buttons());
|
||||
var surface=stage.getScene().lookup("#game-surface");
|
||||
|
||||
@@ -93,6 +93,70 @@ class HeadlessTaskIntegrationTest {
|
||||
}
|
||||
void authorityRetained() { assertEquals(ControlState.AGENT_WORKING, project.automation().snapshot().state()); }
|
||||
|
||||
@org.junit.jupiter.params.ParameterizedTest
|
||||
@org.junit.jupiter.params.provider.ValueSource(strings={"pong","fragments","main"})
|
||||
void maintainedGraphicsExamplesBuildAndPublishNativeFrames(String name) throws Exception {
|
||||
project.close();
|
||||
Path examples=Path.of("../test-projects").toAbsolutePath().normalize();
|
||||
if(!Files.isDirectory(examples))examples=Path.of("test-projects").toAbsolutePath().normalize();
|
||||
Path example=examples.resolve(name);
|
||||
for(String directory:List.of("src","assets")){
|
||||
Path from=example.resolve(directory);
|
||||
if(!Files.isDirectory(from))continue;
|
||||
try(var files=Files.walk(from)){
|
||||
for(Path file:files.toList()){
|
||||
Path target=root.resolve(directory).resolve(from.relativize(file));
|
||||
if(Files.isDirectory(file))Files.createDirectories(target);
|
||||
else Files.copy(file,target,StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
}
|
||||
}
|
||||
Files.copy(example.resolve("prometeu.json"),root.resolve("prometeu.json"),StandardCopyOption.REPLACE_EXISTING);
|
||||
var reference=app.getBean(ProjectCatalog.class).openProject(root);
|
||||
project=app.getBean(ProjectSessionFactory.class).open(reference);
|
||||
assertTrue(project.automation().grant(false).toCompletableFuture().get(5,TimeUnit.SECONDS).success());
|
||||
task=tasks.acquire(root).task().value();
|
||||
call(TaskTools.HeadlessAction.BOOT,successfulBuild("graphics-"+name));
|
||||
var result=advance("graphics-frames-"+name);
|
||||
assertEquals(AutomationOutcome.Kind.SUCCEEDED,result.kind(),String.valueOf(result));
|
||||
var png=result.capture().png();
|
||||
var pixels=new p.studio.app.evidence.PngEvidenceCodec().decode(png);
|
||||
assertEquals(640,pixels.width());assertEquals(360,pixels.height());
|
||||
assertNull(call(TaskTools.HeadlessAction.FAULT,null).values().get("fault"));
|
||||
Path output=Path.of("build/graphics-examples");Files.createDirectories(output);
|
||||
Files.write(output.resolve(name+".png"),png);
|
||||
if(name.equals("pong")) {
|
||||
tasks.headless(root,task,TaskTools.HeadlessAction.SET_INPUT,null,Map.of("start",true));
|
||||
advance("pong-native-start");
|
||||
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;
|
||||
for(int i=0;i<80&&!rightPaddleBounce;i++) {
|
||||
String request="pong-native-contact-"+i;
|
||||
tasks.advance(root,task,request,1);
|
||||
var frame=finished(request);assertNull(frame.failure());
|
||||
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.
|
||||
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);}
|
||||
}
|
||||
assertTrue(right>=left,"Playing ball must remain observable before right contact");
|
||||
int center=(left+right)/2;
|
||||
// A scored point would teleport to the center; require a local
|
||||
// reversal near the new right paddle at x=590 instead.
|
||||
rightPaddleBounce=previous>570&¢er<previous&¢er>500;
|
||||
previous=center;
|
||||
}
|
||||
assertTrue(rightPaddleBounce,"Actual guest ball must bounce off the paddle in the expanded arena");
|
||||
}
|
||||
}
|
||||
|
||||
@Test void originalCaptureEvidenceSurvivesLaterFramesRebuildReleaseAndReopen() throws Exception {
|
||||
call(TaskTools.HeadlessAction.BOOT,successfulBuild("evidence-build"));
|
||||
tasks.advance(root,task,"evidence-frame",1);var original=finished("evidence-frame");
|
||||
@@ -145,7 +209,7 @@ class HeadlessTaskIntegrationTest {
|
||||
var legacyPaths=new ArrayList<String>();
|
||||
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(113,114,1,80),new Evidence.Rect(237,152,6,6),new Evidence.Rect(42,72,8,36)};
|
||||
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}};
|
||||
long totalPngBytes=0;
|
||||
for(int i=0;i<names.length;i++) {
|
||||
@@ -163,11 +227,11 @@ class HeadlessTaskIntegrationTest {
|
||||
assertFalse(persisted.path("isError").asBoolean(),persisted.toString());
|
||||
var actual=mapper.convertValue(persisted.path("structuredContent").path("value"),Evidence.Publication.class).artifacts().getFirst();
|
||||
Path reference=root.resolve("reference-"+names[i]+".png");
|
||||
byte[] rgba=new byte[480*270*4];
|
||||
byte[] rgba=new byte[640*360*4];
|
||||
for(int pixel=0;pixel<rgba.length;pixel+=4){
|
||||
rgba[pixel]=(byte)colors[i][0];rgba[pixel+1]=(byte)colors[i][1];rgba[pixel+2]=(byte)colors[i][2];rgba[pixel+3]=(byte)255;
|
||||
}
|
||||
Files.write(reference,new p.studio.app.evidence.PngEvidenceCodec().encode(new Evidence.Pixels(480,270,rgba)));
|
||||
Files.write(reference,new p.studio.app.evidence.PngEvidenceCodec().encode(new Evidence.Pixels(640,360,rgba)));
|
||||
legacyPaths.add(reference.toString());legacyPaths.add(legacyActual.toString());
|
||||
var imported=mcp.call("studio_evidence_import",args.deepCopy().put("clientRequestId","import-"+request).put("path",reference.toString())).wire();
|
||||
afterCalls++;afterWireBytes+=mapper.writeValueAsBytes(imported).length;
|
||||
|
||||
@@ -75,7 +75,7 @@ class StudioPlayProcessTest {
|
||||
try(var s=new Native()){
|
||||
s.connection.pause().get(3,TimeUnit.SECONDS);s.connection.startExecution().get(3,TimeUnit.SECONDS);
|
||||
Thread.sleep(80);assertNull(s.connection.acquireLatestFrame());
|
||||
s.connection.resume().get(3,TimeUnit.SECONDS);try(var image=s.image()){assertEquals(480,image.width());}
|
||||
s.connection.resume().get(3,TimeUnit.SECONDS);try(var image=s.image()){assertEquals(640,image.width());}
|
||||
s.connection.stopAsync().get(5,TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ class StudioWireTest {
|
||||
byte[] huge=fixture("pause.hex");java.util.Arrays.fill(huge,12,16,(byte)255);
|
||||
assertThrows(IOException.class,()->Header.decode(huge));
|
||||
assertThrows(IOException.class,()->frameBytes(Integer.MAX_VALUE,Integer.MAX_VALUE,Integer.MAX_VALUE));
|
||||
assertThrows(IOException.class,()->frameBytes(480,270,481));
|
||||
assertEquals(518400,frameBytes(480,270,480));
|
||||
assertThrows(IOException.class,()->frameBytes(640,360,641));
|
||||
assertEquals(921600,frameBytes(640,360,640));
|
||||
assertThrows(IOException.class,()->text(new byte[]{(byte)0xff},0));
|
||||
}
|
||||
@Test void rgbaPayloadMatchesSharedFixture() throws Exception {
|
||||
|
||||
+4
-1
@@ -18,7 +18,7 @@ public final class PlaybackViewport extends BorderPane implements AutoCloseable
|
||||
private final EnumSet<KeyCode> pressed=EnumSet.noneOf(KeyCode.class);
|
||||
private final AnimationTimer timer;
|
||||
private WritableImage writable;
|
||||
private int zoom=1,width=480,height=270,touchX=-1,touchY=-1;
|
||||
private int zoom=1,width=0,height=0,touchX=-1,touchY=-1;
|
||||
private boolean touching;
|
||||
private long painted,lastFrame;
|
||||
private final long[] latencies=new long[2048];
|
||||
@@ -33,6 +33,7 @@ public final class PlaybackViewport extends BorderPane implements AutoCloseable
|
||||
surface.focusedProperty().addListener((o,a,b)->{if(!b)neutralize();});
|
||||
image.setOnMousePressed(e->{surface.requestFocus();touch(e,true);});
|
||||
image.setOnMouseDragged(e->touch(e,true));
|
||||
image.setOnMouseExited(e->{if(touching){touching=false;touchX=touchY=-1;send();}});
|
||||
surface.addEventFilter(MouseEvent.MOUSE_RELEASED,e->{if(e.getButton()==MouseButton.PRIMARY)touch(e,false);});
|
||||
timer=new AnimationTimer(){@Override public void handle(long now){paint();}};timer.start();
|
||||
}
|
||||
@@ -61,6 +62,8 @@ public final class PlaybackViewport extends BorderPane implements AutoCloseable
|
||||
case Q->8;case E->9;case Z->10;case SHIFT->11;default->-1;};}
|
||||
private void touch(MouseEvent event,boolean down){
|
||||
if(down&&!event.isPrimaryButtonDown())return;
|
||||
// After leaving the image, dragging back with the button held cannot recapture.
|
||||
if(down&&!touching&&event.getEventType()!=MouseEvent.MOUSE_PRESSED)return;
|
||||
var p=image.sceneToLocal(event.getSceneX(),event.getSceneY());
|
||||
int x=(int)Math.floor(p.getX()/zoom),y=(int)Math.floor(p.getY()/zoom);
|
||||
touching=down&&state.get()==ExecutionState.RUNNING&&x>=0&&y>=0&&x<width&&y<height;
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
# Fragments
|
||||
|
||||
A procedural fractal/cloud effect with moving stars. Open the project in Studio,
|
||||
build with Shipper and use Debug Play. The sample keeps its original logical
|
||||
320×180 field and 8-pixel cells; the host framebuffer is 480×270.
|
||||
build with Shipper and use Debug Play. The effect covers the native 640×360 field.
|
||||
Its procedural cells are 16 pixels: 920 cells retain the original sample's
|
||||
computational workload, while 8-pixel cells over the larger field exhausted the
|
||||
existing VM frame budget. This content adjustment preserves the effect's update
|
||||
rhythm without changing machine limits. The final cell row is clipped to 8 pixels;
|
||||
star sizes and motion remain unchanged. These cells are drawing primitives, not a
|
||||
restriction on the machine's 8/16/32-pixel glyph tiles.
|
||||
|
||||
The effect's palette formulas produce RGB565 values. `rgb565()` explicitly expands
|
||||
the 5/6/5-bit channels into the current RGBA8888 Color representation. No image
|
||||
|
||||
@@ -2,9 +2,11 @@ import { Color } from @core:color;
|
||||
import { Gfx } from @sdk:gfx;
|
||||
|
||||
declare global ticks: int = 0;
|
||||
declare const SCREEN_W: int = 320;
|
||||
declare const SCREEN_H: int = 180;
|
||||
declare const CELL: int = 8;
|
||||
declare const SCREEN_W: int = 640;
|
||||
declare const SCREEN_H: int = 360;
|
||||
// Keep the procedural workload within the existing VM frame budget at 640x360.
|
||||
// The last row is clipped to the final 8 pixels of the framebuffer.
|
||||
declare const CELL: int = 16;
|
||||
|
||||
[Init]
|
||||
fn init() -> void
|
||||
@@ -140,4 +142,4 @@ fn frame() -> void
|
||||
Gfx.fill_rect(star_f, star_y5, star_s5, star_s5, rgb565(star_c5));
|
||||
|
||||
}
|
||||
// Estimated frame cost: ~920 fills + ~2760 fractal-iteration steps + 6 twinkling parallax stars/frame at CELL=8.
|
||||
// 920 fills + 2760 fractal-iteration steps + 6 twinkling stars/frame at CELL=16.
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
Open this folder in Studio, build with Shipper and use Debug Play. The project
|
||||
uses the current Pad/Button and Touch input APIs and the existing Composer API.
|
||||
Touch advances the Link frames; releasing resets them. The camera pans through
|
||||
the scene. A/B/X demonstrate the log levels.
|
||||
the scene with bounds for the native 640×360 viewport. The three active 8-pixel
|
||||
layers extend to 45 rows by continuing their existing bottom terrain; the
|
||||
base layer is 720 pixels wide, so the camera travels from x=0 to x=80. A/B/X demonstrate the log levels.
|
||||
|
||||
Packer preloads Zelda3 into glyph slot 0, tileset into glyph slot 1 and tiled2
|
||||
into scene slot 0. The scene is bound from Frame, after preloads complete.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.10" tiledversion="1.12.1" orientation="orthogonal" renderorder="right-down" width="120" height="34" tilewidth="8" tileheight="8" infinite="0" nextlayerid="4" nextobjectid="1">
|
||||
<map version="1.10" tiledversion="1.12.1" orientation="orthogonal" renderorder="right-down" width="120" height="45" tilewidth="8" tileheight="8" infinite="0" nextlayerid="4" nextobjectid="1">
|
||||
<tileset firstgid="1" source="../tileset/tileset.tsx"/>
|
||||
<layer id="1" name="Layer 1" width="90" height="34" visible="0" locked="1">
|
||||
<layer id="1" name="Layer 1" width="90" height="45" visible="0" locked="1">
|
||||
<data encoding="csv">
|
||||
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
|
||||
8,8,8,8,8,8,8,8,1,1,1,1,1,1,8,8,8,8,1,1,1,1,1,1,1,1,1,1,1,1,8,8,8,8,8,8,1,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
|
||||
@@ -36,10 +36,21 @@
|
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
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
|
||||
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
|
||||
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
|
||||
8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
|
||||
</data>
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="2" name="Layer 2" width="90" height="34" visible="0" locked="1">
|
||||
<layer id="2" name="Layer 2" width="90" height="45" visible="0" locked="1">
|
||||
<data encoding="csv">
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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,0,0,7,7,7,7,7,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,8,0,0,0,0,0
|
||||
</data>
|
||||
</data>
|
||||
</layer>
|
||||
</map>
|
||||
|
||||
@@ -11,6 +11,8 @@ declare global camera_x: int = 0;
|
||||
declare global camera_mult: int = 1;
|
||||
declare const MAX_FRAMES: int = 4;
|
||||
declare const CAMERA_SPEED: int = 1;
|
||||
// The base scene is 90 tiles of 8 pixels; viewport is the fixed native 640.
|
||||
declare const CAMERA_MAX_X: int = 90 * 8 - 640;
|
||||
|
||||
[Init]
|
||||
fn init() -> void
|
||||
@@ -56,7 +58,7 @@ fn frame() -> void
|
||||
}
|
||||
|
||||
camera_x = camera_x + (camera_mult * CAMERA_SPEED);
|
||||
if (camera_x >= 240 || camera_x <= 0)
|
||||
if (camera_x >= CAMERA_MAX_X || camera_x <= 0)
|
||||
{
|
||||
camera_mult = -1 * camera_mult;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,10 @@ The CPU moves more slowly and starts tracking when the ball enters its half.
|
||||
## Source
|
||||
|
||||
`src/main.pbs` separates input, state transitions, simulation and rendering.
|
||||
The game uses a fixed 480×270 field, quarter-pixel integer coordinates and four
|
||||
small simulation substeps per logical frame. Ball speed is capped so it cannot
|
||||
The game uses a fixed 640×360 field, quarter-pixel integer coordinates and four
|
||||
small simulation substeps per logical frame. Positions and speeds follow the larger native arena while paddle/ball sizes and
|
||||
match rules remain unchanged. At maximum speed each substep is 2.5 pixels, below
|
||||
the 8-pixel paddle thickness. Ball speed is capped so it cannot
|
||||
jump through a paddle. It uses the existing `@sdk:input`, `@sdk:gfx` and
|
||||
`@core:color` modules; no external art, audio, save system or engine changes are
|
||||
required for this first version. Every new match clears scores and positions.
|
||||
|
||||
@@ -2,10 +2,11 @@ import { Color } from @core:color;
|
||||
import { Gfx } from @sdk:gfx;
|
||||
import { Pad, Button } from @sdk:input;
|
||||
|
||||
// One logical frame is one game tick. Ball coordinates use quarter pixels.
|
||||
// Native 640x360 arena. One logical frame is one game tick; ball uses quarter pixels.
|
||||
// Speeds track the larger playfield while paddle/ball art and mechanics stay unchanged.
|
||||
declare const SCALE: int = 4;
|
||||
declare const FIELD_TOP: int = 72;
|
||||
declare const FIELD_BOTTOM: int = 238;
|
||||
declare const FIELD_BOTTOM: int = 328;
|
||||
declare const PADDLE_H: int = 36;
|
||||
declare const BALL_SIZE: int = 6;
|
||||
declare const MENU: int = 0;
|
||||
@@ -16,14 +17,14 @@ declare const FINISHED: int = 4;
|
||||
|
||||
declare global phase: int = 0;
|
||||
declare global resume_phase: int = 0;
|
||||
declare global player_y: int = 137;
|
||||
declare global cpu_y: int = 137;
|
||||
declare global player_y: int = 182;
|
||||
declare global cpu_y: int = 182;
|
||||
declare global player_score: int = 0;
|
||||
declare global cpu_score: int = 0;
|
||||
declare global ball_x: int = 948;
|
||||
declare global ball_y: int = 608;
|
||||
declare global ball_vx: int = 4;
|
||||
declare global ball_vy: int = 2;
|
||||
declare global ball_x: int = 1268;
|
||||
declare global ball_y: int = 788;
|
||||
declare global ball_vx: int = 6;
|
||||
declare global ball_vy: int = 3;
|
||||
declare global serve_ticks: int = 60;
|
||||
declare global hit_flash: int = 0;
|
||||
|
||||
@@ -39,12 +40,12 @@ fn abs_i(value: int) -> int {
|
||||
}
|
||||
|
||||
fn prepare_serve(direction: int) -> void {
|
||||
player_y = 137;
|
||||
cpu_y = 137;
|
||||
ball_x = 237 * SCALE;
|
||||
ball_y = 152 * SCALE;
|
||||
ball_vx = direction * 4;
|
||||
ball_vy = if (player_score + cpu_score) % 2 == 0 { 2 } else { -3 };
|
||||
player_y = 182;
|
||||
cpu_y = 182;
|
||||
ball_x = 317 * SCALE;
|
||||
ball_y = 197 * SCALE;
|
||||
ball_vx = direction * 6;
|
||||
ball_vy = if (player_score + cpu_score) % 2 == 0 { 3 } else { -4 };
|
||||
serve_ticks = 60;
|
||||
hit_flash = 0;
|
||||
phase = SERVING;
|
||||
@@ -64,27 +65,27 @@ fn init() -> void {
|
||||
}
|
||||
|
||||
fn move_player(up: bool, down: bool) -> void {
|
||||
if up && !down { player_y = player_y - 4; }
|
||||
if down && !up { player_y = player_y + 4; }
|
||||
if up && !down { player_y = player_y - 6; }
|
||||
if down && !up { player_y = player_y + 6; }
|
||||
player_y = clamp(player_y, FIELD_TOP, FIELD_BOTTOM - PADDLE_H);
|
||||
}
|
||||
|
||||
fn move_cpu() -> void {
|
||||
// The CPU reacts only in its half and is slower than the human paddle.
|
||||
let target: int = 137;
|
||||
if ball_vx > 0 && ball_x > 240 * SCALE {
|
||||
let target: int = 182;
|
||||
if ball_vx > 0 && ball_x > 320 * SCALE {
|
||||
target = ball_y / SCALE + BALL_SIZE / 2 - PADDLE_H / 2;
|
||||
}
|
||||
if target > cpu_y + 2 { cpu_y = cpu_y + 2; }
|
||||
if target < cpu_y - 2 { cpu_y = cpu_y - 2; }
|
||||
if target > cpu_y + 3 { cpu_y = cpu_y + 3; }
|
||||
if target < cpu_y - 3 { cpu_y = cpu_y - 3; }
|
||||
cpu_y = clamp(cpu_y, FIELD_TOP, FIELD_BOTTOM - PADDLE_H);
|
||||
}
|
||||
|
||||
fn bounce(paddle_y: int, direction: int) -> void {
|
||||
let speed: int = clamp(abs_i(ball_vx) + 1, 4, 7);
|
||||
let speed: int = clamp(abs_i(ball_vx) + 1, 6, 10);
|
||||
ball_vx = direction * speed;
|
||||
let offset: int = ball_y / SCALE + BALL_SIZE / 2 - paddle_y - PADDLE_H / 2;
|
||||
ball_vy = clamp(offset / 5, -4, 4);
|
||||
ball_vy = clamp(offset * 3 / 10, -6, 6);
|
||||
if ball_vy == 0 {
|
||||
ball_vy = if (player_score + cpu_score) % 2 == 0 { -1 } else { 1 };
|
||||
}
|
||||
@@ -103,7 +104,7 @@ fn point(player_won: bool) -> void {
|
||||
}
|
||||
|
||||
fn move_ball() -> void {
|
||||
// At max speed each substep travels 1.75 px, below the paddle thickness.
|
||||
// At max speed each substep travels 2.5 px, below the paddle thickness.
|
||||
for substep: int from 0 until 4 {
|
||||
ball_x = ball_x + ball_vx;
|
||||
ball_y = ball_y + ball_vy;
|
||||
@@ -125,9 +126,9 @@ fn move_ball() -> void {
|
||||
bounce(player_y, 1);
|
||||
}
|
||||
}
|
||||
if ball_vx > 0 && x + BALL_SIZE >= 430 && x <= 438 {
|
||||
if ball_vx > 0 && x + BALL_SIZE >= 590 && x <= 598 {
|
||||
if y + BALL_SIZE > cpu_y && y < cpu_y + PADDLE_H {
|
||||
ball_x = (430 - BALL_SIZE) * SCALE;
|
||||
ball_x = (590 - BALL_SIZE) * SCALE;
|
||||
bounce(cpu_y, -1);
|
||||
}
|
||||
}
|
||||
@@ -136,7 +137,7 @@ fn move_ball() -> void {
|
||||
point(false);
|
||||
return;
|
||||
}
|
||||
if ball_x > 460 * SCALE {
|
||||
if ball_x > 620 * SCALE {
|
||||
point(true);
|
||||
return;
|
||||
}
|
||||
@@ -189,11 +190,11 @@ fn draw_digit(value: int, x: int, y: int, color: Color) -> void {
|
||||
}
|
||||
|
||||
fn draw_overlay(title: str, line_one: str, line_two: str) -> void {
|
||||
Gfx.draw_square(112, 111, 256, 90, Color.rgb(57, 81, 106), Color.rgb(12, 22, 39));
|
||||
Gfx.fill_rect(112, 111, 3, 90, Color.rgb(77, 237, 205));
|
||||
Gfx.draw_text(136, 125, title, Color.rgb(236, 244, 250));
|
||||
Gfx.draw_text(136, 150, line_one, Color.rgb(155, 176, 198));
|
||||
Gfx.draw_text(136, 174, line_two, Color.rgb(77, 237, 205));
|
||||
Gfx.draw_square(192, 156, 256, 90, Color.rgb(57, 81, 106), Color.rgb(12, 22, 39));
|
||||
Gfx.fill_rect(192, 156, 3, 90, Color.rgb(77, 237, 205));
|
||||
Gfx.draw_text(216, 170, title, Color.rgb(236, 244, 250));
|
||||
Gfx.draw_text(216, 195, line_one, Color.rgb(155, 176, 198));
|
||||
Gfx.draw_text(216, 219, line_two, Color.rgb(77, 237, 205));
|
||||
}
|
||||
|
||||
fn draw() -> void {
|
||||
@@ -204,22 +205,22 @@ fn draw() -> void {
|
||||
Gfx.clear(Color.rgb(7, 14, 26));
|
||||
Gfx.draw_text(24, 17, "PONG", white);
|
||||
Gfx.draw_text(24, 32, "PROMETEU", muted);
|
||||
Gfx.draw_text(370, 17, "FIRST TO 5", muted);
|
||||
Gfx.draw_text(138, 34, "YOU", mint);
|
||||
Gfx.draw_text(313, 34, "CPU", coral);
|
||||
draw_digit(player_score, 190, 19, mint);
|
||||
draw_digit(cpu_score, 272, 19, coral);
|
||||
Gfx.fill_rect(237, 28, 3, 3, muted);
|
||||
Gfx.fill_rect(237, 39, 3, 3, muted);
|
||||
Gfx.draw_text(530, 17, "FIRST TO 5", muted);
|
||||
Gfx.draw_text(218, 34, "YOU", mint);
|
||||
Gfx.draw_text(393, 34, "CPU", coral);
|
||||
draw_digit(player_score, 270, 19, mint);
|
||||
draw_digit(cpu_score, 352, 19, coral);
|
||||
Gfx.fill_rect(317, 28, 3, 3, muted);
|
||||
Gfx.fill_rect(317, 39, 3, 3, muted);
|
||||
|
||||
Gfx.draw_square(20, 66, 440, 178, Color.rgb(37, 57, 79), Color.rgb(13, 23, 40));
|
||||
for y: int from 76 until 238 step 13 {
|
||||
Gfx.fill_rect(239, y, 2, 6, Color.rgb(43, 61, 82));
|
||||
Gfx.draw_square(20, 66, 600, 268, Color.rgb(37, 57, 79), Color.rgb(13, 23, 40));
|
||||
for y: int from 76 until 328 step 13 {
|
||||
Gfx.fill_rect(319, y, 2, 6, Color.rgb(43, 61, 82));
|
||||
}
|
||||
Gfx.fill_rect(40, player_y + 3, 10, PADDLE_H, Color.rgb(20, 58, 60));
|
||||
Gfx.fill_rect(430, cpu_y + 3, 10, PADDLE_H, Color.rgb(65, 37, 46));
|
||||
Gfx.fill_rect(590, cpu_y + 3, 10, PADDLE_H, Color.rgb(65, 37, 46));
|
||||
Gfx.fill_rect(42, player_y, 8, PADDLE_H, mint);
|
||||
Gfx.fill_rect(430, cpu_y, 8, PADDLE_H, coral);
|
||||
Gfx.fill_rect(590, cpu_y, 8, PADDLE_H, coral);
|
||||
|
||||
if phase == PLAYING || phase == SERVING || phase == PAUSED {
|
||||
let x: int = ball_x / SCALE;
|
||||
@@ -232,15 +233,15 @@ fn draw() -> void {
|
||||
if hit_flash > 0 { Gfx.draw_square(x - 2, y - 2, 10, 10, mint, white); }
|
||||
}
|
||||
|
||||
Gfx.draw_text(24, 254, "UP / DOWN MOVE", muted);
|
||||
Gfx.draw_text(344, 254, "START PAUSE", muted);
|
||||
Gfx.draw_text(24, 344, "UP / DOWN MOVE", muted);
|
||||
Gfx.draw_text(504, 344, "START PAUSE", muted);
|
||||
if phase == MENU {
|
||||
draw_overlay("LET'S PLAY PONG", "YOU VS CPU / FIRST TO 5", "A / START - PLAY");
|
||||
} else if phase == SERVING {
|
||||
let countdown = if serve_ticks > 40 { "3" } else if serve_ticks > 20 { "2" } else { "1" };
|
||||
Gfx.draw_text(220, 111, "READY", mint);
|
||||
Gfx.draw_text(236, 128, countdown, white);
|
||||
Gfx.draw_text(190, 188, "A - SERVE NOW", muted);
|
||||
Gfx.draw_text(300, 156, "READY", mint);
|
||||
Gfx.draw_text(316, 173, countdown, white);
|
||||
Gfx.draw_text(270, 233, "A - SERVE NOW", muted);
|
||||
} else if phase == PAUSED {
|
||||
draw_overlay("PAUSED", "A / START - RESUME", "B - MAIN MENU");
|
||||
} else if phase == FINISHED {
|
||||
|
||||
Reference in New Issue
Block a user