# How do I make a turn based game?

**URL:** <https://forum.makecode.com/t/how-do-i-make-a-turn-based-game/31126>\
**Category:** Help\
**Tags:** game\
**Created:** [October 11, 2024, 8:43pm UTC](https://forum.makecode.com/t/how-do-i-make-a-turn-based-game/31126 "2024-10-11T20:43:40Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Qaceacewace](https://avatars.discourse-cdn.com/v4/letter/q/c37758/32.png) [@Qaceacewace](https://forum.makecode.com/u/Qaceacewace)\
**Post date:** [October 11, 2024, 8:43pm UTC](https://forum.makecode.com/t/how-do-i-make-a-turn-based-game/31126/1 "2024-10-11T20:43:40Z")

</div>

> **[Snowland Highlands V0.6](https://arcade.makecode.com/S44911-98659-50956-42571)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![ADM\_F](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/adm_f/32/19808_2.png) [@ADM\_F](https://forum.makecode.com/u/ADM_F)\
**Post date:** [October 11, 2024, 11:30pm UTC](https://forum.makecode.com/t/how-do-i-make-a-turn-based-game/31126/2 "2024-10-11T23:30:02Z")

</div>

Its. . .  
Quite the pain

ive [made one](https://arcade.makecode.com/34114-26432-86422-75662) but its so bloated i cant edit it anymore but i did learn some things

id start by making a function or using [This Extension](https://github.com/riknoll/arcade-state-transitions)  
that when your “turn/All actions” are over runs Does all of the enemys Attacks/Actions then allows you to control your player again

> **[Turnbasied thingy](https://arcade.makecode.com/S21972-18226-69534-67316)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

Here is a small basic example I made

---

<div class="post-metadata">

**Author:** ![Qaceacewace](https://avatars.discourse-cdn.com/v4/letter/q/c37758/32.png) [@Qaceacewace](https://forum.makecode.com/u/Qaceacewace)\
**Post date:** [October 14, 2024, 2:17am UTC](https://forum.makecode.com/t/how-do-i-make-a-turn-based-game/31126/3 "2024-10-14T02:17:37Z")

</div>

Thanks, however; do you know Battle Brothers? If not, look it up and see the combat system. I want something like that.

---

<div class="post-metadata">

**Author:** ![ADM\_F](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/adm_f/32/19808_2.png) [@ADM\_F](https://forum.makecode.com/u/ADM_F)\
**Post date:** [October 15, 2024, 6:09pm UTC](https://forum.makecode.com/t/how-do-i-make-a-turn-based-game/31126/4 "2024-10-15T18:09:01Z")

</div>

> [@Qaceacewace](#):
>
> Battle Brothers?

Kinda looks like advanced wars/ Fire emblem

well the Knighted link i sent was basied off of Baldur’s Gate 3 But with some modding could be similar

> **[Knighted! WonderFul World](https://arcade.makecode.com/34114-26432-86422-75662)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

Press A to get through the “Menu”

feel free to take anycode you see

and if you have anymore questions or need more help @ me

---

<div class="post-metadata">

**Author:** ![Qaceacewace](https://avatars.discourse-cdn.com/v4/letter/q/c37758/32.png) [@Qaceacewace](https://forum.makecode.com/u/Qaceacewace)\
**Post date:** [October 17, 2024, 9:42pm UTC](https://forum.makecode.com/t/how-do-i-make-a-turn-based-game/31126/5 "2024-10-17T21:42:04Z")

</div>

1. I can’t Gmail due to being on a school Chromebook, which you now know. Since you will likely respond, the school will likely block it.
2. You won’t know what my account is like if I make a new one.

I tried to do something where you have several actions = how far you can see you can move.  
The blue tiles are highlighted, which indicates how far you can move. However, I think they’re below the green tiles, if at all.

> **[Tile Test - 1](https://arcade.makecode.com/S79109-48413-80605-30846)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![Qaceacewace](https://avatars.discourse-cdn.com/v4/letter/q/c37758/32.png) [@Qaceacewace](https://forum.makecode.com/u/Qaceacewace)\
**Post date:** [October 17, 2024, 9:42pm UTC](https://forum.makecode.com/t/how-do-i-make-a-turn-based-game/31126/6 "2024-10-17T21:42:55Z")

</div>

The game is buggy with after moving 6 times against enemy, the game is stuck nothing happenes.

---

<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:** [October 17, 2024, 10:08pm UTC](https://forum.makecode.com/t/how-do-i-make-a-turn-based-game/31126/7 "2024-10-17T22:08:30Z")

</div>

oh man, lucky for you tactics games are pretty much my favorite genre!

typically the way you determine movement ranges in grid-based tactics games is by implementing an algorithm called [breadth-first search](https://en.wikipedia.org/wiki/Breadth-first_search) (BFS). BFS is pretty tough to code in blocks; i think we did it on stream once or twice and it was a huge pain.

anyways, looking at your code i see a few issues.

firstly, inside the on game update it looks like you’re trying to make the tiles around the player turn blue:

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/b/3/b3c7ae60e058c02e577508f0a0cf26d7fd5a6def.png)

this code won’t work because you’re passing the sprite’s x and y for the column and row. this function is expecting column and row to be in tile units, while the x and y of the sprite are in pixel units. each tile in your game is 16x16 pixels, so if you wanted to convert the x and y of the sprite into tile coordinates then you would need to divide them by 16.

luckily, there’s an easier way to do this! inside the Scene category, there is a block that gets the tilemap location of a sprite:

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/9/c/9c19067502105e84656c2ea21ff3e20bd6718440.png)

to get the surrounding tiles, you can also use this block in the Scene category:

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/f/c/fcbc446c64a051a99091c6acc6d1a0a106da74a8.png)

using these two blocks, we can rewrite your code like this:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/e/5/e55df331728d398e3324bec3b2650e83b0ce5c0b.png)

---

<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:** [October 17, 2024, 10:18pm UTC](https://forum.makecode.com/t/how-do-i-make-a-turn-based-game/31126/8 "2024-10-17T22:18:40Z")

</div>

next it looks like you’re setting these tiles inside of an on game update. instead of doing that, i think you might find it easier if you only do it when the sprite actually moves.

to illustrate that, let’s create a function that we can call every time we move that will highlight/unhighlight tiles based on how many actions are left:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/2/0/20b7df959df62c06d82eac142ad2a9369c797f73.png)

the “replace all \_\_\_ tiles with \_\_\_” block comes from the arcade-tile-util extension. you can add it to your project using the “Extensions” category.

now that we have this function, we’re going to call it in two places: on-start and inside of that action=0 function you defined:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/9/1/91b02a0deab8d7778468374e5e57d4ec70097d81.png)

and with that, the tiles should automatically change whenever you move!

---

<div class="post-metadata">

**Author:** ![Qaceacewace](https://avatars.discourse-cdn.com/v4/letter/q/c37758/32.png) [@Qaceacewace](https://forum.makecode.com/u/Qaceacewace)\
**Post date:** [October 17, 2024, 10:48pm UTC](https://forum.makecode.com/t/how-do-i-make-a-turn-based-game/31126/9 "2024-10-17T22:48:26Z")

</div>

Thanks

---

<div class="post-metadata">

**Author:** ![labfox29](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/labfox29/32/9252_2.png) [@labfox29](https://forum.makecode.com/u/labfox29)\
**Post date:** [October 18, 2024, 2:34am UTC](https://forum.makecode.com/t/how-do-i-make-a-turn-based-game/31126/10 "2024-10-18T02:34:09Z")

</div>

I made something like this but mor like Undertale/Deltarune [RPG Engine](https://forum.makecode.com/t/rpg-engine/26349)

---

<div class="post-metadata">

**Author:** ![ADM\_F](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/adm_f/32/19808_2.png) [@ADM\_F](https://forum.makecode.com/u/ADM_F)\
**Post date:** [October 18, 2024, 2:35am UTC](https://forum.makecode.com/t/how-do-i-make-a-turn-based-game/31126/11 "2024-10-18T02:35:30Z")

</div>

@Qaceacewace Yea i know about that bug you just have to use ALL your actions for each charecter you use menu (Or ~)to swap between them its kinda a dead game but it was a goodish turn based game till it exploded

Also i think Richard already fixed all your main issues

He stole my thunder ):  
Richard is still going to have a better idea plan and execution then me anyways

But if you have any OTHER questions down the line, ask Hopefully i can beat Richard to it!

Im pretty sure about 75% of people here just use there school computers Shared part of any makecoders life, I guess

---

<div class="post-metadata">

**Author:** ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)\
**Post date:** [October 18, 2024, 4:43pm UTC](https://forum.makecode.com/t/how-do-i-make-a-turn-based-game/31126/12 "2024-10-18T16:43:22Z")

</div>

@ADM_F  
YOOO the one you made is so cool! Mind if I try to get it working?

---

<div class="post-metadata">

**Author:** ![Qaceacewace](https://avatars.discourse-cdn.com/v4/letter/q/c37758/32.png) [@Qaceacewace](https://forum.makecode.com/u/Qaceacewace)\
**Post date:** [October 18, 2024, 4:51pm UTC](https://forum.makecode.com/t/how-do-i-make-a-turn-based-game/31126/13 "2024-10-18T16:51:52Z")

</div>

How do I increase the Field of View so the characters can see more?

---

<div class="post-metadata">

**Author:** ![Qaceacewace](https://avatars.discourse-cdn.com/v4/letter/q/c37758/32.png) [@Qaceacewace](https://forum.makecode.com/u/Qaceacewace)\
**Post date:** [October 18, 2024, 6:07pm UTC](https://forum.makecode.com/t/how-do-i-make-a-turn-based-game/31126/14 "2024-10-18T18:07:13Z")

</div>

You can try sure.

---

<div class="post-metadata">

**Author:** ![ADM\_F](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/adm_f/32/19808_2.png) [@ADM\_F](https://forum.makecode.com/u/ADM_F)\
**Post date:** [October 18, 2024, 6:08pm UTC](https://forum.makecode.com/t/how-do-i-make-a-turn-based-game/31126/15 "2024-10-18T18:08:56Z")

</div>

Knock Yourself out i have a updated version somewhere [here](https://forum.makecode.com/t/the-adm-f-makecade/27695)

---

<div class="post-metadata">

**Author:** ![Qaceacewace](https://avatars.discourse-cdn.com/v4/letter/q/c37758/32.png) [@Qaceacewace](https://forum.makecode.com/u/Qaceacewace)\
**Post date:** [October 20, 2024, 4:52pm UTC](https://forum.makecode.com/t/how-do-i-make-a-turn-based-game/31126/16 "2024-10-20T16:52:26Z")

</div>

How do I increase the Field of view so the people who play can see more?

---

<div class="post-metadata">

**Author:** ![Qaceacewace](https://avatars.discourse-cdn.com/v4/letter/q/c37758/32.png) [@Qaceacewace](https://forum.makecode.com/u/Qaceacewace)\
**Post date:** [October 21, 2024, 5:34pm UTC](https://forum.makecode.com/t/how-do-i-make-a-turn-based-game/31126/17 "2024-10-21T17:34:47Z")

</div>

Ok then, I’ma revamp the game if no one gonna help me.

---

<div class="post-metadata">

**Author:** ![Qaceacewace](https://avatars.discourse-cdn.com/v4/letter/q/c37758/32.png) [@Qaceacewace](https://forum.makecode.com/u/Qaceacewace)\
**Post date:** [October 21, 2024, 5:52pm UTC](https://forum.makecode.com/t/how-do-i-make-a-turn-based-game/31126/18 "2024-10-21T17:52:08Z")

</div>

You forced me to revamp it fully.

---

<div class="post-metadata">

**Author:** ![Qaceacewace](https://avatars.discourse-cdn.com/v4/letter/q/c37758/32.png) [@Qaceacewace](https://forum.makecode.com/u/Qaceacewace)\
**Post date:** [October 21, 2024, 5:52pm UTC](https://forum.makecode.com/t/how-do-i-make-a-turn-based-game/31126/19 "2024-10-21T17:52:09Z")

</div>

Sorry about this but I’m angry VERY angry.

---

<div class="post-metadata">

**Author:** ![ADM\_F](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/adm_f/32/19808_2.png) [@ADM\_F](https://forum.makecode.com/u/ADM_F)\
**Post date:** [October 21, 2024, 6:05pm UTC](https://forum.makecode.com/t/how-do-i-make-a-turn-based-game/31126/20 "2024-10-21T18:05:39Z")

</div>

Ok so First  
Field of view?  
short answer you cant! not without a lot of code spaghetti  
you can change the Screen size but that’s permanent  
and you could also use [This extension](https://forum.makecode.com/t/zoom-extension/13745) + Screen size code to Fake a zoom in/out But ive used it before and its bad

Second  
Ive had a lot of personal work to do i am failing 2 of my classes right now and need to get them fixed so i’m sorry i haven’t be able to help you as i said

Third  
The fact that this topic has been so active is insane  
normally An Arcade|Help Topic dies or gets 2-3 replise with the problem stated in the main topic fixed or a link to another topic giveing the same answer or third they get ignored completely (mostly microbit stuff)

nobody here forced you to do anything  
and with minimal Searching you can normally find answers to your problems  
im sorry you feel this way and i hope your problems are fixed

[Next page](https://forum.makecode.com/t/how-do-i-make-a-turn-based-game/31126.md?page=2)
