Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Two Locations at the same TileMap coordinates on the same TileMap are not equal #6517

Open
jernwerber opened this issue Oct 14, 2024 · 1 comment

Comments

@jernwerber
Copy link

When using tilemaps, MakeCode Arcade has blocks to retrieve an arbitrary tilemap location (tiles.getTileLocation(col,row)) as well as the tilemap Location of a sprite (mySprite.tilemapLocation()). Checking if two Locations are equal (i.e., they correspond to the same location on the TileMap) always returns false.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new MakeCode Arcade project.
  2. Add a Tilemap asset.
  3. Compare tilemap locations. Code:
tiles.setCurrentTileMap(tilemap`level1`) // use whatever the your tilemap is called
// compare the same location
console.log(tiles.getTileLocation(0,0)==tiles.getTileLocation(0,0)) // false

// compare the location of a sprite at the same location
let mySprite = sprites.create(img`a a a`, SpriteKind.Player) // use whatever image
tiles.placeOnTile(mySprite, tiles.getTileLocation(3,4)) // place the sprite at (3,4) on the tilemap
console.log(mySprite.tilemapLocation()==tiles.getTileLocation(3,4)) // false

Expected behavior

  • Tilemap locations at the same column and row should return true when compared.
  • And/or in Blocks mode, a warning or error should come up on the comparison block that Locations (or objects in general) can't be compared with it or the user should not be able to put a Location block into a logic block's open spaces.

Desktop (please complete the following information):

  • OS: Windows 10 (build 19045)
  • Browser: Chrome 129 (64-bit)

Additional context
I suppose this is because JavaScript comparisons using == of two objects are based on their references and not their values and two different Location objects would indeed not be the same. As a developer, this would be known, however for those just starting out, and considering that this comparison can be done in the Blocks editor as well, this could be confusing (sidenote: I ran into this issue while using MakeCode Arcade at a summer camp for youth 12-14).

@jernwerber jernwerber changed the title Bug: Two Locations at the same TileMap coordiantes on the same TileMap are not equal Bug: Two Locations at the same TileMap coordinates on the same TileMap are not equal Oct 14, 2024
@jernwerber
Copy link
Author

Also, I wouldn't mind taking a crack at addressing this, should it be something that is deemed fix-worthy. I see that strings are already treated as special for comparison, so I don't think it's too big of a stretch to treat objects (or even just some MakeCode objects) as special as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant