Skip to content

Sprite Lab in Lab2: player 2 - #76780

Open
breville wants to merge 2 commits into
stagingfrom
spritelab-lab2-player-2
Open

breville wants to merge 2 commits into
stagingfrom
spritelab-lab2-player-2

Conversation

@breville

@breville breville commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

[written by Claude]

Summary

A new block, set X as player 2, makes a sprite a second platform player, moved with W, A, S and D while the first player keeps the arrow keys, so two people can play on one keyboard. It falls, lands and jumps like the first player, under the same gravity. A player 2 block refers to it the way the player does, so events can tell the two apart. Both blocks are in the toolboxes and in the free-play level's Discover blocks catalog.

Captures

Recording

Screen.Recording.2026-11-05.at.11.03.26.PM.mov

Code

Screenshot 2026-11-05 at 11 12 09 PM

Catalog

Screenshot 2026-11-05 at 11 05 27 PM

Key changes

  • setAsPlatformPlayer2 and thePlayer2 block definitions. One builder in makePlatformPlayer writes the key handlers for both players, so the two sets cannot drift; the new block's runtime half calls it with W, A, S and D and the second group.
  • The player groups live in playerGroups.ts, shared by the engine and every block that names one.
  • The engine's player commands take a group: setPlatformPlayer and platformJump default to the first player's. Gravity, footing and landing apply to both groups; the sounds, objectives, jump event and camera still follow the arrow-key player, and the progress report does not count the other player as something touched.
  • The two blocks join the complete toolbox, the Platform toolbox additions, the free-play level's toolbox, and the block catalog's help.

Testing

Unit tests for the new block's generated code and its key wiring, for the first player's keys staying its own, and the existing suites for toolboxes, catalog help, image references and the engine's helper code. Checked in the browser as a test student on the free-play level with a two-player program, reading sprite positions from the running game: holding A moved player 2 left and off its ledge while player 1 stood still, holding the right arrow moved player 1 while player 2 stood still, W jumped player 2 alone, and the up arrow jumped player 1 alone.

A second platform player beside the first: "set X as player 2" promotes
a sprite into a second player group, steered by W, A, S and D as the
first is by the arrow keys, with the same physics and jump. "Player 2"
refers to it as "the player" does. The engine treats both groups as
players for gravity, footing and landing; the arrow-key player stays the
one the sounds, objectives and camera follow. Both blocks are in the
complete toolbox, the Platform additions and the free-play level's own
toolbox, with catalog entries, so Discover blocks offers them.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@breville breville changed the title Sprite Lab in Lab2: set as player 2, moved with W, A, S and D Sprite Lab in Lab2: player 2 Nov 6, 2026
@breville breville added the AI generated This PR has been substantially generated using AI. label Nov 6, 2026
The player groups move to playerGroups.ts, shared by the engine and the
block code, and every block reads the group from it. One builder writes
both players' key handlers. Jump take-off spots and the impulse frame are
kept for the arrow-key player only, since only its jump event is raised,
and the progress report no longer counts the other player as something
touched. The block help says which player the events, sounds and camera
follow.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@breville
breville requested review from a team, dju90 and katiejofr November 7, 2026 00:07

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI generated This PR has been substantially generated using AI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant