From 81c112b2e4869da9d572d082bb7ed1e075f2ac22 Mon Sep 17 00:00:00 2001 From: Brian Date: Thu, 10 Jul 2008 16:02:42 +0000 Subject: thicker affixations, more mouse grab power! --- diff --git a/elements/add_objects.py b/elements/add_objects.py index 7954852..72dc21e 100644 --- a/elements/add_objects.py +++ b/elements/add_objects.py @@ -513,7 +513,7 @@ class Add: mj.body1 = self.parent.world.GetGroundBody() mj.body2 = body mj.target = box2d.b2Vec2(x, y) - mj.maxForce = 50.0 * body.GetMass() + mj.maxForce = 100.0 * body.GetMass() # give humans POWER! self.parent.mouseJoint = self.parent.world.CreateJoint(mj).getAsType() body.WakeUp() diff --git a/elements/elements.py b/elements/elements.py index 398c484..1e821b3 100644 --- a/elements/elements.py +++ b/elements/elements.py @@ -240,7 +240,6 @@ class Elements: """ Transfers a coordinate from the screen to the world coordinate system (pixels) - Change to the right axis orientation - Include the offset: screen -- world coordinate system - - Include the scale factor (Screen coordinate system might have a scale factor) """ dx, dy = self.screen_offset_pixel @@ -362,9 +361,9 @@ class Elements: p1 = joint.GetAnchor2() p1 = self.to_screen((p1.x*self.ppm, p1.y*self.ppm)) - if p1 == p2: - self.renderer.draw_circle((255,255,255), p1, 2, 0) - else: + if p1 == p2: # Fixation + self.renderer.draw_circle((255,0,0), p1, 4, 0) + else: # Object to object joint self.renderer.draw_lines((0,0,0), False, [p1, p2], 3) joint = joint.GetNext() diff --git a/tools.py b/tools.py index 2409527..c7df29b 100644 --- a/tools.py +++ b/tools.py @@ -311,4 +311,33 @@ class DestroyTool(Tool): pygame.draw.lines(self.game.screen,(255,0,0),False,self.vertices,3) def cancel(self): - self.vertices = None + self.vertices = None + + # The joystick tool +class JoystickTool(Tool): + def __init__(self,gameInstance): + self.game = gameInstance + self.name = "Joystick" + self.vertices = None + self.joystickobject + def handleEvents(self,event): + #look for default events, and if none are handled then try the custom events + if not super(JoystickTool,self).handleEvents(event): + if pygame.mouse.get_pressed()[0]: + if not self.vertices: self.vertices = [] + self.vertices.append(pygame.mouse.get_pos()) + if len(self.vertices) > 10: + self.vertices.pop(0) + self.joystickobject = self.game.world.get_bodies_at_pos(pygame.mouse.get_pos()) + if tokill: + self.game.world.world.DestroyBody(tokill[0]) + elif event.type == MOUSEBUTTONUP and event.button == 1: + self.cancel() + def draw(self): + # draw the trail + if self.vertices: + if len(self.vertices) > 1: + pygame.draw.lines(self.game.screen,(255,0,0),False,self.vertices,3) + + def cancel(self): + self.vertices = None -- cgit v0.9.1