hackclub / sprig

🍃 Learn to code by making games in a JavaScript web-based game editor.
https://sprig.hackclub.com
MIT License
893 stars 1.05k forks source link

Documentation lies regarding z-index ordering of setLegend #1222

Open grymmy opened 11 months ago

grymmy commented 11 months ago

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 commented 11 months ago

@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.

leomcelroy commented 11 months ago

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