[Bugs] #1615 UNSP: Add a button in Physics Activity to clear off the whole screen at once

Sugar Labs Bugs bugtracker-noreply at sugarlabs.org
Sat Dec 19 15:11:15 EST 2009


#1615: Add a button in Physics Activity to clear off the whole screen at once
------------------------------------------+---------------------------------
    Reporter:  mchua                      |          Owner:  garycmartin                
        Type:  enhancement                |         Status:  new                        
    Priority:  Unspecified by Maintainer  |      Milestone:  Unspecified by Release Team
   Component:  Physics                    |        Version:  0.84.x                     
    Severity:  Unspecified                |       Keywords:                             
Distribution:  Unspecified                |   Status_field:  Unconfirmed                
------------------------------------------+---------------------------------
Changes (by garycmartin):

 * cc: bernie (added)
  * distribution:  OLPC => Unspecified


Comment:

 Possible patch from Bernie posted to the mail-list (thanks). I'm still
 concerned that without first adding an undo mechanism (or real Journal
 versioning), this feature will result in loss of work with no way of
 recovery:

 {{{
 --- Physics.activity/tools.py.orig      2009-12-18 22:43:20.779933607
 -0500
 +++ Physics.activity/tools.py   2009-12-18 22:41:50.680806893 -0500
 @@ -458,6 +458,23 @@
                     else:
                         self.game.world.world.DestroyBody(tokill[0])

 +            # Destroy everything!
 +            elif pygame.mouse.get_pressed()[2]:
 +
 +                # Build a Python list of all bodies from the linked list
 returned by box2D
 +                body = self.game.world.world.GetBodyList()
 +                shapes = []
 +                while body:
 +                    shapes.append(body)
 +                    body = body.GetNext()
 +
 +                # Destroy everything! Muhahahah!
 +                for body in shapes:
 +                    self.game.world.world.DestroyBody(body)
 +
 +                # Oops! Restore the ground which we eagerly destroyed :-)
 +                self.game.world.add.ground()
 +
             elif event.type == MOUSEBUTTONUP and event.button == 1:
                 self.cancel()
     def draw(self):
 }}}

-- 
Ticket URL: <http://bugs.sugarlabs.org/ticket/1615#comment:3>
Sugar Labs <http://sugarlabs.org/>
Sugar Labs bug tracking system


More information about the Bugs mailing list