I am writing a game. Its structure looks like this - Diagram .
Now, I have a map in another class called World(Basically an array of organisms), where I want to spawn n random organisms.
I know that I could do rand() % subclassesCount and do if/switch statements, but what if I had 1000 types of animals and plants? Would I have to specify them all in my code? Is there an easier way of doing this?
Aucun commentaire:
Enregistrer un commentaire