Codebase list sugar-pippy-activity / cceaa36
Added mousejoint to example Brian Jordan 15 years ago
1 changed file(s) with 12 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
1010 # set up the physics world (instance of Elements)
1111 world = physics.Elements(screen.get_size())
1212 world.renderer.set_surface(screen)
13
13
1414 # set up initial physics objects
1515 world.add.ground()
1616 world.add.ball((600,0), 50)
3333 elif event.type == KEYDOWN:
3434 sys.exit()
3535
36 elif event.type == MOUSEBUTTONDOWN and event.button == 1:
37 bodylist = world.get_bodies_at_pos(event.pos, include_static=False)
38 if bodylist and len(bodylist) > 0:
39 world.add.mouseJoint(bodylist[0], event.pos)
40
41 elif event.type == MOUSEBUTTONUP and event.button == 1:
42 world.add.remove_mouseJoint()
43
44 elif event.type == MOUSEMOTION and event.buttons[0]:
45 world.mouse_move(event.pos)
46
3647 # clear display with a color
3748 # (r,g,b), where 0<=value<256
3849 screen.fill((80,160,240))