# Level changes and backtracking

**URL:** <https://forum.makecode.com/t/level-changes-and-backtracking/17575>\
**Category:** Help\
**Tags:** game\
**Created:** [January 24, 2023, 7:24pm UTC](https://forum.makecode.com/t/level-changes-and-backtracking/17575 "2023-01-24T19:24:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lrigby22](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/lrigby22/32/7367_2.png) [@Lrigby22](https://forum.makecode.com/u/Lrigby22)\
**Post date:** [January 24, 2023, 7:24pm UTC](https://forum.makecode.com/t/level-changes-and-backtracking/17575/1 "2023-01-24T19:24:04Z")

</div>

Hello all,  
I’m making a top-down arcade game based within different levels of a building.  
I can code it to change levels however is there a way to code it so I can **return to a previous level**? (i.e. Ground floor to First floor and back to Ground floor again?).  
I realise I can duplicate the tilemap for multiple options but that seems like a lot of duplicates and was wondering if there was an easier way to backtrack to levels?  
Thanks in advance!

---

<div class="post-metadata">

**Author:** ![TheConeGuy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/theconeguy/32/13840_2.png) [@TheConeGuy](https://forum.makecode.com/u/TheConeGuy)\
**Post date:** [January 24, 2023, 9:08pm UTC](https://forum.makecode.com/t/level-changes-and-backtracking/17575/2 "2023-01-24T21:08:16Z")

</div>

This might not help but-

Maybe you can use a setting that uses a variable to keep track of what level you’re one? I don’t have a picture for this, but you can do something like “if the variable currentLevel (what you could use) is a certain value, than that’s the level you’re on.”  
So if you’re on one level, and you want to go back, just make a tile and then make some code for it that decreases the “currentLevel” variable. I hope this helps.

---

<div class="post-metadata">

**Author:** ![Lrigby22](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/lrigby22/32/7367_2.png) [@Lrigby22](https://forum.makecode.com/u/Lrigby22)\
**Post date:** [January 26, 2023, 6:11pm UTC](https://forum.makecode.com/t/level-changes-and-backtracking/17575/3 "2023-01-26T18:11:05Z")

</div>

@TheConeGuy - This actually did help! I made a new variable changing the level by -1 - which I ran through a new function I called “returnLevel” and so far it seems to be working! Thanks!

---

<div class="post-metadata">

**Author:** ![TheConeGuy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/theconeguy/32/13840_2.png) [@TheConeGuy](https://forum.makecode.com/u/TheConeGuy)\
**Post date:** [January 26, 2023, 6:14pm UTC](https://forum.makecode.com/t/level-changes-and-backtracking/17575/4 "2023-01-26T18:14:27Z")

</div>

No problem! I’m glad it helped.  
Have a nice day! 😄
