• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker go to a random room without doing it twice

T

Tom Radziwill

Guest
Hey,
I am new to the GM community and I am doing good with learning the GML and all the tools. :)

But right now I stuck with - it seems - a simple task. I want the player to go to a random room but never go there again after he went there (until the player restart the game). There will be around 100 rooms to choose from.

It seems so simple, but I can't figure it out...

I need something like a list where I can delete the rooms after going there, right? Any ideas?

Best regards,
Tom
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
I need something like a list where I can delete the rooms after going there, right? Any ideas?
You have the answer within your grasp...!

Look at using a globally assigned DS List - add all the rooms at game start, shuffle the list, pick the first one to go to then delete it from the list.... then go to the next one and delete it form the list and continue doing this until the list is empty or the player dies (at which point you would delete the list and re-create it following all the steps given again).

:)
 
T

Tom Radziwill

Guest
Thank you very much Nocturne!
Could you give me an example on how to store the rooms in the list and how to execute the "goto" command?

qlist = ds_list_create();
var qroom;
qroom[0] = rm_q1;
qroom[1] = rm_q2;
qroom[2] = rm_q3;
qroom[3] = rm_q4;
ds_list_shuffle(qlist);

Now I would like to execute a room_goto(); command and insert one of the qroom[ x ] values starting from 0 to 3, right? How can I read the values from a ds_list? Sorry, it's the first time I work with ds_lists...

Best regards,
Tom
 

TheouAegis

Member
If it's 100+ rooms, make your life easier. Put them all together; orderdoesn't matter, just make sure no other rooms are mixed in with them. Then just add them with a loop.

room_list=ds_list_create();
var i=0;
repeat 100 room_list[|i]=first_room+i;

Replace first_room with the ID of the first room in the set.

Only works in Studio.
 
Top