Commit cdaa1b17 authored by Raphaël Bastide's avatar Raphaël Bastide

Cursor, play / pause, layout more robust, more units to unlock

parent d0968963
......@@ -14,7 +14,6 @@ h1{
body.debug{
background:gray;
}
body {
font:24px/1.4em 'version 4';
background: #7ceb9f;
......@@ -22,24 +21,31 @@ body {
margin: 0;
padding: 0;
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
}
main{
display: flex;
}
canvas{
position: relative;
border-radius: 20px;
margin:90px 20px 20px 20px;
margin-top: 30px;
}
aside, main{
position: relative;
max-width: 1500px;
width:95%;
}
aside{
aside .inner{
position: absolute;
left: 0;
top: 0;
width: 100%;
z-index: 200;
justify-content: space-between;
display: flex;
top:10px;
max-width: 1500px;
padding: 0 0px;
margin: 0 20px;
width:100%;
z-index: 200;
}
.box{
border-radius: 10px;
......@@ -72,3 +78,19 @@ aside{
background: #35f531;
}
a{color: inherit;}
.pause-btn{
position: absolute;
right:10px;
bottom:10px;
width:44px;
text-align: center;
padding: 5px 10px;
border-radius: 20px;
}
.pause-btn:hover{background: white;}
.paused .pause-icon, .play-icon{display: none;}
.pause-icon, .paused .play-icon{display: block;}
.button{
cursor: url(../img/pointer.png) 0 0, auto;
}
......@@ -26,10 +26,10 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="3.959798"
inkscape:cx="80.265692"
inkscape:cy="108.4616"
inkscape:cx="68.737903"
inkscape:cy="115.48647"
inkscape:document-units="mm"
inkscape:current-layer="g516"
inkscape:current-layer="layer1"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
......@@ -119,8 +119,9 @@
<path
inkscape:connector-curvature="0"
id="path31"
d="m -11.2514,-266.29039 c -2.413819,-2.50218 -6.374377,-3.37828 -9.559538,-2.10414"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.8061564;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke" />
d="m -11.503888,-266.25672 c -2.413819,-2.50218 -6.121889,-3.41195 -9.30705,-2.13781"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.8061564;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke"
sodipodi:nodetypes="cc" />
<path
inkscape:connector-curvature="0"
id="path33"
......@@ -130,8 +131,8 @@
<path
inkscape:connector-curvature="0"
id="path39"
d="m -10.980213,-245.44452 c -10.09866,-3.40301 -18.838284,-0.92348 -19.589671,-2.3965"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.80615636;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke"
d="m -10.980213,-245.44452 c -10.09866,-3.40301 -18.905614,-0.68781 -19.657001,-2.16083"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.80615634;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke"
sodipodi:nodetypes="cc" />
<path
inkscape:connector-curvature="0"
......@@ -267,8 +268,9 @@
<path
inkscape:connector-curvature="0"
id="path346"
d="m -33.182562,-266.12452 c 1.386611,-1.811 3.942093,-0.48743 5.521065,-1.75066"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.80615634;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke" />
d="m -33.051636,-266.32687 c 1.386611,-1.811 4.174861,-1.08019 5.420566,-1.58163"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.80615634;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke"
sodipodi:nodetypes="cc" />
<path
inkscape:connector-curvature="0"
id="path348"
......@@ -352,10 +354,11 @@
d="m -14.520301,-241.15937 c 0.931361,-0.32736 1.94142,-0.42321 2.808962,-0.857"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.80615634;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke" />
<path
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.80615636;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke"
d="m -10.559662,-247.00193 c 0.09276,1.03551 -1.207439,2.83249 -0.403978,3.63599"
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.80615634;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke"
d="m -9.9873566,-247.94459 c -0.3785504,0.73251 -1.6787494,3.60682 -0.8752884,4.41032"
id="path864"
inkscape:connector-curvature="0" />
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.80615634;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke"
d="m -30.69135,-269.62584 c 2.174327,-1.1273 4.331997,-1.21919 6.463686,0.202 0.416733,0.27783 0.697104,0.62898 1.144611,0.808"
......@@ -363,9 +366,10 @@
inkscape:connector-curvature="0" />
<path
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.80615634;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke"
d="m -27.998148,-267.60585 c 0.891917,-0.0661 1.673715,-0.29332 2.423883,0.26933"
d="m -27.998148,-267.60585 c 0.171761,-0.54623 1.533531,-0.38678 2.423883,0.26933"
id="path878"
inkscape:connector-curvature="0" />
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.80615634;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke"
d="m -13.252863,-267.94251 c 1.331862,-2.45166 5.7951949,-0.23086 6.9349968,-1.75066"
......@@ -382,8 +386,8 @@
id="path892"
inkscape:connector-curvature="0" />
<path
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.80615634;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke"
d="m -23.285043,-249.22392 c 1.062432,2.61138 4.329454,2.40683 5.319075,-0.0673"
style="opacity:1;vector-effect:none;fill:#ec82be;fill-opacity:1;stroke:#000000;stroke-width:0.80615634;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke"
d="m -23.332653,-248.47847 c 1.062432,2.61138 4.329454,2.40683 5.319075,-0.0673"
id="path898"
inkscape:connector-curvature="0" />
<path
......@@ -416,6 +420,39 @@
d="m -13.791505,-264.97986 c 2.170348,0.93224 3.892047,2.77376 5.9923771,0.67333"
id="path914"
inkscape:connector-curvature="0" />
<path
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.80615634;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke"
d="m -36.818386,-268.00985 c 1.508933,-0.35031 2.708058,0.84088 3.972474,1.34666"
id="path916"
inkscape:connector-curvature="0" />
<path
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.80615634;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke"
d="m -5.0385962,-265.85519 c 1.5554548,1.06885 2.7276822,2.08733 4.64577399,2.08733"
id="path918"
inkscape:connector-curvature="0" />
<path
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.80615634;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke"
d="m -29.210089,-270.09717 c 1.508232,0.0502 2.790728,1.85939 3.838515,2.90722"
id="path928"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.80615634;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke"
d="m -11.350789,-267.26918 c 1.30615,-0.82505 1.6107925,-1.95266 3.215011,-1.95266"
id="path930"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
</g>
<path
style="opacity:1;vector-effect:none;fill:#ec82be;fill-opacity:1;stroke:#000000;stroke-width:0.80000001;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke"
d="m -26.900452,-267.72305 c -0.100712,0.32429 -0.0167,1.03227 -0.0167,1.33634"
id="path948"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="opacity:1;vector-effect:none;fill:#ec82be;fill-opacity:1;stroke:#000000;stroke-width:0.80000001;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke"
d="m -10.580307,-267.32215 c -0.06681,0.52203 -0.04189,1.06959 -0.167045,1.57021"
id="path950"
inkscape:connector-curvature="0" />
</g>
</svg>
......@@ -25,9 +25,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.4"
inkscape:cx="21.068821"
inkscape:cy="67.920754"
inkscape:zoom="7.9195959"
inkscape:cx="-401.61635"
inkscape:cy="-45.867897"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
......@@ -35,10 +35,10 @@
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-width="1080"
inkscape:window-height="1892"
inkscape:window-x="1920"
inkscape:window-y="0"
inkscape:window-width="1920"
inkscape:window-height="1024"
inkscape:window-x="0"
inkscape:window-y="868"
inkscape:window-maximized="1"
units="px"
inkscape:snap-bbox="true"
......@@ -146,5 +146,59 @@
inkscape:connector-curvature="0"
inkscape:export-xdpi="7.7399998"
inkscape:export-ydpi="7.7399998" />
<path
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#333333;stroke-width:2.5;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke"
d="m -157.37268,-249.2038 c -5.41605,-0.7028 -3.54275,-4.22118 -4.06919,-6.96284 -0.83584,-4.35301 -1.58492,-8.83887 1.36014,-10.3114 1.05894,-0.52947 4.45412,0.35009 5.10267,1.32292 0.35066,0.52598 4.5932,5.65342 -0.14679,9.32605 m 2.20785,-3.99467 c 1.50145,3.26743 4.36454,8.35095 4.36454,9.03171"
id="path825"
inkscape:connector-curvature="0"
sodipodi:nodetypes="csscccc" />
<path
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#333333;stroke-width:2.5;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke"
d="m -151.76626,-250.41405 c 5.27896,-1.34036 11.64153,-1.29461 16.81994,0 2.81721,0.87724 4.85338,4.14728 5.88748,7.52563 0.94348,3.08231 0.0606,4.97912 -2.76918,5.3728"
id="path827"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccsc" />
<path
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#333333;stroke-width:2.5;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke"
d="m -160.96936,-249.91587 c -2.19097,3.7944 3.53346,9.31658 3.53346,14.80985"
id="path833"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#333333;stroke-width:2.5;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke"
d="m -161.02667,-244.9334 c -8.31205,9.69228 5.85252,23.70912 12.86298,25.94215 0.77221,5.86536 10.64474,1.78584 14.12157,1.29771 2.30925,-0.32421 3.9011,-1.85673 4.31827,-3.66317 0.22143,-0.95887 0.15981,-2.85761 -0.0824,-3.47033"
id="path835"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccssc" />
<path
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#333333;stroke-width:2.5;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke"
d="m -129.84364,-223.95572 c 2.02174,-5.27369 2.07887,-9.92202 0.70871,-15.30804"
id="path837"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#333333;stroke-width:2.5;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke"
d="m -142.3475,-225.48195 c -0.62835,-0.95479 -2.95208,-2.15642 -4.98976,-2.39392"
id="path841"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#333333;stroke-width:2.5;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke"
d="m -148.59373,-223.37719 c 0.162,2.09238 0.0995,5.03702 2.30144,5.79297"
id="path843"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#333333;stroke-width:2.5;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke"
d="m -142.76738,-220.48851 c 1.50135,-0.89831 5.13085,-1.46466 6.18936,-1.46466"
id="path845"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#333333;stroke-width:2.5;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.98431373;paint-order:fill markers stroke"
d="m -136.33565,-223.40363 c 1.50013,-2.74181 4.3615,-2.67362 6.01164,-2.27097"
id="path847"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
</g>
</svg>
This diff is collapsed.
......@@ -12,18 +12,26 @@
</head>
<body>
<aside>
<h1>burl</h1>
<details id="inventory" class="box"></details>
<details id="infobox" class="box">
<summary>Info</summary>
</details>
<details id="help" class="box">
<summary>Help</summary>
<p>To make a track for the ball, add some characters after a “#” in this url, just like that: <a href="#dff">#dff</a>.</p><p>Available characters are listed in the inventory.</p>
<p>Some characters need to be unlocked by making the ball touch bonuses.</p>
<p class="credits">Burl is an experiment by <a href="https://raphaelbastide.com/">Raphaël Bastide</a>.<br><a href="https://gitlab.com/raphaelbastide/burl">Sources on Gitlab</a> <br>→ Dedicated <a href="http://reddit.com/r/burl">subReddit</a><br><a href="https://niu.moe/@burl">Burl on Mastodon</a></p>
</details>
<div class="inner">
<h1>burl</h1>
<details id="inventory" class="box button"></details>
<details id="infobox" class="box button">
<summary>Info</summary>
</details>
<details id="help" class="box button">
<summary>Help</summary>
<p>To make a track for the ball, add some characters after a “#” in this url, just like that: <a href="#dff">#dff</a>.</p><p>Available characters are listed in the inventory.</p>
<p>Some characters need to be unlocked by making the ball touch bonuses.</p>
<p class="credits">Burl is an experiment by <a target="_blank href="https://raphaelbastide.com/">Raphaël Bastide</a>.<br><a target="_blank href="https://gitlab.com/raphaelbastide/burl">Sources on Gitlab</a> <br>→ Dedicated <a target="_blank" href="http://reddit.com/r/burl">subReddit</a><br><a href="https://niu.moe/@burl">Burl on Mastodon</a></p>
</details>
</div>
</aside>
<main>
<span class="pause-btn button">
<span class="play-icon"></span>
<span class="pause-icon"></span>
</span>
</main>
<script type="text/javascript" src="lib/decomp.js"></script>
<script type="text/javascript" src="lib/pathseg.js"></script>
<script src="lib/matter.min.js"></script>
......
var d = document,
infobox = d.getElementById("infobox"),
inventory = d.getElementById('inventory')
inventory = d.getElementById('inventory'),
body = d.getElementsByTagName("body")[0]
function preloadImgs() {
var images = ['img/burl-ball.svg','img/burl-bonus.svg'];
for (var i = 0; i < arguments.length; i++) {
images[i] = new Image();
images[i].src = preload.arguments[i];
}
}
preloadImgs()
function getDistances(unit){
var realW = unit.bounds.max.x - unit.bounds.min.x
......
......@@ -123,6 +123,27 @@
"posX": 3300,
"posY": 200,
"unlocks":"jump"
},
{
"name": "bonus4",
"role": "bonus",
"posX": 4800,
"posY": 100,
"unlocks":"invertedGravity"
},
{
"name": "bonus5",
"role": "bonus",
"posX": 8800,
"posY": 100,
"unlocks":"bulletTime"
},
{
"name": "bonus6",
"role": "bonus",
"posX": 12800,
"posY": 700,
"unlocks":"teleport"
}
]
}
......@@ -13,7 +13,8 @@ function launch(units, isRefresh){
Body = Matter.Body,
Events = Matter.Events;
var debug = false,
body = document.getElementsByTagName('body')[0],
main = d.getElementsByTagName('main')[0],
pauseBtn = d.querySelectorAll(".pause-btn")[0],
startX = 100,
startY = 300,
nextPos = 0,
......@@ -42,7 +43,6 @@ function launch(units, isRefresh){
c.parentElement.removeChild(c)
resetInfo()
}
// Listen to the URL hash change
window.onhashchange = locationHashChanged;
function locationHashChanged() {
......@@ -55,13 +55,12 @@ function launch(units, isRefresh){
// create engine
var engine = Engine.create(),
world = engine.world;
engine.world.gravity.y = 1;
// create renderer
engine.world.gravity.y = 1,
engine.enableSleeping = true
var render = Render.create({
element: document.body,
element: main,
engine:engine,
options: {
options: {
wireframes:false,
width: canvasW,
height: canvasH,
......@@ -69,6 +68,13 @@ function launch(units, isRefresh){
}
});
Render.run(render);
var runner = Runner.create();
runner.isFixed = true
Runner.run(runner, engine);
// Engine.run(engine);
// create renderer
var hash = testHash(data)
if (hash) {
for (var i = 0; i < hash.length; i++) {
......@@ -101,58 +107,57 @@ function launch(units, isRefresh){
// Building terrain from the character array
function buildUnit(char, nextPos){
var unit = findObjectsByKey(data.units, 'char', char)[0];
if (unit.role === "buildPlace") {
console.log('t');
nextPos.x += 0
nextPos.y += unit.verticalShift
}else{
if (unit.verticalShift == 1) {
var posX = nextPos.x
var posY = nextPos.y + (unit.angle * 550)
}else if (unit.verticalShift == 0) {
var posX = nextPos.x + 35
var posY = nextPos.y + (unit.angle * 550)
}else if (unit.verticalShift == -1) {
var posX = nextPos.x
var posY = nextPos.y + (unit.angle * 550)
}
buildW += buildW * Math.round(Math.abs(unit.angle))
var toBuild = Bodies.rectangle(posX, posY, buildW - strokeWidth*2, buildH - strokeWidth*2, {isStatic:unit.isStatic,angle: Math.PI * unit.angle})
if (debug) {
toBuild.isLocked = false
}else {
toBuild.isLocked = unit.isLocked
}
toBuild.name = unit.name
if (checkLock(unit) === false || debug) { // if unlocked
toBuild.isSensor = unit.isSensor
toBuild.render.fillStyle = unit.color
toBuild.render.lineWidth = strokeWidth
}else{ // if locked
toBuild.isSensor = true
toBuild.render.lineWidth = 1
toBuild.render.fillStyle = "#ffffff00"
}
if (toBuild.name === "gap") {
toBuild.render.strokeStyle = "#ffffff00"
}else {
toBuild.render.strokeStyle = "black"
}
getDistances(toBuild)
if (toBuild != null) {
World.add(world,toBuild);
}
if (unit.verticalShift == 1) {
nextPos.x += Math.round(toBuild.distances.w)
nextPos.y -= Math.round(toBuild.distances.h) - realBuildH / 2
}else if (unit.verticalShift == 0) {
nextPos.x += Math.round(toBuild.distances.w)
nextPos.y += Math.round(toBuild.distances.h) - realBuildH / 2
}else {
nextPos.x += Math.round(toBuild.distances.w)
nextPos.y += Math.round(toBuild.distances.h) - realBuildH / 2 + 10
}
if (unit.role === "buildPlace") {
nextPos.x += 0
nextPos.y += unit.verticalShift
}else{
if (unit.verticalShift == 1) {
var posX = nextPos.x
var posY = nextPos.y + (unit.angle * 550)
}else if (unit.verticalShift == 0) {
var posX = nextPos.x + 35
var posY = nextPos.y + (unit.angle * 550)
}else if (unit.verticalShift == -1) {
var posX = nextPos.x
var posY = nextPos.y + (unit.angle * 550)
}
buildW += buildW * Math.round(Math.abs(unit.angle))
var toBuild = Bodies.rectangle(posX, posY, buildW - strokeWidth*2, buildH - strokeWidth*2, {isStatic:unit.isStatic,angle: Math.PI * unit.angle})
if (debug) {
toBuild.isLocked = false
}else {
toBuild.isLocked = unit.isLocked
}
toBuild.name = unit.name
if (checkLock(unit) === false || debug) { // if unlocked
toBuild.isSensor = unit.isSensor
toBuild.render.fillStyle = unit.color
toBuild.render.lineWidth = strokeWidth
}else{ // if locked
toBuild.isSensor = true
toBuild.render.lineWidth = 1
toBuild.render.fillStyle = "#ffffff00"
}
if (toBuild.name === "gap") {
toBuild.render.strokeStyle = "#ffffff00"
}else {
toBuild.render.strokeStyle = "black"
}
getDistances(toBuild)
if (toBuild != null) {
World.add(world,toBuild);
}
if (unit.verticalShift == 1) {
nextPos.x += Math.round(toBuild.distances.w)
nextPos.y -= Math.round(toBuild.distances.h) - realBuildH / 2
}else if (unit.verticalShift == 0) {
nextPos.x += Math.round(toBuild.distances.w)
nextPos.y += Math.round(toBuild.distances.h) - realBuildH / 2
}else {
nextPos.x += Math.round(toBuild.distances.w)
nextPos.y += Math.round(toBuild.distances.h) - realBuildH / 2 + 10
}
}
}
function unlockFromBonus(bonus){
......@@ -220,7 +225,6 @@ function launch(units, isRefresh){
var pair = pairs[i];
var b1 = pair.bodyB
var b2 = pair.bodyA // can differ accordins to World.add order
// console.log(pair);
var col = b2.render.fillStyle
if (col !== "#ffffff00") { // If not transparent, highlight the color when collision
col = col.substring(0, col.length - 2);
......@@ -230,7 +234,7 @@ function launch(units, isRefresh){
if (b2.name === 'boost' && !b1.inactiveBuffer) {
b1.render.fillStyle = '#00FF00';
Body.setVelocity(ball, { x: 40, y: 0 });
b1.inactiveBuffer = true
// b1.inactiveBuffer = true
}else if(b2.name === 'bulletTime') {
ball.render.sprite.texture = 'img/burl-bullettime.svg'
bulletTime = true
......@@ -242,7 +246,6 @@ function launch(units, isRefresh){
}else if(b2.name === 'jump') {
Body.setVelocity(ball, { x: ball.speed, y: -30 });
}else if(b2.name === 'invertedGravity') {
console.log('i');
if (engine.world.gravity.y == -1) {
engine.world.gravity.y = 1;
}else {
......@@ -265,9 +268,18 @@ function launch(units, isRefresh){
}
});
World.add(world, [ball]);
var runner = Runner.create();
runner.isFixed = true
Engine.run(engine);
Render.run(render);
pauseBtn.addEventListener('click',function(){
if (body.classList.contains('paused')) {
body.classList.remove('paused')
Render.run(render);
Runner.run(runner, engine); // Render.run(engine)
}else {
body.classList.add('paused')
Render.stop(render);
Runner.stop(runner, engine);
}
})
} // end launch()
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