sprig icon indicating copy to clipboard operation
sprig copied to clipboard

Documentation lies regarding z-index ordering of setLegend

Open grymmy opened this issue 1 year ago • 2 comments

Describe the bug A user reported that the documentation in the help panel states the following under setLegend(bitmaps): Screenshot 2023-11-08 at 4 25 53 PM however this link shows a game where it can easily be seen that this ordering is not respected.

To Reproduce Steps to reproduce the behavior:

  1. Open above link
  2. Modify legend order
  3. Run game

Expected behavior draw order should respect setLegend documentation

Actual behavior
draw order does not respect setLegend documentation

grymmy avatar Nov 08 '23 21:11 grymmy

@leomcelroy stated he believed this is likely a regression. I will investigate this tomorrow by doing a git bisect and attempt to find the specific commit that caused this apparent regression.

grymmy avatar Nov 08 '23 21:11 grymmy

This is a minimal example that does seem to demonstrate that the z-ordering is respected.

https://sprig.hackclub.com/share/3kovFmLi0HQaMQNvOMQd

Try swapping the order of the sprites.

What the bug should be in the provided example is that setLegend should clear the entire sprite table in the movement code.

onInput("w", () => {
  getFirst(player).y -= 1
  setLegend([ player, playerMaps[0]])
})
onInput("a", () => {
  getFirst(player).x -= 1
  setLegend([ player, playerMaps[1]])
})
onInput("s", () => {
  getFirst(player).y += 1
  setLegend([ player, playerMaps[3]])
})
onInput("d", () => {
  getFirst(player).x += 1
  setLegend([ player, playerMaps[2]])
})

The error may be here:

https://github.com/hackclub/sprig-engine/blob/main/src/web/index.ts#L94

leomcelroy avatar Nov 14 '23 14:11 leomcelroy