# Randomly generated rooms

**URL:** <https://forum.makecode.com/t/randomly-generated-rooms/28234>\
**Category:** Help\
**Created:** [April 14, 2024, 7:39pm UTC](https://forum.makecode.com/t/randomly-generated-rooms/28234 "2024-04-14T19:39:48Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lilvince](https://avatars.discourse-cdn.com/v4/letter/l/e9a140/32.png) [@Lilvince](https://forum.makecode.com/u/Lilvince)\
**Post date:** [April 14, 2024, 7:39pm UTC](https://forum.makecode.com/t/randomly-generated-rooms/28234/1 "2024-04-14T19:39:48Z")

</div>

how would I make rooms randomly generated? (tilemaps) I’m trying to make a B.O.I game (Binding Of Issac) and want randomly generated rooms (not made by the computer, I’m 99% sure that’s impossible in makecode) that are chosen from a specific set of rooms for example: starter room \> left = enemies \> left = shop \> up = item and so on, any ideas?

---

<div class="post-metadata">

**Author:** ![RobbyZero](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/robbyzero/32/17188_2.png) [@RobbyZero](https://forum.makecode.com/u/RobbyZero)\
**Post date:** [April 15, 2024, 5:08am UTC](https://forum.makecode.com/t/randomly-generated-rooms/28234/2 "2024-04-15T05:08:42Z")

</div>

I believe that there is an extension for that. I just could not dig up a link.

---

<div class="post-metadata">

**Author:** ![Awesomefreez](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/awesomefreez/32/24832_2.png) [@Awesomefreez](https://forum.makecode.com/u/Awesomefreez)\
**Post date:** [April 15, 2024, 5:10am UTC](https://forum.makecode.com/t/randomly-generated-rooms/28234/3 "2024-04-15T05:10:10Z")

</div>

I might know use this code: [How to make a sprite random choice system - #2 by richard](https://forum.makecode.com/t/how-to-make-a-sprite-random-choice-system/3726/2)  
but instead of set mysprite do set tilemap to whatever you want it to be and put an if something is touching over the if choice.

---

<div class="post-metadata">

**Author:** ![Brainstorm\_Studios](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/brainstorm_studios/32/20476_2.png) [@Brainstorm\_Studios](https://forum.makecode.com/u/Brainstorm_Studios)\
**Post date:** [April 15, 2024, 4:33pm UTC](https://forum.makecode.com/t/randomly-generated-rooms/28234/4 "2024-04-15T16:33:29Z")

</div>

on tilemap unloaded [tilemap] do

set [roomRNG] to {pick random 1 - (however many rooms you end up making)}

if [roomRNG] = 1 then

set tilemap to (room 1)

else if [roomRNG] = 2 then

set tilemap to (room 2)

repeat the else if prompt for however many rooms you want to generate in the game. make 1 room have an exit so that you can move on to the next level. how you save these rooms, however, im not really sure.

---

<div class="post-metadata">

**Author:** ![soren\_lorenson](https://avatars.discourse-cdn.com/v4/letter/s/f14d63/32.png) [@soren\_lorenson](https://forum.makecode.com/u/soren_lorenson)\
**Post date:** [April 15, 2024, 4:45pm UTC](https://forum.makecode.com/t/randomly-generated-rooms/28234/5 "2024-04-15T16:45:36Z")

</div>

I think there was a stream game on this, I remember watching a stream where they were using randomly generated platformer tiles

---

<div class="post-metadata">

**Author:** ![Awesomefreez](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/awesomefreez/32/24832_2.png) [@Awesomefreez](https://forum.makecode.com/u/Awesomefreez)\
**Post date:** [April 15, 2024, 9:09pm UTC](https://forum.makecode.com/t/randomly-generated-rooms/28234/6 "2024-04-15T21:09:10Z")

</div>

Your answer is basically my answer but 10 times better.

---

<div class="post-metadata">

**Author:** ![Luke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/luke/32/32519_2.png) [@Luke](https://forum.makecode.com/u/Luke)\
**Post date:** [April 15, 2024, 9:11pm UTC](https://forum.makecode.com/t/randomly-generated-rooms/28234/7 "2024-04-15T21:11:50Z")

</div>

You can use arrays to store data

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/4/415e68e5b1d039b73b75681eb57ff75af8894b87.png)  
ArrayRoomTilemaps stores the tilemaps that you want to randomly choose  
ArrayRoomNames stores their respective names  
ArrayRooms stores the dungeon layout. This array can be added to with ArrayRoomNames to add more rooms.  
On A pressed adds a room to array  
On B simplifies how the player position would be tracked so that the array of rooms could be referenced whith the ArrayPicker variable.

One disadvantage with this is that it can only store a single line of rooms, idk how 2 dimensional room layouts could be stored and accessed easily.

> **Fun fact**
>
> I actually used arrays in a similar way to store the current card hand, draw pile, discard pile, card inventory and map events for Card Delver

---

<div class="post-metadata">

**Author:** ![Lilvince](https://avatars.discourse-cdn.com/v4/letter/l/e9a140/32.png) [@Lilvince](https://forum.makecode.com/u/Lilvince)\
**Post date:** [April 20, 2024, 3:59pm UTC](https://forum.makecode.com/t/randomly-generated-rooms/28234/8 "2024-04-20T15:59:49Z")

</div>

any ideas for being able to make just a few tiles of a tilemap change? (without using like 50 different ones)

---

<div class="post-metadata">

**Author:** ![Luke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/luke/32/32519_2.png) [@Luke](https://forum.makecode.com/u/Luke)\
**Post date:** [April 21, 2024, 12:24am UTC](https://forum.makecode.com/t/randomly-generated-rooms/28234/9 "2024-04-21T00:24:06Z")

</div>

Something like this maybe

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

---

<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:** [April 21, 2024, 12:24am UTC](https://forum.makecode.com/t/randomly-generated-rooms/28234/10 "2024-04-21T00:24:16Z")

</div>

Randomly adding tiles? If you used a seed to generate the random numbers, a different one for every room, then if you went back to the room you were in before the room would be the same. This would stop you from having to save every random room.

---

<div class="post-metadata">

**Author:** ![Lilvince](https://avatars.discourse-cdn.com/v4/letter/l/e9a140/32.png) [@Lilvince](https://forum.makecode.com/u/Lilvince)\
**Post date:** [April 21, 2024, 2:49am UTC](https://forum.makecode.com/t/randomly-generated-rooms/28234/11 "2024-04-21T02:49:34Z")

</div>

no, that wouldn’t work because I want a few of the blocks to stay the same but for the room to be completely randomly generated

---

<div class="post-metadata">

**Author:** ![Lilvince](https://avatars.discourse-cdn.com/v4/letter/l/e9a140/32.png) [@Lilvince](https://forum.makecode.com/u/Lilvince)\
**Post date:** [April 21, 2024, 2:49am UTC](https://forum.makecode.com/t/randomly-generated-rooms/28234/12 "2024-04-21T02:49:38Z")

</div>

how would I do this? please show an example if you can because i’m not sure

---

<div class="post-metadata">

**Author:** ![Luke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/luke/32/32519_2.png) [@Luke](https://forum.makecode.com/u/Luke)\
**Post date:** [April 21, 2024, 2:49am UTC](https://forum.makecode.com/t/randomly-generated-rooms/28234/13 "2024-04-21T02:49:49Z")

</div>

Yeah using the RNG extension would be useful

---

<div class="post-metadata">

**Author:** ![Lilvince](https://avatars.discourse-cdn.com/v4/letter/l/e9a140/32.png) [@Lilvince](https://forum.makecode.com/u/Lilvince)\
**Post date:** [April 21, 2024, 3:35am UTC](https://forum.makecode.com/t/randomly-generated-rooms/28234/14 "2024-04-21T03:35:17Z")

</div>

where can I find the rng extension?

---

<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:** [April 21, 2024, 4:34pm UTC](https://forum.makecode.com/t/randomly-generated-rooms/28234/15 "2024-04-21T16:34:16Z")

</div>

[Here](https://forum.makecode.com/t/procedural-generation/5383).  
My idea was to have a way of randomly generating rooms, like a function that added, say, a chest, picking a random tile in the room using the non-random seed thing, so the chest would be in the same place every time you used the same seed number. Then you could have many other elements that could be added. Then maybe every room has a sort of “X” and “y” to it so when you leave to the right the “X” goes up, down if you leave to the left, and “y” does the same but with up and down. Then, when you enter a room, you could maybe multiply them together or something to get the seed that would make that room.

---

<div class="post-metadata">

**Author:** ![Lilvince](https://avatars.discourse-cdn.com/v4/letter/l/e9a140/32.png) [@Lilvince](https://forum.makecode.com/u/Lilvince)\
**Post date:** [April 21, 2024, 11:26pm UTC](https://forum.makecode.com/t/randomly-generated-rooms/28234/16 "2024-04-21T23:26:52Z")

</div>

issue, I am using raycast and want the walls to change 😅

---

<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:** [April 22, 2024, 4:45pm UTC](https://forum.makecode.com/t/randomly-generated-rooms/28234/17 "2024-04-22T16:45:40Z")

</div>

I think someone smarter might have to help you with that 😅

---

<div class="post-metadata">

**Author:** ![Lilvince](https://avatars.discourse-cdn.com/v4/letter/l/e9a140/32.png) [@Lilvince](https://forum.makecode.com/u/Lilvince)\
**Post date:** [April 22, 2024, 11:15pm UTC](https://forum.makecode.com/t/randomly-generated-rooms/28234/18 "2024-04-22T23:15:10Z")

</div>

alr ty

---

<div class="post-metadata">

**Author:** ![Sunny1](https://avatars.discourse-cdn.com/v4/letter/s/c0e974/32.png) [@Sunny1](https://forum.makecode.com/u/Sunny1)\
**Post date:** [August 13, 2024, 1:44am UTC](https://forum.makecode.com/t/randomly-generated-rooms/28234/19 "2024-08-13T01:44:36Z")

</div>

hello I’m trying to make the roblox game rooms but in Makecode can someone tell me how to make the rooms randomly generated?

---

<div class="post-metadata">

**Author:** ![PaleWriter](https://avatars.discourse-cdn.com/v4/letter/p/db5fbb/32.png) [@PaleWriter](https://forum.makecode.com/u/PaleWriter)\
**Post date:** [December 18, 2024, 6:00pm UTC](https://forum.makecode.com/t/randomly-generated-rooms/28234/20 "2024-12-18T18:00:03Z")

</div>

could you add a link to that project? i’ll need it for a game, but are too dumb to figure out how to code that.

[Next page](https://forum.makecode.com/t/randomly-generated-rooms/28234.md?page=2)
