Repository navigation
Scratch for Java 7.0 - #60
Merged
Merged
Conversation
- Own renderer on LWJGL (OpenGL 3.3, 4.1 on macOS), sound on OpenAL Soft, images and fonts through stb; no Processing, JOGL or java.desktop. - A window thread and a game thread in lockstep: run() is called 60 times per second of game time, and the scene reaches the renderer as a draw list. Collisions, colour sensing and text layout are computed on the CPU, the same on every GPU and in headless tests. - Modules: core (scratch); the extensions tiled, save, recorder and drawing as jars of their own on a public extension API; the fat jar with build checks (all); the examples (demos, reference examples, parity probes, documentation tools). The 6.x single-module sources are removed. - The API cleaned up for learners: time in seconds, animations and nine-slicing on every sprite, layers, an immutable Color, Scratch's colour effect next to the tint, a shorter shader format, Scratch's ask box. docs/book/migrate-to-7.md lists every change. - templates/extension-starter for extensions by others.
- run.sh, visual-parity.sh, reference-docs.sh and update-demo-pages.sh build in the reactor; migrate-7.py moves 6.x projects to 7.0 and marks what needs a person. - The release workflow versions and publishes the modules in lockstep. - Catalogs and the compatibility contract regenerated from the 7.0 API.
- "Moving from 6.x to 7.0" lists every change; the major changeset. - Setup with Studio instead of BlueJ, the extension artifacts for Maven. - Tutorial projects and the VS Code starter on 7.0.
The standalone checks behind the move to LWJGL (window, game loop, text, audio, the macOS launch routes) and the workflow that runs them on macOS.
Module layout, build commands, testing without a window, the architecture and the documentation pipeline for 7.0, in one file for every tool.
…x calls - target/ and hidden folders (.scratch4j/, .vscode/, …) are copied, not migrated: Studio's generated launcher got a note it should not have - the row/column addAnimation hint matched the sheet calls the script had just written; it now needs six arguments, or seven ending in true/false
- A sprite keeps its world hitbox until it moves, turns, grows or changes costume or hitbox; touching checks asked for it twice per pair. - The stage keeps its sprites in order until they change, instead of copying the list for every touching check. - Colour checks leave out sprites whose painted pixels cannot lie under the sensing sprite, and a picture decides once whether it has effects to apply. With 400 sprites each asking which others it touches, a tick takes 6 ms instead of 25 ms (39 ns per pair; 6.x needed 58 ns).
- examples/src/main/java/benchmark: the stress test, n sprites asking which others they touch, n sprites looking for a colour; the same source runs on 6.x (scripts/benchmark/Main6.java against a build of main) - every run appends updates/s, frames/s, CPU and the cost per check, with commit, display, renderer and CPU, to scripts/benchmark/history.csv - the history starts with the runs under Xvfb before and after the faster collision and colour checks
getTouchingSprite(s) and isTouchingSprite ask for the sprite's own hitbox once, not again for every other sprite (800 sprites checking each other: 24.5 → 21 ms per tick). The benchmark can exit normally for a profiler (-Dbenchmark.exit=true).
- the graphic effects travel with the vertices instead of uniforms, so sprites with different effects are drawn together - consecutive sprites and image regions with the built-in program form one run: program and projection are set once, and only a change of texture draws what was collected (before: about eight GL calls per sprite) - costumes up to 512 pixels go into 2048-pixel atlas pages, each on an 8-pixel grid with its edge pixels repeated around it and three mip levels, so they look as in a texture of their own; shaders still get the costume as a texture of its own Stress test on a Radeon 780M: 540 figures 0.31 → 0.15 cores, 2160 figures 0.89 → 0.29 cores, both at 60 frames per second. visual-parity unchanged.
… swaps The window decided that vsync works unless 30 frames in a row came in under half a period (counting the tick work too). Once drawing got faster, frames alternated around that mark under Xvfb and the window drew up to 127 identical frames a second. Now the time between swaps is compared with the monitor's refresh period, and most of 60 swaps have to come too fast. A 144 Hz monitor, whose swaps the old rule took for "not waiting", keeps its vsync.
F12 keeps toggling debug mode; while it is on, a chip in the bottom right opens a checkbox list: hitboxes, positions (with the sprite's name), mouse and camera, touching pairs, hidden sprites, clone count, frame rate. -Dscratch4j.debug=... presets the options for headless runs. Clicks on the panel never reach the learner, and it rides the capture-excluded overlayItems, so captures stay reproducible.
The donutIO background grid covers the whole stage and follows the camera, so it counted as touching every donut (the debug overlay's touching pairs made it visible); it is scenery: disableHitbox(). Also remove leftovers the debug line, a println, the vestigial per-tick pen eraseAll (v7 has no canvas until a pen draws) and unused imports.
Controllers for up to four players: Gamepad asks anywhere for buttons, sticks (y up, as on the stage, with a dead zone), triggers and connections, and stages and sprites implementing GamepadListener are told about presses, releases and controllers connecting (changeset: minor). Wired into the fat jar, the examples and the build checks; the Online IDE does not offer the example yet. Smooth pixel art now scales the letterbox to fit, like its camera zoom, instead of whole numbers; plain pixel art keeps stepping whole pixels (changeset: patch). Also: the docs embed the online IDE instead of loading it from a CDN, the README and the docs index state that the project is independent of the Scratch Foundation, the benchmark history gets the runs after the batching and costume atlas changes, and the catalogs and browser compatibility files are regenerated with the gamepad API.
…o and the shader texts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
7.0: LWJGL instead of Processing, extensions as jars of their own, the learner API cleanup and the scratch-gamepad extension. The changesets (major) bump the version to 7.0.0;
docs/book/migrate-to-7.mdlists every breaking change.