Each new game start different gameplay

Hi,

For my game I have planned to have for each new game start a different gameplay.

So how to achieve that:
All of my game objects have a unique ID which are stored in a class with its position and rotation.

So I will add more to the class.

So know comes my random selection:

def createIds(all_ID):
    for i in range(0, 101):
        all_ID.append(i)
        #print (all_ID, 'all_ID')    
    else:
        pass
    
    return all_ID        


if Sens.positive:
    all_IDs = createIds(all_ID)
    randomObjIds = random.sample(all_IDs,  20)  # Choose 20 elements
    print (randomObjIds)

So I will add only the object which are in the randomObjIds list.

What do you think? Would that be a good idea to do it this way or do you have a better idea?

Thanks in advance

That depends on what you want to do:

  • random content adding
  • random level selection

What you described can be much easier the other way around:
Add all and end all objects you do not want (random ends).

This way you do not need to keep the object data (pos/loc/scale/properties/etc.) separate.

I want to have a random content adding

Add all and end all objects you do not want (random ends)
Yeap that is really a good idea. Thanks a lot for your idea.