GameObject name is now passed as a keyword argument, so is the unused
GameObject name is now passed as a keyword argument, so is the unused
parent. Also classes to hold debug information are created.

--- a/astroids.py
+++ b/astroids.py
@@ -15,10 +15,10 @@
     bulletFixture=b2FixtureDef(shape=b2CircleShape(radius=0.1),density=100,friction=0.3)
 
 
-    def __init__(self,g,position,velocity):
+    def __init__(self,game,position,velocity,**kwargs):
         Bullet.bulletDef.position=position
         Bullet.bulletDef.linearVelocity=velocity
-        super(Bullet,self).__init__(g,'bullet',Bullet.bulletDef,Bullet.bulletFixture)
+        super(Bullet,self).__init__(game,Bullet.bulletDef,Bullet.bulletFixture,**kwargs)
 
         self.area=self.game.game_area
 
@@ -75,7 +75,7 @@
 
         shipFixture=b2FixtureDef(shape=shipShape,density=0.01,friction=0.3)
 
-        self.ship=game.GObjBox2D(g,'ship',shipDef,shipFixture)
+        self.ship=game.GObjBox2D(g,shipDef,shipFixture,name='ship')
         self.ship.smashInfo=smasher.SmashInfo()
         self.ship.smashInfo.treshold_impulse=0.01
         self.ship.smashInfo.brittleness=0.01
@@ -198,7 +198,7 @@
         astroidShape=b2PolygonShape(vertices=astroidPolygon)
         astroidFixture=b2FixtureDef(shape=astroidShape,density=1,friction=0.3)
 
-        astroid=game.GObjBox2D(self.game,'astroid',astroidDef,astroidFixture)
+        astroid=game.GObjBox2D(self.game,astroidDef,astroidFixture,name='astroid')
         astroid.area=self.game.game_area
 
     def generate_astroid_polygon(self,size):
@@ -217,8 +217,8 @@
         return polygon
 
 class HUD(game.GameObject):
-    def __init__(self,game,name):
-        super(HUD,self).__init__(game,name)
+    def __init__(self,game,**kwargs):
+        super(HUD,self).__init__(game,**kwargs)
 
         self.font=pygame.font.Font(None, 35)
         self.fg=(255,255,255)
@@ -255,7 +255,7 @@
         self.shipControl=ShipControl(self)
         self.astroidGenerator=AstroidGenerator(self)
 
-        self.hud=HUD(self,'hud')
+        self.hud=HUD(self)
 
         self.score=0
 

file:a/game.py -> file:b/game.py
--- a/game.py
+++ b/game.py
@@ -36,6 +36,9 @@
             )
         self.world.renderer=self.debugDrawer
 
+        # Initialize the game system
+        self.debugOverlay=GObjDebugOverlay(self)
+
     def run(self):
         velocityIterations=6
         positionIterations=2
@@ -103,8 +106,9 @@
 
 
 class GameObject(object):
-    def __init__(self,game,name):
-        self.name=name
+    def __init__(self,game,**kwargs):
+        self.name=kwargs.get('name')
+        self.parent=kwargs.get('parent')
 
         self.game=game
         self.game.add_object(self)
@@ -119,8 +123,8 @@
         pass
 
 class GObjBox2D(GameObject):
-    def __init__(self,game,name,bodyDef,fixtureDef):
-        super(GObjBox2D,self).__init__(game,name)
+    def __init__(self,game,bodyDef,fixtureDef,**kwargs):
+        super(GObjBox2D,self).__init__(game,**kwargs)
 
         bodyDef.userData=self
         self.body=self.game.world.CreateBody(bodyDef)
@@ -143,6 +147,13 @@
             if self.body.position.y<self.area.lowerBound.y or self.body.position.y>self.area.upperBound.y:
                 self.remove()
 
+class GObjDebugOverlay(GameObject):
+    def __init__(self,game):
+        super(GObjDebugOverlay,self).__init__(game,name='DEBUG')
+
+class GObjDebugScreen(GameObject):
+    def __init__(self,game,**kwargs):
+        super(GObjDebugScreen,self).__init__(game,**kwargs)
 
 
 class EventListener(object):

file:a/smasher.py -> file:b/smasher.py
--- a/smasher.py
+++ b/smasher.py
@@ -75,7 +75,7 @@
                                      density=obj.fixture.density,
                                      friction=obj.fixture.friction)
 
-            body=game.GObjBox2D(self.game,obj.name,bodyDef,bodyFixture)
+            body=game.GObjBox2D(self.game,bodyDef,bodyFixture,name=obj.name)
             body.area=obj.area
 
         # Remove the selected object