From cceaa369918b77f5849237d60bb4b8d58d363aab Mon Sep 17 00:00:00 2001 From: Brian Jordan Date: Tue, 04 Nov 2008 22:08:38 +0000 Subject: Added mousejoint to example --- (limited to 'data') diff --git a/data/graphics/physics b/data/graphics/physics index 88138fd..556442a 100644 --- a/data/graphics/physics +++ b/data/graphics/physics @@ -11,7 +11,7 @@ screen = pygame.display.set_mode((1200,900)) # set up the physics world (instance of Elements) world = physics.Elements(screen.get_size()) world.renderer.set_surface(screen) - + # set up initial physics objects world.add.ground() world.add.ball((600,0), 50) @@ -34,6 +34,17 @@ while pippy.pygame.next_frame() and world.run_physics: elif event.type == KEYDOWN: sys.exit() + elif event.type == MOUSEBUTTONDOWN and event.button == 1: + bodylist = world.get_bodies_at_pos(event.pos, include_static=False) + if bodylist and len(bodylist) > 0: + world.add.mouseJoint(bodylist[0], event.pos) + + elif event.type == MOUSEBUTTONUP and event.button == 1: + world.add.remove_mouseJoint() + + elif event.type == MOUSEMOTION and event.buttons[0]: + world.mouse_move(event.pos) + # clear display with a color # (r,g,b), where 0<=value<256 screen.fill((80,160,240)) -- cgit v0.9.1