Randomly generated rooms

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?

2 Likes

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

I might know use this code: How to make a sprite random choice system - #2 by richard
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.

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.

1 Like

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

1 Like

Your answer is basically my answer but 10 times better.

You can use arrays to store data


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

1 Like

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

1 Like

Something like this maybe

2 Likes

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.

1 Like

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

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

Yeah using the RNG extension would be useful

where can I find the rng extension?

1 Like

Here.
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.

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

1 Like

I think someone smarter might have to help you with that :sweat_smile:

alr ty

1 Like

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

1 Like

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.

1 Like