# Overlap issue that we can't figure out!

**URL:** <https://forum.makecode.com/t/overlap-issue-that-we-cant-figure-out/11807>\
**Category:** Help\
**Tags:** game\
**Created:** [January 20, 2022, 10:07pm UTC](https://forum.makecode.com/t/overlap-issue-that-we-cant-figure-out/11807 "2022-01-20T22:07:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gumtowgames](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/gumtowgames/32/6379_2.png) [@gumtowgames](https://forum.makecode.com/u/gumtowgames)\
**Post date:** [January 20, 2022, 10:07pm UTC](https://forum.makecode.com/t/overlap-issue-that-we-cant-figure-out/11807/1 "2022-01-20T22:07:37Z")

</div>

I have a student who is building a game in which you have to move through a level while avoiding a shark. The goal is to get to a trigger for the next level, and if the shark touches you, a life is lost and you both reset to the beginning positions.

The problem is that at the very beginning of the game, before anything happens or the sprites even move, the shark seemingly “glitches” through the tilemap walls and hits the player, harming him, without ever overlapping the player.

Code is below! Any advice would be very appreciated.

[Game Link](https://makecode.com/_aWTRbTeXV8Wg)

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [January 21, 2022, 6:03pm UTC](https://forum.makecode.com/t/overlap-issue-that-we-cant-figure-out/11807/3 "2022-01-21T18:03:13Z")

</div>

The issue is that you are placing your sprites before the tilemap exists:

 ![Screen Shot 2022-01-21 at 10.02.25 AM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/0/01d325ee40e711a917bb27c4a6133dd98f443972.png)

Just move the “set tilemap to” blocks before the “place on top of tile” blocks and you should be all set!

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [January 21, 2022, 7:22pm UTC](https://forum.makecode.com/t/overlap-issue-that-we-cant-figure-out/11807/4 "2022-01-21T19:22:03Z")

</div>

To clarify my answer, the place on top of tile blocks don’t do anything unless a tilemap already exists.

---

<div class="post-metadata">

**Author:** ![gumtowgames](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/gumtowgames/32/6379_2.png) [@gumtowgames](https://forum.makecode.com/u/gumtowgames)\
**Post date:** [January 24, 2022, 2:51pm UTC](https://forum.makecode.com/t/overlap-issue-that-we-cant-figure-out/11807/5 "2022-01-24T14:51:31Z")

</div>

This worked! Thank you! However, when reaching level two, if you get hit once by the shark, he moves through the tilemap and hits repeatedly until game over. I think that is because the mysprite / mysprite 3 overlap places the sprites back to their level 1 position, instead of the new starting positions for level 2. I’m not sure how to correct this. Any ideas?

> **[Avoid the Shark!](https://arcade.makecode.com/52195-89681-21703-42067)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [January 24, 2022, 6:56pm UTC](https://forum.makecode.com/t/overlap-issue-that-we-cant-figure-out/11807/6 "2022-01-24T18:56:31Z")

</div>

Well the easiest way is to use that current level variable you have:

 ![Screen Shot 2022-01-24 at 10.49.21 AM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/4/4871f3acbd47085701cb6d2ad856645cbd43d7fd.png)

Typically, the way I do this sort of thing is to make special tiles that mark where the shark and player should spawn. Then, you can avoid having to hardcode position locations like that. Instead, you can use the “place on top of random tile” block to place the shark and player onto the special tiles you created. Sorta like this:

 ![Screen Shot 2022-01-24 at 10.55.31 AM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/4/4bdfd92eb5393ba445a992f8721a93e340a4e595.png)\

Here’s the code:

> **[Avoid the Shark! (richard's edits)](https://arcade.makecode.com/42384-68986-00116-84921)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [January 24, 2022, 6:56pm UTC](https://forum.makecode.com/t/overlap-issue-that-we-cant-figure-out/11807/7 "2022-01-24T18:56:57Z")

</div>

If you want to hide the special tiles, there is a block for doing that in the tilemaps extension
