Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools.py31
1 files changed, 13 insertions, 18 deletions
diff --git a/tools.py b/tools.py
index ff8bcd3..190e8a8 100644
--- a/tools.py
+++ b/tools.py
@@ -215,24 +215,19 @@ class MagicPenTool(Tool):
def handleEvents(self,event):
#look for default events, and if none are handled then try the custom events
if not super(MagicPenTool,self).handleEvents(event):
- if event.type == MOUSEBUTTONDOWN:
- if event.button == 1:
- 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.game.world.add.complexPoly(self.vertices, dynamic=True, density=1.0, restitution=0.16, friction=0.5)
- self.vertices = None
- else:
- self.vertices.append(event.pos)
- elif event.type == MOUSEBUTTONUP:
- if event.button == 1:
- if self.vertices:
- self.game.world.add.complexPoly(self.vertices, dynamic=True, density=1.0, restitution=0.16, friction=0.5)
- self.vertices = None
- elif event.type == MOUSEMOTION:
- if self.vertices:
- self.vertices.append(event.pos)
+ if event.type == MOUSEBUTTONDOWN and event.button == 1:
+ self.vertices=[event.pos]
+ self.safe = False
+ elif event.type == MOUSEBUTTONUP and event.button == 1:
+ if self.vertices and self.safe:
+ self.game.world.add.complexPoly(self.vertices, dynamic=True, density=1.0, restitution=0.16, friction=0.5)
+ self.vertices = None
+ else:
+ self.vertices = None
+ elif event.type == MOUSEMOTION and self.vertices:
+ self.vertices.append(event.pos)
+ if distance(event.pos,self.vertices[0]) >= 55 and len(self.vertices) > 3:
+ self.safe = True
def draw(self):
# draw the poly being created