• 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!

Create a new list

eams1986

Member
How can I recreate a new list when restarting the game? Note: the object is persistent
I have to restart the game to randomize the objects in this case the Sprites "l_level_"

GML:
My_level = ds_list_create();

//Game
var game_total = 61;
for(var a = 0; a < game_total; a++)
    ds_list_add(My_level,a);
   
randomize();

ds_list_shuffle(My_level);
//ds_list_destroy(My_level);

it is a vk_up key I put this to see if to the random of objects

randomize ();
ds_list_shuffle (My_level);

Thanks
 

FoxyOfJungle

Kazan Games
  1. Create a method to create this list.
  2. Call this function in Room Start event.
Create Event:
GML:
randomize();
My_level = ds_list_create();

create_new_list = function() {
    // Game
    if ds_list_exists(My_level) ds_list_clear(My_level);
    var game_total = 61;
    for (var i = 0; i < game_total; i++) {
        ds_list_add(My_level, i);
    }
    ds_list_shuffle(My_level);
}
Clean Up Event
GML:
ds_list_destroy(My_level);
Room Start Event
GML:
create_new_list();
Importantly, randomize() causes all numbers to be random from the moment it is called, without following a seed.
 
Last edited:
Top