Closed GoogleCodeExporter closed 9 years ago
I am adding a pynguin.remove() method. It works like this:
def remove(self, pyn=None):
'''take the given pynguin (or this one if none specified)
out of the scene.
If removing a different pynguin from this one, this one will
adopt all of the drawn items from the other pynguin. In
other words, items drawn by the pynguin that is being
removed will not be cleared immediately, but can later
be cleared by this pynguin.
If this pynguin is removing itself, it will first clear all
of its own drawings, otherwise there will be no way to
clear them out later.
'''
Give it a try to see if it does what you need.
Original comment by miss...@hotmail.com
on 15 Jul 2010 at 5:21
See also p.reap() for removing all other pynguins and taking charge of their
drawings all at once.
Original comment by miss...@hotmail.com
on 15 Jul 2010 at 9:13
Thanks! This is awesome.
Original comment by aresnick...@gmail.com
on 16 Jul 2010 at 3:54
Original comment by miss...@hotmail.com
on 17 Jul 2010 at 12:41
Any chance we could have an argument for .remove that lets you choose whether
to remove a penguin's drawings? e.g. if you want to remove a penguin but leave
its drawings, is that easy? Or do drawings need to be owned by a penguin? If
so, maybe there could be an invisible/omnipresent penguin?
Original comment by aresnick...@gmail.com
on 17 Jul 2010 at 7:23
Well...
You can certainly create an invisible, omnipresent pynguin to hold any drawings
by pynguins that you want to get rid of:
>>> reaper = Pynguin()
>>> reaper.avatar('hidden')
Now make some drawings
>>> circle(100)
>>> square(150)
Use the reaper to get rid of the pynguin
>>> reaper.remove(p)
Need a new pynguin to draw with?
>>> promote(Pynguin())
>>> lt(45)
>>> fd(100)
>>> reaper.remove(p)
Remember that if you have a bunch of other pynguins drawing, and want to get
rid of them all at once -- but keep their drawings -- use the reap() method:
>>> for i in range(20):
>>> pyn = Pynguin()
>>> pyn.right(10*i)
>>> pyn.fd(100)
>>>
>>> reaper.reap()
Original comment by miss...@hotmail.com
on 18 Jul 2010 at 2:05
Original issue reported on code.google.com by
aresnick...@gmail.com
on 6 Jul 2010 at 6:41