Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tools.py
diff options
context:
space:
mode:
authorGary Martin <gary@garycmartin.com>2009-06-21 20:11:12 (GMT)
committer Gary Martin <gary@garycmartin.com>2009-06-21 20:11:12 (GMT)
commit56b86d85ae9158c58552fe0c65801d79dbe2e91c (patch)
tree59554589fde430432da84cc4d20a5cf90e8aad43 /tools.py
parentb210424ac06451ac2b4baa31b0beeb4ad98b7f49 (diff)
Fixed polygon tool to prevent small polys and avoid the crash.
Diffstat (limited to 'tools.py')
-rw-r--r--tools.py25
1 files changed, 18 insertions, 7 deletions
diff --git a/tools.py b/tools.py
index 190e8a8..89420c4 100644
--- a/tools.py
+++ b/tools.py
@@ -168,27 +168,38 @@ class PolygonTool(Tool):
#look for default events, and if none are handled then try the custom events
if not super(PolygonTool,self).handleEvents(event):
if event.type == MOUSEBUTTONDOWN:
+ # Solid poly
if event.button == 1:
if not self.vertices:
- self.vertices=[event.pos]
- elif distance(event.pos,self.vertices[0]) < 15:
+ self.vertices=[event.pos]
+ self.safe = False
+ elif distance(event.pos,self.vertices[0]) < 15 and self.safe:
self.vertices.append(self.vertices[0]) #connect the polygon
self.game.world.add.complexPoly(self.vertices, dynamic=True, density=1.0, restitution=0.16, friction=0.5)
- self.vertices = None
+ self.vertices = None
+ elif distance(event.pos,self.vertices[0]) < 15:
+ self.vertices = None
else:
self.vertices.append(event.pos)
-
+ if distance(event.pos,self.vertices[0]) >= 55 and self.vertices:
+ self.safe = True
+
+ # Polygon of triangles
elif event.button == 3:
if not self.vertices:
- self.vertices=[event.pos]
- elif distance(event.pos,self.vertices[0]) < 15:
- #self.vertices.append(self.vertices[0]) #connect the polygon
+ self.vertices=[event.pos]
+ self.safe = False
+ elif distance(event.pos,self.vertices[0]) < 15 and self.safe:
gons = decomposePoly(self.vertices)
for g in gons:
self.game.world.add.convexPoly(g, dynamic=True, density=1.0, restitution=0.16, friction=0.5)
self.vertices = None
+ elif distance(event.pos,self.vertices[0]) < 15:
+ self.vertices = None
else:
self.vertices.append(event.pos)
+ if distance(event.pos,self.vertices[0]) >= 55 and self.vertices:
+ self.safe = True
def draw(self):
# draw the poly being created