# Maze tile map navigation issues

**URL:** <https://forum.makecode.com/t/maze-tile-map-navigation-issues/484>\
**Category:** Arcade\
**Created:** [August 25, 2019, 4:44pm UTC](https://forum.makecode.com/t/maze-tile-map-navigation-issues/484 "2019-08-25T16:44:04Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![kjw](https://avatars.discourse-cdn.com/v4/letter/k/e79b87/32.png) [@kjw](https://forum.makecode.com/u/kjw)\
**Post date:** [August 25, 2019, 4:44pm UTC](https://forum.makecode.com/t/maze-tile-map-navigation-issues/484/1 "2019-08-25T16:44:04Z")

</div>

For a maze implemented with a tile map where the paths are the same size as the sprite there’s some unpredictable behaviour with trying to move the sprite down turnings. I’ve demonstrated this in this video (animated gif). A lot of the time I can make the turn by holding down the turn direction key and walking past it (effectively using a diagonal) but this doesn’t always work and sometimes many attempts fail. When I’m having trouble manoeuvring I press `A` to indicate this with `Denied!` message. This is the beta beta simulator (`0.14.3 5.21.6`):

 ![](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/1X/782dd7146d0b8552e6062bc2184539ebeba8be92.gif)

Watching the D-pad closely reveals which keys I am pressing in the simulator.

Here’s the code:

 ![Big-Ball-in-Maze-screenshot-code1](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/1X/6293239b64d51ab982c33f5e2f91404d5c926e23.png)

![arcade-Big-Ball-in-Maze](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/1X/64760c9bd22600faa40fefbd64addbed921ffd78.png)

I expanded the `move with buttons` block to show the default speed. I tried that at `40,40` and it appeared to improve the ability to navigate around the maze which suggests the discrete nature of the movement may be causing this. I don’t know if this is a bug or a feature but it’s certainly a potential cause of frustrating gameplay and difficult to explain to novice programmers.

What’s the best workaround here? Reduce the size of the player sprite slightly?

---

<div class="post-metadata">

**Author:** ![mmoskal](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/mmoskal/32/20_2.png) [@mmoskal](https://forum.makecode.com/u/mmoskal)\
**Post date:** [August 25, 2019, 6:00pm UTC](https://forum.makecode.com/t/maze-tile-map-navigation-issues/484/2 "2019-08-25T18:00:26Z")

</div>

@tballmsft is working on extending the controller blocks specifically for this scenario. Essentially the sprite always moves to the middle of the tile by itself.

---

<div class="post-metadata">

**Author:** ![mmoskal](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/mmoskal/32/20_2.png) [@mmoskal](https://forum.makecode.com/u/mmoskal)\
**Post date:** [August 25, 2019, 6:13pm UTC](https://forum.makecode.com/t/maze-tile-map-navigation-issues/484/3 "2019-08-25T18:13:43Z")

</div>

BTW maybe it’s obvious but making the sprite slightly smaller will likely improve things.

---

<div class="post-metadata">

**Author:** ![tballmsft](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/tballmsft/32/332_2.png) [@tballmsft](https://forum.makecode.com/u/tballmsft)\
**Post date:** [August 25, 2019, 10:07pm UTC](https://forum.makecode.com/t/maze-tile-map-navigation-issues/484/4 "2019-08-25T22:07:40Z")

</div>

There definitely are issues with pixel level collision detection and tile-based layout, which can probably be resolved by reducing sprite size. I am working on a simpler scheme for tile-based movement that should be ready in a week or so.

---

<div class="post-metadata">

**Author:** ![kjw](https://avatars.discourse-cdn.com/v4/letter/k/e79b87/32.png) [@kjw](https://forum.makecode.com/u/kjw)\
**Post date:** [August 25, 2019, 10:56pm UTC](https://forum.makecode.com/t/maze-tile-map-navigation-issues/484/5 "2019-08-25T22:56:06Z")

</div>

Thanks. I’m happy to do some testing when this is deployed.

On the subject of tiles, is there a way to list the tile(s) underneath a sprite in Blocks?

---

<div class="post-metadata">

**Author:** ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)\
**Post date:** [August 25, 2019, 11:59pm UTC](https://forum.makecode.com/t/maze-tile-map-navigation-issues/484/6 "2019-08-25T23:59:53Z")

</div>

Not currently, but what’s the case you’d be using it for? To check collisions with non-wall tiles?

---

<div class="post-metadata">

**Author:** ![rudro](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/rudro/32/995_2.png) [@rudro](https://forum.makecode.com/u/rudro)\
**Post date:** [August 26, 2019, 12:08am UTC](https://forum.makecode.com/t/maze-tile-map-navigation-issues/484/7 "2019-08-26T00:08:40Z")

</div>

I was thinking about using the tile map to spread out (many) food elements, in that case, I’d want to use a non-wall tile collision to check for the player eating food.

If there a better way to do this ?

---

<div class="post-metadata">

**Author:** ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)\
**Post date:** [August 26, 2019, 12:19am UTC](https://forum.makecode.com/t/maze-tile-map-navigation-issues/484/8 "2019-08-26T00:19:53Z")

</div>

I’d create them as sprites on top of tiles - there’s a block for getting all tiles of a given tile, so use that in a for each loop to place one food sprite on each tile, then just check sprite collisions with that. I’m on my phone, but I’ll edit this with a quick example in a few. The jumpy platformer example game i wrote on the home screen uses this to spawn coins, enemies, and the player.

Edit: Made it on my phone real quick [https://makecode.com/\_10M5W7UKEatH](https://makecode.com/_10M5W7UKEatH)

---

<div class="post-metadata">

**Author:** ![kjw](https://avatars.discourse-cdn.com/v4/letter/k/e79b87/32.png) [@kjw](https://forum.makecode.com/u/kjw)\
**Post date:** [September 1, 2019, 11:34pm UTC](https://forum.makecode.com/t/maze-tile-map-navigation-issues/484/9 "2019-09-01T23:34:07Z")

</div>

I’m also seeing what I think is the same issue with projectiles. I’d imagine most people’s projectiles are fairly small but I’ve got some absolute units at 16x16 and these disappear immediately / do not appear in a maze of the kind in the first post.

---

<div class="post-metadata">

**Author:** ![kjw](https://avatars.discourse-cdn.com/v4/letter/k/e79b87/32.png) [@kjw](https://forum.makecode.com/u/kjw)\
**Post date:** [September 16, 2019, 5:44pm UTC](https://forum.makecode.com/t/maze-tile-map-navigation-issues/484/10 "2019-09-16T17:44:07Z")

</div>

There are some definite issues/quirks with the mix of real numbers for physics and the discrete world of MakeCode Arcade’s tile maps and sprites. This example with maze navigation is frustrating and I suspect it’ll prove difficult to explain this behaviour to children.

I’ve put together some other tests which test things that are currently ok and highlight some problems with a 16x16 sprite passing a 16 wide gap slowly with acceleration toward that gap, see [Physics engine tests?](https://forum.makecode.com/t/physics-engine-tests/509/5/). Those might be useful to verify any changes made don’t alter desirable/current behaviour and to see what they do in terms of improving gap passing.

---

<div class="post-metadata">

**Author:** ![tballmsft](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/tballmsft/32/332_2.png) [@tballmsft](https://forum.makecode.com/u/tballmsft)\
**Post date:** [September 16, 2019, 6:55pm UTC](https://forum.makecode.com/t/maze-tile-map-navigation-issues/484/11 "2019-09-16T18:55:42Z")

</div>

I’ll take a look at these. Many thanks!

– Tom

---

<div class="post-metadata">

**Author:** ![tballmsft](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/tballmsft/32/332_2.png) [@tballmsft](https://forum.makecode.com/u/tballmsft)\
**Post date:** [September 16, 2019, 6:56pm UTC](https://forum.makecode.com/t/maze-tile-map-navigation-issues/484/12 "2019-09-16T18:56:40Z")

</div>

Can you please share the program (via the Share button)?

– Tom

---

<div class="post-metadata">

**Author:** ![kjw](https://avatars.discourse-cdn.com/v4/letter/k/e79b87/32.png) [@kjw](https://forum.makecode.com/u/kjw)\
**Post date:** [September 16, 2019, 8:12pm UTC](https://forum.makecode.com/t/maze-tile-map-navigation-issues/484/13 "2019-09-16T20:12:53Z")

</div>

All three of 'em:

- [Physics Maze UnitTest v1](https://makecode.com/_darVEJaL14E5)
- [Big Ball in Maze](https://makecode.com/_96cFJeUHbRXi) (manual test)
- [Bounce UnitTest v3](https://makecode.com/_a30ca5Thafd3) (inelastic wall bounce test)

---

<div class="post-metadata">

**Author:** ![tballmsft](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/tballmsft/32/332_2.png) [@tballmsft](https://forum.makecode.com/u/tballmsft)\
**Post date:** [September 16, 2019, 8:24pm UTC](https://forum.makecode.com/t/maze-tile-map-navigation-issues/484/14 "2019-09-16T20:24:09Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![kjw](https://avatars.discourse-cdn.com/v4/letter/k/e79b87/32.png) [@kjw](https://forum.makecode.com/u/kjw)\
**Post date:** [January 26, 2020, 6:48pm UTC](https://forum.makecode.com/t/maze-tile-map-navigation-issues/484/15 "2020-01-26T18:48:30Z")

</div>

There’s another diagonal issue now with mazes like this: [GitHub microsoft/pxt-arcade Velocity of sprite is reduced incorrectly for constrained movement on diagonal control #1727](https://github.com/microsoft/pxt-arcade/issues/1727).
