@@ -37,31 +37,61 @@ Example.bridge = function() {
3737 // add bodies
3838 var group = Body . nextGroup ( true ) ;
3939
40- var bridge = Composites . stack ( 150 , 300 , 9 , 1 , 10 , 10 , function ( x , y ) {
41- return Bodies . rectangle ( x , y , 50 , 20 , { collisionFilter : { group : group } } ) ;
40+ var bridge = Composites . stack ( 160 , 290 , 15 , 1 , 0 , 0 , function ( x , y ) {
41+ return Bodies . rectangle ( x - 20 , y , 53 , 20 , {
42+ collisionFilter : { group : group } ,
43+ chamfer : 5 ,
44+ render : {
45+ fillStyle : '#575375'
46+ }
47+ } ) ;
4248 } ) ;
4349
44- Composites . chain ( bridge , 0.5 , 0 , - 0.5 , 0 , { stiffness : 0.9 } ) ;
50+ Composites . chain ( bridge , 0.3 , 0 , - 0.3 , 0 , {
51+ stiffness : 1.2 ,
52+ length : 0 ,
53+ render : {
54+ visible : false
55+ }
56+ } ) ;
4557
46- var stack = Composites . stack ( 200 , 40 , 6 , 3 , 0 , 0 , function ( x , y ) {
47- return Bodies . polygon ( x , y , Math . round ( Common . random ( 1 , 8 ) ) , Common . random ( 20 , 40 ) ) ;
58+ var stack = Composites . stack ( 250 , 50 , 4 , 3 , 0 , 0 , function ( x , y ) {
59+ return Bodies . polygon ( x , y , 1 , Common . random ( 20 , 40 ) ) ;
4860 } ) ;
4961
5062 World . add ( world , [
5163 bridge ,
52- Bodies . rectangle ( 80 , 440 , 120 , 280 , { isStatic : true } ) ,
53- Bodies . rectangle ( 720 , 440 , 120 , 280 , { isStatic : true } ) ,
54- Constraint . create ( { pointA : { x : 140 , y : 300 } , bodyB : bridge . bodies [ 0 ] , pointB : { x : - 25 , y : 0 } } ) ,
55- Constraint . create ( { pointA : { x : 660 , y : 300 } , bodyB : bridge . bodies [ 8 ] , pointB : { x : 25 , y : 0 } } ) ,
56- stack
64+ stack ,
65+ Bodies . rectangle ( 30 , 490 , 220 , 380 , {
66+ isStatic : true ,
67+ chamfer : { radius : 20 }
68+ } ) ,
69+ Bodies . rectangle ( 770 , 490 , 220 , 380 , {
70+ isStatic : true ,
71+ chamfer : { radius : 20 }
72+ } ) ,
73+ Constraint . create ( {
74+ pointA : { x : 140 , y : 300 } ,
75+ bodyB : bridge . bodies [ 0 ] ,
76+ pointB : { x : - 25 , y : 0 } ,
77+ length : 2 ,
78+ stiffness : 0.5
79+ } ) ,
80+ Constraint . create ( {
81+ pointA : { x : 660 , y : 300 } ,
82+ bodyB : bridge . bodies [ 14 ] ,
83+ pointB : { x : 25 , y : 0 } ,
84+ length : 2 ,
85+ stiffness : 0.5
86+ } )
5787 ] ) ;
5888
5989 // add mouse control
6090 var mouse = Mouse . create ( render . canvas ) ,
6191 mouseConstraint = MouseConstraint . create ( engine , {
6292 mouse : mouse ,
6393 constraint : {
64- stiffness : 0.2 ,
94+ stiffness : 0.1 ,
6595 render : {
6696 visible : false
6797 }
0 commit comments