Commit 9fdc8cfb authored by Raphaël Bastide's avatar Raphaël Bastide

First sound tests, new modules, gfx

parent 0f32528e
......@@ -7,4 +7,20 @@ body {
padding: 0;
}
.matter-header-outer{display: none!important;}
.matter-demo{background: #777!important}
.matter-demo{
background: #eee!important;
}
canvas{
position: relative;
}
canvas:before{
z-index: 1000000;
box-shadow: 0px 0px 16px red inset;
background: red;
content:"";
position: absolute;
top:0;
left:0;
bottom: 0;
right: 0;
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="200"
height="200"
viewBox="0 0 52.916668 52.916668"
version="1.1"
id="svg8"
inkscape:version="0.92.3 (2405546, 2018-03-11)"
sodipodi:docname="ball-bullettime.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="3.959798"
inkscape:cx="100.06475"
inkscape:cy="68.448063"
inkscape:document-units="mm"
inkscape:current-layer="g940"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-width="1920"
inkscape:window-height="1024"
inkscape:window-x="0"
inkscape:window-y="868"
inkscape:window-maximized="1"
units="px" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(46.310902,285.37685)">
<circle
id="path817"
style="opacity:1;vector-effect:none;fill:#00ffff;fill-opacity:1;stroke:none;stroke-width:0.59829068;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
cx="-19.852568"
cy="-258.91852"
r="26.458334"
inkscape:export-xdpi="57.439999"
inkscape:export-ydpi="57.439999" />
<path
style="opacity:1;vector-effect:none;fill:#00ffff;fill-opacity:1;stroke:none;stroke-width:0.59829068;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
id="path815"
sodipodi:type="arc"
sodipodi:cx="-19.852568"
sodipodi:cy="-258.91852"
sodipodi:rx="26.458334"
sodipodi:ry="26.458334"
sodipodi:start="0"
sodipodi:end="3.1415927"
sodipodi:open="true"
d="m 6.6057663,-258.91852 a 26.458334,26.458334 0 0 1 -13.2291673,22.91359 26.458334,26.458334 0 0 1 -26.458334,0 26.458334,26.458334 0 0 1 -13.229167,-22.91359"
inkscape:export-xdpi="57.439999"
inkscape:export-ydpi="57.439999" />
<g
id="g940"
transform="matrix(0.7681688,0.05593443,-0.05593443,0.7681688,20.0778,-50.121517)"
style="stroke-width:1.29835975">
<path
sodipodi:nodetypes="ccccccccscccsccccccscccsccccscccccccccccc"
inkscape:connector-curvature="0"
id="path921"
d="m -50.882279,-285.10921 c -0.10804,0.006 -0.190034,0.0745 -0.272335,0.20671 -0.30357,0.48752 -5.661457,0.53378 -6.946347,0.0599 -0.56805,-0.20946 -1.161159,-0.26682 -1.455209,-0.14056 -0.272989,0.11723 -0.734218,0.25674 -1.02526,0.30954 -0.291039,0.0528 -1.422141,0.34112 -2.513542,0.64079 -1.091409,0.29968 -2.460627,0.66341 -3.042708,0.80822 -0.582078,0.14482 -1.424302,0.37439 -1.871202,0.51005 -0.446889,0.13566 -0.997704,0.24649 -1.224214,0.24649 -0.226512,0 -0.549772,0.16643 -0.718304,0.36949 -0.168518,0.20306 -0.702321,0.44353 -1.18649,0.53433 -1.20025,0.22517 -1.882396,0.99509 -1.505336,1.69964 0.480491,0.89781 1.089234,1.36529 1.777154,1.36529 0.3714,0 0.587359,0.11528 0.495059,0.26459 -0.08994,0.14552 -0.0081,0.26671 0.182419,0.26871 0.23917,0.003 0.255416,0.0642 0.05168,0.19844 -0.470781,0.31016 -0.729358,1.42554 -0.380338,1.64124 0.16914,0.10457 1.060309,0.16293 1.980239,0.13023 1.567312,-0.0558 1.74307,-0.12773 2.79518,-1.14877 0.61754,-0.5993 1.335088,-1.08985 1.594218,-1.08985 0.25912,0 0.717746,0.41861 1.019574,0.93017 0.301832,0.51156 0.864071,1.04995 1.249022,1.19631 1.053898,0.40069 2.460992,-0.19951 2.969844,-1.26659 0.461248,-0.96723 1.370457,-1.19078 1.370457,-0.33693 0,0.75935 1.242764,1.52099 1.812293,1.11053 0.450641,-0.32478 1.052039,-0.61414 2.102199,-1.01183 l 0.607198,-0.22996 -0.862481,-1.12189 c -0.47425,-0.61705 -0.991254,-1.1219 -1.149284,-1.1219 -0.569169,0 -0.909587,-0.58769 -0.636138,-1.09864 0.279353,-0.52196 1.032905,-0.64803 1.446424,-0.24184 0.13824,0.1358 0.727909,0.28463 1.309998,0.33073 0.8398,0.0665 1.049909,0.18438 1.01751,0.57102 -0.02984,0.35657 0.09398,0.45193 0.462503,0.35553 0.276949,-0.0724 0.575725,-0.0155 0.663527,0.12661 0.08284,0.13402 0.526314,0.17227 1.037145,0.10335 l 1.135904,-1.32649 c -0.474715,-0.81187 -1.058198,-1.58749 -0.501139,-2.74328 l -0.634765,-0.79711 c -0.236415,0.0629 -0.474969,0.0176 -0.724503,-0.13695 -0.187862,-0.11634 -0.321908,-0.1717 -0.429948,-0.16536 z"
style="fill:#000000;stroke-width:1.29835975" />
<path
inkscape:connector-curvature="0"
id="path919"
d="m -48.280372,-283.64728 c 0.09622,-0.0138 0.156607,0.14657 0.138494,0.39274 -0.05297,0.71898 -0.401011,0.99437 -0.401011,0.31729 0,-0.30671 0.09841,-0.6189 0.21911,-0.6935 0.01508,-0.009 0.02966,-0.0146 0.04341,-0.0165 z"
style="fill:#000000;stroke-width:1.29835975" />
<path
sodipodi:nodetypes="scccsccccscscsscccccscs"
inkscape:connector-curvature="0"
id="path917"
d="m -88.626228,-281.05054 c -2.060978,-0.008 -3.900713,0.28129 -5.10925,0.83457 -0.800269,0.36638 -1.512115,0.6092 -1.581814,0.5395 -0.06974,-0.0697 -0.356558,-0.004 -0.637688,0.14676 -0.448911,0.24025 -0.489151,0.45655 -0.331761,1.77664 0.193608,1.62388 0.524986,2.26404 0.800467,1.54616 0.37515,-0.97762 3.204295,-1.63221 3.475755,-0.80409 0.05366,0.16368 -0.381315,0.48918 -0.966864,0.72347 -0.954432,0.38188 -1.054934,0.50832 -0.972035,1.2206 0.13149,1.12933 0.618858,1.59474 1.670699,1.59474 0.74305,0 1.12259,-0.22309 2.023649,-1.19063 1.29616,-1.39179 1.911604,-1.51319 2.150774,-0.42426 0.187249,0.85253 0.79261,1.49414 1.5937,1.6893 0.500361,0.1219 0.843073,0.16619 1.140079,0.0903 0.197154,-0.0504 0.374168,-0.15367 0.563784,-0.32238 0.173337,-0.15422 0.357204,-0.36309 0.576617,-0.63611 0.968111,-1.20469 1.219751,-1.26642 2.154391,-0.53124 0.54297,0.4271 0.696521,0.45617 0.812872,0.15296 0.08704,-0.2266 0.356296,-0.31876 0.684196,-0.23306 0.41365,0.10817 0.607476,-0.0337 0.824754,-0.60513 0.40222,-1.05792 0.175297,-1.66199 -1.201994,-3.19877 -1.408239,-1.57131 -1.909627,-1.80004 -4.760949,-2.17196 -0.989934,-0.12913 -1.972575,-0.19394 -2.909382,-0.1974 z"
style="fill:#000000;stroke-width:1.29835975" />
<path
inkscape:connector-curvature="0"
id="path915"
d="m -62.269181,-278.63054 c 0.144963,-0.002 0.232543,0.0948 0.232543,0.27182 0,0.42793 -0.413526,0.5255 -0.644404,0.15193 -0.08051,-0.13027 0.03163,-0.30521 0.249079,-0.38861 0.06004,-0.023 0.114462,-0.0346 0.162782,-0.0351 z"
style="fill:#000000;stroke-width:1.29835975" />
<path
inkscape:connector-curvature="0"
id="path913"
d="m -60.599517,-278.37422 c 0.247441,0.003 0.414962,0.1693 0.414962,0.44855 0,0.29545 -0.724318,0.28227 -0.908987,-0.0165 -0.08051,-0.13027 0.02003,-0.30078 0.223243,-0.37878 0.09699,-0.0372 0.188303,-0.0542 0.270782,-0.0532 z"
style="fill:#000000;stroke-width:1.29835975" />
<path
inkscape:connector-curvature="0"
id="path911"
d="m -86.460987,-276.08134 c 0.209362,-0.005 0.347266,0.12548 0.347266,0.34107 0,0.24543 -0.226386,0.41599 -0.551387,0.41599 -0.6448,0 -0.553699,-0.61799 0.11007,-0.74672 0.03264,-0.006 0.06414,-0.01 0.09405,-0.0103 z"
style="fill:#000000;stroke-width:1.29835975" />
<path
inkscape:connector-curvature="0"
id="path909"
d="m -84.923096,-275.58886 c 0.218291,0 0.396875,0.11215 0.396875,0.24908 0,0.3336 -0.413377,0.5726 -0.624766,0.36122 -0.297961,-0.29797 -0.181258,-0.6103 0.227891,-0.6103 z"
style="fill:#000000;stroke-width:1.29835975" />
<path
inkscape:connector-curvature="0"
id="path903"
d="m -71.5482,-264.17612 c -0.07503,-0.01 -0.142788,0.005 -0.190172,0.0527 -0.07767,0.0777 -0.06231,0.26803 0.03359,0.42323 0.215558,0.34876 0.672308,0.37172 0.672308,0.0336 0,-0.23414 -0.290639,-0.48093 -0.515728,-0.50953 z"
style="fill:#000000;stroke-width:1.29835975" />
<path
inkscape:connector-curvature="0"
id="path899"
d="m -68.008882,-261.09052 c -0.03431,0.0185 -0.05889,0.17777 -0.06201,0.45062 -0.0054,0.43655 0.04946,0.64733 0.121957,0.46819 0.0727,-0.17913 0.07692,-0.53632 0.0098,-0.79375 -0.02516,-0.0965 -0.04918,-0.13614 -0.06976,-0.12506 z"
style="fill:#000000;stroke-width:1.29835975" />
<path
inkscape:connector-curvature="0"
id="path897"
d="m -71.523914,-259.44928 c -1.107699,0 -1.445096,0.12529 -2.097545,0.77773 -0.471911,0.47192 -0.87321,0.68175 -1.020609,0.53434 -0.133572,-0.13356 -1.182108,-0.37356 -2.330609,-0.5333 -1.619218,-0.22516 -2.226548,-0.21638 -2.704227,0.0393 -0.33882,0.18133 -0.615984,0.41693 -0.615984,0.52348 0,0.44079 1.955469,1.30552 2.991548,1.32292 0.610143,0.0102 1.347621,0.12091 1.63866,0.24598 0.980202,0.42121 1.623057,0.29033 1.934766,-0.39378 0.16501,-0.36208 0.225242,-0.85277 0.133842,-1.09089 -0.151458,-0.39474 -0.106069,-0.394 0.514181,0.0124 0.64253,0.42102 0.696094,0.4193 0.963765,-0.0331 0.266312,-0.45006 0.312772,-0.44095 0.772563,0.14573 0.474019,0.60485 0.515368,0.6104 1.326017,0.1912 1.58904,-0.82172 0.793361,-1.74201 -1.506368,-1.74201 z"
style="fill:#000000;stroke-width:1.29835975" />
<path
inkscape:connector-curvature="0"
id="path887"
d="m -64.014955,-252.67399 c -0.220379,0.18295 -1.399174,0.62959 -3.096826,0.61289 -3.113449,-0.0307 -4.830865,0.15983 -6.564455,0.72709 -0.869251,0.28444 -1.615326,0.33234 -2.778125,0.17932 -1.8996,-0.24998 -2.657874,-0.18347 -3.680912,0.32194 -0.42254,0.20874 -1.13692,0.38144 -1.5875,0.38344 -1.807541,0.009 -1.931683,0.90547 -0.157615,1.13792 l 0,-5.3e-4 c 0.509331,0.0672 1.402286,0.0704 1.984375,0.007 0.582081,-0.0632 2.797267,-0.21099 4.922697,-0.32815 2.12543,-0.11717 4.025598,-0.31261 4.222999,-0.4346 0.1974,-0.12201 1.732687,-0.22871 3.411677,-0.23771 2.58463,-0.0134 3.169796,-0.44162 3.953105,-0.90176 1.692412,-1.34198 1.431665,-2.70859 -0.62942,-1.46685 z"
style="fill:#000000;stroke-width:1.29835975"
sodipodi:nodetypes="cccscccccccccc" />
<path
inkscape:connector-curvature="0"
id="path883"
d="m -88.74405,-248.07219 c -0.154112,0 -0.280088,0.11906 -0.280088,0.26458 0,0.14552 0.05207,0.26458 0.116274,0.26458 0.06417,0 0.190701,-0.11906 0.280601,-0.26458 0.08993,-0.14552 0.03732,-0.26458 -0.116787,-0.26458 z"
style="fill:#000000;stroke-width:1.29835975" />
<path
inkscape:connector-curvature="0"
id="path881"
d="m -69.428435,-246.95598 c -0.352748,-0.0149 -0.88533,0.0471 -1.779736,0.17776 -1.140388,0.16661 -3.115061,0.31036 -4.388363,0.31936 -1.815298,0.0131 -2.315104,0.0982 -2.315104,0.39274 0,0.20657 0.208362,0.38216 0.463021,0.39016 0.254661,0.008 0.879734,0.1746 1.389062,0.36949 1.471242,0.56297 5.162407,0.3565 6.582029,-0.36794 1.04372,-0.5326 1.118399,-0.63135 0.750858,-0.9989 -0.175974,-0.17598 -0.349017,-0.26774 -0.701767,-0.28267 z"
style="fill:#000000;stroke-width:1.29835975" />
<path
inkscape:connector-curvature="0"
id="path875"
d="m -53.930573,-255.99853 c -0.0349,-0.003 -0.0859,0.008 -0.15244,0.03 -0.44192,0.1473 -0.74252,1.28218 -0.57361,2.16576 0.0727,0.38036 0.28941,0.69143 0.48214,0.69143 0.45602,0 0.72911,-0.44695 0.39791,-0.65164 -0.14158,-0.0875 -0.19516,-0.32148 -0.11886,-0.52038 0.0763,-0.19891 0.0111,-0.44062 -0.14469,-0.53692 -0.20034,-0.12402 -0.19783,-0.33371 0.008,-0.71882 0.16987,-0.31704 0.20615,-0.45009 0.10129,-0.4594 z"
style="fill:#000000;stroke-width:1.29835975" />
<path
inkscape:connector-curvature="0"
id="path873"
d="m -55.132563,-254.80584 c -0.0407,-0.007 -0.0924,0.003 -0.15607,0.0274 -0.37678,0.14459 -0.47422,0.66679 -0.17931,0.9617 0.25907,0.25906 0.27965,0.23601 0.41289,-0.46095 0.0654,-0.34235 0.0445,-0.50799 -0.0775,-0.52814 z"
style="fill:#000000;stroke-width:1.29835975" />
</g>
</g>
</svg>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="200"
height="200"
viewBox="0 0 52.916668 52.916668"
version="1.1"
id="svg8"
inkscape:version="0.92.3 (2405546, 2018-03-11)"
sodipodi:docname="ball.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="2.8"
inkscape:cx="55.175243"
inkscape:cy="59.817906"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-width="1920"
inkscape:window-height="1024"
inkscape:window-x="0"
inkscape:window-y="868"
inkscape:window-maximized="1"
units="px" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(46.310902,285.37685)">
<circle
id="path817"
style="opacity:1;vector-effect:none;fill:#00ffff;fill-opacity:1;stroke:none;stroke-width:0.59829068;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
cx="-19.85257"
cy="-258.91852"
r="26.458334"
inkscape:export-xdpi="57.439999"
inkscape:export-ydpi="57.439999" />
<path
style="opacity:1;vector-effect:none;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1.32291663;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
d="m -35.06611,-265.91108 c -0.185166,0.29373 -0.113679,0.63269 0.09449,0.94494 0.349514,0.52428 1.592722,-0.12184 1.228422,-0.85044 -0.282849,-0.5657 -2.311836,-1.50537 -1.889881,-0.66146"
id="path816"
inkscape:connector-curvature="0" />
<path
style="opacity:1;vector-effect:none;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1.32291663;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
d="m -4.8280168,-244.46093 c -1.4542716,1.90294 0.4724718,2.27293 0.4724718,0.0945"
id="path818"
inkscape:connector-curvature="0" />
<path
style="opacity:1;vector-effect:none;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1.32291663;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
d="m 0.27466327,-259.29649 c -1.96606847,0.0519 1.13821633,1.89703 0,0 z"
id="path820"
inkscape:connector-curvature="0" />
<path
style="opacity:1;vector-effect:none;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1.32291663;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
d="m -25.522212,-248.99664 c -0.583888,3.02265 2.115088,-0.63232 0.661459,0.0945"
id="path822"
inkscape:connector-curvature="0" />
<path
style="opacity:1;vector-effect:none;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1.32291663;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
d="m -7.7573299,-277.06137 c -0.9376384,-0.16111 -1.2212241,2.35875 -0.2834825,1.88988 0.7138643,-0.35694 1.6379507,-1.92136 0.7559516,-2.36235"
id="path824"
inkscape:connector-curvature="0" />
<path
style="opacity:1;vector-effect:none;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1.32291663;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
d="m -6.4344133,-271.29724 c -2.3546249,-0.19999 -0.6849321,2.41532 0.1889866,1.32292 0.2403131,-0.30039 0.2414138,-0.55661 0.094493,-0.85045"
id="path826"
inkscape:connector-curvature="0" />
</g>
</svg>
......@@ -11,26 +11,27 @@
<meta name="robots" content="noindex">
<link rel="stylesheet" href="css/main.css">
<title>Ball On URL</title>
</head>
<body>
<!-- <button class="play">play</button> -->
<script type="text/javascript" src="lib/decomp.js"></script>
<script type="text/javascript" src="lib/pathseg.js"></script>
<!-- Matter -->
<script src="lib/matter.min.js"></script>
<!-- MatterTools -->
<script src="http://code.jquery.com/jquery-3.1.1.js"></script>
<script src="lib/matter-tools.gui.js"></script>
<script src="lib/matter-tools.inspector.js"></script>
<script src="lib/matter-tools.demo.js"></script>
<!-- Plugins -->
<script src="lib/matter-wrap.js"></script>
<!-- Examples -->
<!-- Sound -->
<script src="lib/tone.js"></script>
<script src="js/sound.js"></script>
<!-- Car -->
<script src="js/car.js"></script>
</head>
<body>
<script src="js/launcher.js"></script>
</body>
</html>
......@@ -31,13 +31,22 @@ Example.car = function() {
engine: engine,
options: {
wireframes:false,
width: 1600,
height: 800,
width: 1900,
height: 1000,
showAngleIndicator: false,
showCollisions: false,
background: '#111'
background: '#222',
}
});
var startX = 100
var startY = 200
var nextPos = 0
var lastDir = 0
var w = 400
var h = 10
var platformColor = "#CCC"
var ballColor = "#e91763"
var zoom = false
Render.run(render);
......@@ -48,22 +57,13 @@ Example.car = function() {
engine.world.gravity.y = 1;
var car = Composites.car(150, 100, 150, 30, 40)
var test = Bodies.circle(100, 100, 100, { friction:0, frictionAir:.003, restitution: 0.2})
// test.density = 1
car.bodies[1].friction = 0 // wheels friction
car.bodies[2].friction = 0
var ball = Bodies.circle(100, 100, 100, { friction:1, frictionAir:.003, restitution: 0.2})
ball.render.sprite.texture = 'img/ball.svg'
// ball.render.fillStyle = ballColor
World.add(world, test);
World.add(world, ball);
// World.add(world, car);
var startX = 100
var startY = 200
var nextPos = 0
var lastDir = 0
// var realW = unit.bounds.max.x - unit.bounds.min.x
// var realH = unit.bounds.max.y - unit.bounds.min.y
var w = 400
var h = 10
for (var i = 0; i < terrain.length; i++) {
if (urlshapes) {
var t = "%E" + String(terrain[i])
......@@ -75,31 +75,61 @@ Example.car = function() {
}
function buildUnit(char, nextPos){
var posY = nextPos.y
if (char == "%E2%80%94" || char == 'f') { // shape: —
var unit = Bodies.rectangle(nextPos.x, posY, w, h, { isStatic: true, angle: Math.PI * 0.0 , friction:0})
if (char == 'f') {
var unit = Bodies.rectangle(nextPos.x, posY, w, h, { isStatic: true, angle: Math.PI * 0.0 })
unit.name = 'flat'
unit.render.fillStyle = 'white'
unit.render.fillStyle = platformColor
getDistances(unit)
nextPos.x += unit.distances.w
nextPos.y += unit.distances.h
}else if (char == '%E2%95%B1' || char == 'u') { // shape: ╱
var unit = Bodies.rectangle(nextPos.x, posY - 150, w, h, { isStatic: true, angle: Math.PI * -0.2 , friction:0})
}else if (char == 'u') {
var unit = Bodies.rectangle(nextPos.x, posY - 150, w, h, { isStatic: true, angle: Math.PI * -0.2 })
unit.name = 'up'
unit.render.fillStyle = 'white'
unit.render.fillStyle = platformColor
getDistances(unit)
nextPos.x += unit.distances.w
nextPos.y -= unit.distances.h
}else if (char == '%E2%95%B2' || char == 'd') { // shape: ╲
var unit = Bodies.rectangle(nextPos.x, posY + 150, w, h, { isStatic: true, angle: Math.PI * 0.2, friction:0})
}else if (char == 'd') {
var unit = Bodies.rectangle(nextPos.x, posY + 150, w, h, { isStatic: true, angle: Math.PI * 0.2})
unit.name = 'down'
unit.render.fillStyle = 'white'
unit.render.fillStyle = platformColor
getDistances(unit)
nextPos.x += unit.distances.w
nextPos.y += unit.distances.h
}else if (char == '%E2%96%B6' || char == 'b') { // shape: ▶
var unit = Bodies.rectangle(nextPos.x, posY, w, h, {isStatic: true, angle: Math.PI * 0.0, friction:0})
}else if (char == 'b') {
var unit = Bodies.rectangle(nextPos.x, posY, w, h, {isStatic: true, angle: Math.PI * 0.0})
unit.name = 'boost'
unit.render.fillStyle = '#00FF00'
unit.render.fillStyle = '#60a74b'
getDistances(unit)
nextPos.x += unit.distances.w
nextPos.y += unit.distances.h
}else if (char == 'w') {
var unit = Bodies.rectangle(nextPos.x - 150, posY - 150, w, h, {isStatic: true, angle: Math.PI * 0.5})
unit.name = 'wall'
unit.render.fillStyle = platformColor
getDistances(unit)
nextPos.x += 100
nextPos.y += 0
}else if (char == 'z') {
var unit = Bodies.rectangle(nextPos.x, posY , w, h, {isStatic: true, angle: Math.PI * 0})
unit.name = 'bulletTime'
unit.render.fillStyle = "#ba36a0"
getDistances(unit)
nextPos.x += unit.distances.w
nextPos.y += unit.distances.h
}else if (char == 'g') { // gap
var unit = Bodies.rectangle(nextPos.x, posY, w, h, { isStatic: true, angle: Math.PI * 0.0 })
unit.name = 'gap'
unit.render.fillStyle = 'rgba(0,0,0,0)'
unit.isSensor = true
getDistances(unit)
nextPos.x += unit.distances.w
nextPos.y += unit.distances.h
}else if (char == 'j') { // gap
var unit = Bodies.rectangle(nextPos.x, posY, w, h, { isStatic: true, angle: Math.PI * 0.0 })
unit.name = 'jump'
unit.render.fillStyle = '#f227dd'
unit.isSensor = true
getDistances(unit)
nextPos.x += unit.distances.w
nextPos.y += unit.distances.h
......@@ -112,7 +142,6 @@ Example.car = function() {
var realH = unit.bounds.max.y - unit.bounds.min.y
return unit.distances = {w:realW, h:realH}
}
// vertices[1].x += 0.2;
// add mouse control
var mouse = Mouse.create(render.canvas),
......@@ -127,25 +156,61 @@ Example.car = function() {
});
// World.add(world, mouseConstraint);
// keep the mouse in sync with rendering
render.mouse = mouse;
var timeScaleTarget = 1
var zoom = 500
var zoomTarget = 500
var counter = 0
var bulletTime = false
Events.on( engine, 'afterTick', (e)=> {
// Render.lookAt( render, car.bodies[0].bounds.max, {x: 500, y: 500 },true );
Render.lookAt( render, test, {x: 500, y: 500 },true );
if (bulletTime) {
engine.timing.timeScale += (timeScaleTarget - engine.timing.timeScale) * 0.05;
zoom += (zoomTarget - zoom) * 0.05;
if (counter >= 60 * 3.5) {
zoomTarget = 500
timeScaleTarget = 1
console.log(1);
}else{
zoomTarget = 200
timeScaleTarget = 0.05
console.log(2);
}
if (counter >= 60 * 3.6) {
ball.render.sprite.texture = 'img/ball.svg'
}
if (counter >= 60 * 4.5) {
engine.timing.timeScale = 1
bulletTime = false
timeScaleTarget = 1
zoomTarget = 500
zoom = 500
counter = 0
bulletTime = false
}
counter +=1
}
// console.log(ball.render.sprite.texture);
console.log(bulletTime);
Render.lookAt(render, ball, {x: zoom, y: zoom },true );
})
Events.on(engine, 'collisionStart', function(event) {
var pairs = event.pairs;
for (var i = 0, j = pairs.length; i != j; ++i) {
var pair = pairs[i];
if (pair.bodyA.name === 'boost') {
// pair.bodyB.render.fillStyle = '#00FF00';
// Body.setVelocity(test, { x: 50, y: 0 });
} else if (pair.bodyB.name === 'boost') {
if (pair.bodyB.name === 'boost') {
pair.bodyA.render.fillStyle = '#00FF00';
Body.setVelocity(test, { x: 50, y: 0 });
Body.setVelocity(ball, { x: 50, y: 0 });
// bell.triggerAttackRelease(300);
}else if(pair.bodyB.name === 'bulletTime') {
ball.render.sprite.texture = 'img/ball-bullettime.svg'
bulletTime = true
}else if(pair.bodyB.name === 'jump') {
Body.setVelocity(ball, { x: ball.speed, y: -50 });
}
}
});
......
var s1 = new Tone.MembraneSynth().toMaster();
// track
var bell = new Tone.MetalSynth({
"harmonicity" : 13,
"resonance" : 100,
"modulationIndex" : 10,
"octaves":3.7,
"envelope" : {
"attack": 0.01,
"decay" : 0.46,
"sustain":0,
"release":4
},
"volume" : -15
}).toMaster();
var bellPart = new Tone.Sequence(function(time, freq){
bell.frequency.setValueAtTime(freq, time, Math.random()*0.5 + 0.5);
bell.triggerAttack(time);
}, [[300, null, 200],
[null, 200, 200],
[null, 200, null],
[200, null, 200]
], "4n").start(0);
// bellPart.loop = true;
// bellPart.loopEnd = "1m";
var conga = new Tone.MembraneSynth({
"pitchDecay" : 0.008,
"octaves" : 2,
"envelope" : {
"attack" : 0.0006,
"decay" : 0.5,
"sustain" : 0
}
}).toMaster();
var congaPart = new Tone.Sequence(function(time, pitch){
conga.triggerAttack(pitch, time, Math.random()*0.5 + 0.5);
}, ["G3", "C4", "C4", "C4"], "4n").start(0);
// congaPart.loop = true;
// congaPart.loopEnd = "1m";
Tone.Transport.bpm.value = 95;
// var p = document.querySelectorAll(".play")[0]
// p.addEventListener('click',function(){
// Tone.Transport.toggle()
// })
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment