Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/data
diff options
context:
space:
mode:
authorBrian Jordan <brian@laptop.org>2008-11-04 22:08:38 (GMT)
committer Brian Jordan <brian@laptop.org>2008-11-04 22:08:38 (GMT)
commitcceaa369918b77f5849237d60bb4b8d58d363aab (patch)
treee8ab05a46300f0296a18cad207b855be596c5fc8 /data
parentec7d4f57742f6138002ed5f66ba735cea984f1fd (diff)
Added mousejoint to example
Diffstat (limited to 'data')
-rw-r--r--data/graphics/physics13
1 files changed, 12 insertions, 1 deletions
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))