# MakeCode Arcade Explorer Help

**URL:** <https://forum.makecode.com/t/makecode-arcade-explorer-help/28348>\
**Category:** Help\
**Created:** [April 21, 2024, 2:52am UTC](https://forum.makecode.com/t/makecode-arcade-explorer-help/28348 "2024-04-21T02:52:11Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mastermind](https://avatars.discourse-cdn.com/v4/letter/m/ecae2f/32.png) [@Mastermind](https://forum.makecode.com/u/Mastermind)\
**Post date:** [April 21, 2024, 2:52am UTC](https://forum.makecode.com/t/makecode-arcade-explorer-help/28348/1 "2024-04-21T02:52:11Z")

</div>

I’m new to MakeCode Arcade and I don’t really know how the explorer works. I want to use it so I can have two code files in one project and be able to switch between them. Is that possible and can someone explain how the file explorer works?  
Thanks

---

<div class="post-metadata">

**Author:** ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)\
**Post date:** [April 21, 2024, 3:02am UTC](https://forum.makecode.com/t/makecode-arcade-explorer-help/28348/2 "2024-04-21T03:02:02Z")

</div>

Welcome, @Mastermind !

For those of you who are unfamiliar with what @Mastermind is describing, the explorer in MakeCode appears below the simulator when you switch from Blocks to a typing language (_i.e._, JavaScript or Python).

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/7/7a7468f12b69e45676cd7a8dde001da97a2e1502.png)

The explorer shows all of the files that are included in your project, including any extensions that you’ve added to your project. It also gives you the ability to update and remove extensions, which you can’t do in Blocks.

The explorer also allows you to add code files to your project if you want to split your code into multiple files, rather than having all of your code in a single file. It helps to organize your code a bit more when your projects become really complex.

@Mastermind, splitting your code into multiple files _does not_ allow you to turn code “on” and “off.” It’s just a way of organizing your code. In the next two posts, I’ll show you two different ways to turn code “on” and “off.” It depends a little bit on what you’re asking, whether you’re asking to disable code completely or if you want to disable and enable some code in the middle of a game.

---

<div class="post-metadata">

**Author:** ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)\
**Post date:** [April 21, 2024, 3:12am UTC](https://forum.makecode.com/t/makecode-arcade-explorer-help/28348/3 "2024-04-21T03:12:33Z")

</div>

Now, if you want to disable sections of code _completely_, you can do that … whether your code is in a single file or in multiple files.

In JavaScript, use the block comment markers, `/*` and `*/`. Here is an example:

```javascript
// The following code will run.
let mySprite: Sprite = sprites.create(img`.`, SpriteKind.Player)
mySprite.x = 50
mySprite.y = 50

// The following code will not run.
/*
for (let x: number = 0; x < 100; x++) {
    game.splash("x = " + x)
}
*/

```

In Python, use triple-quotes to disable code. Here is the same example in Python:

```python
my_sprite: Sprite = sprites.create(img("""."""), SpriteKind.player)
my_sprite.x = 50
my_sprite.y = 50

# The following code will not run.
"""
for x in range(100):
    game.splash("x = " + str(x))
"""

```

---

<div class="post-metadata">

**Author:** ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)\
**Post date:** [April 21, 2024, 3:34am UTC](https://forum.makecode.com/t/makecode-arcade-explorer-help/28348/4 "2024-04-21T03:34:00Z")

</div>

If, instead, you want to disable blocks of code “on demand,” then the easiest way to do that is to put the blocks of code into functions, and then just call those different functions when you want the code to run. It doesn’t work for all code, but it does for a lot of it!

You could do this if you have several mini games and want to switch among them.

For example:

**game1.js**

```javascript
function startGame1() {
    // Put your main game code for Game 1 here.
    let heroSprite: Sprite = sprites.create(assets.image`duck`, SpriteKind.Player)
    heroSprite.setFlag(SpriteFlag.StayInScreen, true)
    controller.moveSprite(heroSprite, 25, 25)
    game.onUpdateInterval(3000, createFood)
    sprites.onOverlap(SpriteKind.Player, SpriteKind.Enemy, onOverlapPlayerEnemy)
    sprites.onOverlap(SpriteKind.Player, SpriteKind.Food, onOverlapPlayerFood)
    info.setScore(0)
    info.setLife(3)
    info.startCountdown(120)
}

function endGame1() {
    heroSprite.destroy()
    heroSprite = null
    for (let e of sprites.allOfKind(SpriteKind.Enemy)) {
        e.destroy()
    }
    for (let f of sprites.allOfKind(SpriteKind.Food)) {
        f.destroy()
    }
}

```

Notice the `endGame1()` function. You’ll want to clean up the screen and destroy any existing sprites before switching games.

You’d do something similar for each of your mini games.

Then, in **main.ts** , you could do something like this:

**main.ts**

```javascript
const SWITCH_GAMES_TIME_MINUTES = 5
const SWITCH_GAMES_TIME_MILLISECONDS = SWITCH_GAMES_TIME_MINUTES * 60 * 1000

startGame1()
// Get the "game time" when we start the game.
let timeStart: number = game.runtime()

game.onUpdate(function() {
    if (game.runtime() - timeStart > SWITCH_GAMES_TIME_MILLISECONDS) {
        endGame1()
        startGame2()
    }
})

```

This is just one way to have multiple games stored in one project with the ability to switch from one to another. There are other ways to accomplish something similar.

Feel free to ask any other questions that you may have!

---

<div class="post-metadata">

**Author:** ![Mastermind](https://avatars.discourse-cdn.com/v4/letter/m/ecae2f/32.png) [@Mastermind](https://forum.makecode.com/u/Mastermind)\
**Post date:** [April 21, 2024, 3:35am UTC](https://forum.makecode.com/t/makecode-arcade-explorer-help/28348/5 "2024-04-21T03:35:15Z")

</div>

Thanks for the response!  
I guess I should have been a little bit more specific. I’m mainly confused about how to access code in a file other than main.py. For example, if I have a function defined in a second file, is there a way to access it from the main file? Or is there a way to select which file to run at a certain time?

In the end, I want to have two separate files, each containing a different game, and allowing the user to select which game they would like to play and then run that file.

---

<div class="post-metadata">

**Author:** ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)\
**Post date:** [April 21, 2024, 3:37am UTC](https://forum.makecode.com/t/makecode-arcade-explorer-help/28348/6 "2024-04-21T03:37:49Z")

</div>

Here’s an example for the JavaScripters out there:

> **[Game Choice JS](https://arcade.makecode.com/31672-49115-53770-19308)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

Here’s the start of a similar project in Python:

> **[Game Choice Python](https://arcade.makecode.com/45695-36140-62045-67690)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

It’s late and Python is being finicky. I’ll try again tomorrow when I’m less sleepy. 😄

---

<div class="post-metadata">

**Author:** ![Mastermind](https://avatars.discourse-cdn.com/v4/letter/m/ecae2f/32.png) [@Mastermind](https://forum.makecode.com/u/Mastermind)\
**Post date:** [April 22, 2024, 4:53am UTC](https://forum.makecode.com/t/makecode-arcade-explorer-help/28348/7 "2024-04-22T04:53:17Z")

</div>

Thank you for all your effort!  
I think my confusion might be coming from trying to use Python. Does MakeCode Arcade just have less Python support?

---

<div class="post-metadata">

**Author:** ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)\
**Post date:** [April 22, 2024, 4:58am UTC](https://forum.makecode.com/t/makecode-arcade-explorer-help/28348/8 "2024-04-22T04:58:45Z")

</div>

Python is the second language that was implemented in the MakeCode editors, and some of the complex items are not yet implemented.

I’m going to create some new threads on Monday to ask some questions of the developers. You’ll see links to those new threads here. I’ll be back when I can get more information and put a response together. Thanks for your patience, @Mastermind !

---

<div class="post-metadata">

**Author:** ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)\
**Post date:** [April 24, 2024, 1:54am UTC](https://forum.makecode.com/t/makecode-arcade-explorer-help/28348/9 "2024-04-24T01:54:33Z")

</div>

OK; let’s try this again. 😆

Here’s an example for the JavaScripters out there:

> **[Game Choice JS](https://arcade.makecode.com/31672-49115-53770-19308)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

And here’s an example for the Pythoners:

> **[Game Choice Python](https://arcade.makecode.com/79128-20027-91955-97587)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

Multi-file projects are not yet working in Python, so all of your code needs to go in the **main.py** file for the time being. When you’re developing multiple games, though, you could create extra files to move your code “out of the way” so that you can focus your attention on just one of the games. The Python code in those extra files will be disabled and will not run. (Again, this is how it works now. Future versions of MakeCode Arcade may work differently.)

@Mastermind , be sure to ask any questions that you still have. Thanks again for your patience!

---

<div class="post-metadata">

**Author:** ![Mastermind](https://avatars.discourse-cdn.com/v4/letter/m/ecae2f/32.png) [@Mastermind](https://forum.makecode.com/u/Mastermind)\
**Post date:** [April 26, 2024, 3:41pm UTC](https://forum.makecode.com/t/makecode-arcade-explorer-help/28348/10 "2024-04-26T15:41:47Z")

</div>

Ok, sounds good. Thanks for all the help!
