Skip to content

inter-target execution order / layers #59

Description

@pufferfish101007

making notes here so i don't forget.

In scratch, targets are executed from the top layer down (so stage always last)

We currently have one threads table shared between all targets. This makes it difficult to match scratch's execution order (and at the moment we make no effort to do so).

Ideally we'll just make an array of arrays of threads which we can reorder - but also tag these with the targets so we can query which targets are in adjacent layers (see below)? Or could have those in a separate, parallel array.

Then, we will need to store for each sprite target its current layer.

When two sprites swap layer (this will only ever happen between adjacent sprites), we can just query which sprite is adjacent via the array, then update the position in both. So this is constant-time. When moving a sprite to the front or back, all other sprites just need to have their layer de/incremented, and the array can be shifted using array.copy. So linear time which is fine.

Also in addition to the threads_count we'll need a threads count for each target. We can't get rid of the total count though because we use this for checking stopped-ness in JS (I think?).

Metadata

Metadata

Fields

Priority

priority: high

Effort

effort: medium

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions