I work on a project for my baccalaureat. And that is ,unfortunately for me, the most complicated part of the program.

In my alchemy program I will create a library for store my elements and after, make my combinations ...I have already my surfaces and my dragable's pictures. My pictures are already in my library but I have only the quantity necessary of images to make only one combination. I would like to be able to make hundreds of them ! So, I need to to create news dragables copy has each time I select an element. Like a "palett". And I would like to apply this function for each new element created.

If you can halp me to make that and explain steps to me it will be beautiful !!!

def event_loop(self): for ev in pg.event.get(): if ev.type==pg.QUIT or (ev.type==pg.KEYDOWN and ev.key==pg.K_ESCAPE): self.done = True

for Ele in self.elements: Ele.events(ev)

def update(self): self.Screen.fill(0) self.Screen.blit(self.bg,(0,0)) [Ele.update(self.Screen) for Ele in self.elements if not Ele.selected] [Ele.update(self.Screen) for Ele in self.elements if Ele.selected]

If you look back at the original post and at the first snippet I wrote it really should be the exact same.

You need a new class; call it PalletItem or whatever. The class must have a rect, an image, and as we are writing it a kind. It will also need a function to handle events that pertain to it. All this function will do is tell the caller to add an item of its kind to the dragable list when clicked (the new item should be created with self.selected = True). Now in your main control class you will now need to keep a list of PalletItems as well as Dragables. As the Dragables did, these PalletItems will also need to be updated and passed events every frame.

I would really like to see you try to get it working before I write it for you. Your previous code hasn't changed much since I last wrote you a snippet.

def event_loop(self): for ev in pg.event.get(): if ev.type==pg.QUIT or (ev.type==pg.KEYDOWN and ev.key==pg.K_ESCAPE): self.done = True

for BaseEle in self.base_eles: result = BaseEle.events(ev) if result: self.draggables.append(Dragable(result,pg.mouse.get_pos()))

for Ele in self.draggables: Ele.events(ev)

def update(self): self.Screen.fill(0) self.Screen.blit(self.bg,(0,0)) [Ele.update(self.Screen) for Ele in self.base_eles] [Ele.update(self.Screen) for Ele in self.draggables if not Ele.selected] [Ele.update(self.Screen) for Ele in self.draggables if Ele.selected]