I'm attempting to write a code in which the user can add as many of a certain object as needed, and blit it on to a pygame window. Essentially a game engine of sorts. I need to make it so that they can add as many of these objects as they need, so that they can create a game world. The only problem I'm encountering is that I cannot create enough names for all of this by hard-coding it, and even then it would not be enough. So is there a way for me to make it so that they can name each class, or so that it would be procedurally generated names for each class? Here is my class:

##My Class
class objectMesh():
    def __init__(self, objectType, color, width, dimensions):   ##Send dimensions depending on what is required for each pygame.draw command. Polygons are
        self.objectType, self.color, self.width, self.dimensions = objectType, color, width, dimensions ##list of vertices, circles are center + radius, etc.
    def drawObject(self):
        if self.objectType == 0:
            drawRect(self.dimensions, self.color, self.width)

The only problem I'm encountering is that I cannot create enough names for all of this by hard-coding it

I'm not sure I understand this question very well. It seems to me that you want to create many instances of a certain class but you don't want to create a variable name for each instance. The solution is to store the instances in one of the many container classes that come with python: list, set, dict, deque, etc.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.