# Detecting what the current tilemap is

**URL:** <https://forum.makecode.com/t/detecting-what-the-current-tilemap-is/28249>\
**Category:** Help\
**Created:** [April 15, 2024, 4:31pm UTC](https://forum.makecode.com/t/detecting-what-the-current-tilemap-is/28249 "2024-04-15T16:31:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ethan](https://avatars.discourse-cdn.com/v4/letter/e/8dc957/32.png) [@ethan](https://forum.makecode.com/u/ethan)\
**Post date:** [April 15, 2024, 4:31pm UTC](https://forum.makecode.com/t/detecting-what-the-current-tilemap-is/28249/1 "2024-04-15T16:31:56Z")

</div>

I need help making it so the code knows what the current tilemap is, as in being able to know if the tilemap is currently area 1 so it can spawn the enemies for area 1 and not ones for area 5 and vise versa.

---

<div class="post-metadata">

**Author:** ![Mega0star01](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/mega0star01/32/14784_2.png) [@Mega0star01](https://forum.makecode.com/u/Mega0star01)\
**Post date:** [April 15, 2024, 4:47pm UTC](https://forum.makecode.com/t/detecting-what-the-current-tilemap-is/28249/2 "2024-04-15T16:47:01Z")

</div>

create a variable and set its value to the number of the area, like if you’re in area 1 then the variable’s value is 1.

---

<div class="post-metadata">

**Author:** ![Bifrosty](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/bifrosty/32/24819_2.png) [@Bifrosty](https://forum.makecode.com/u/Bifrosty)\
**Post date:** [April 15, 2024, 9:09pm UTC](https://forum.makecode.com/t/detecting-what-the-current-tilemap-is/28249/3 "2024-04-15T21:09:50Z")

</div>

Hi, this is simple to do and can be accomplished within a few steps.

1.Create both your levels.  
2.Create your enemies and their behavior  
3.Create a variable  
4.Whenever your game loads a level set that variable to the level number.  
5.When spawning your enemies create an if-statement like “If level = 1 then spawn level one enemies} else If level = 2 then spawn level two enemies and so on.

Here is an example I have created—\> [https://arcade.makecode.com/S80349-74461-63526-49199](https://arcade.makecode.com/S80349-74461-63526-49199)  
Click “Edit Code” in the top left corner to see the code. Let me know if any further instruction is needed.

---

<div class="post-metadata">

**Author:** ![ethan](https://avatars.discourse-cdn.com/v4/letter/e/8dc957/32.png) [@ethan](https://forum.makecode.com/u/ethan)\
**Post date:** [April 15, 2024, 9:10pm UTC](https://forum.makecode.com/t/detecting-what-the-current-tilemap-is/28249/4 "2024-04-15T21:10:52Z")

</div>

Can you show me what that would look like?
