Skip to content

Commit

Permalink
Remove ability to force the result
Browse files Browse the repository at this point in the history
  • Loading branch information
nmss committed Jan 5, 2016
1 parent aac8c27 commit 8956dc8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 107 deletions.
52 changes: 28 additions & 24 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# =========================
# Operating System Files
# =========================

# OSX
# =========================

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# =========================
# Operating System Files
# =========================

# OSX
# =========================

.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon
Icon


# Thumbnails
._*
Expand All @@ -41,3 +42,6 @@ Icon
Network Trash Folder
Temporary Items
.apdisk

typings
.vscode
6 changes: 0 additions & 6 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,3 @@ body {
.collection {
margin: 0;
}

.force {
position: relative;
top: -22px;
left: 70%;
}
16 changes: 0 additions & 16 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@
On
</label>
</div>
<div class="force">
<input type="checkbox" class="filled-in" id="force-planet-0">
<label for="force-planet-0">Force</label>
</div>
</a>

<a href="#!" class="collection-item">
Expand All @@ -54,10 +50,6 @@
On
</label>
</div>
<div class="force">
<input type="checkbox" class="filled-in" id="force-planet-1">
<label for="force-planet-1">Force</label>
</div>
</a>

<a href="#!" class="collection-item">
Expand All @@ -70,10 +62,6 @@
On
</label>
</div>
<div class="force">
<input type="checkbox" class="filled-in" id="force-planet-2">
<label for="force-planet-2">Force</label>
</div>
</a>

<a href="#!" class="collection-item">
Expand All @@ -86,10 +74,6 @@
On
</label>
</div>
<div class="force">
<input type="checkbox" class="filled-in" id="force-planet-3">
<label for="force-planet-3">Force</label>
</div>
</a>
</section>
</section>
Expand Down
63 changes: 2 additions & 61 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
var drawingCanvas = document.getElementById('canvas');
var statusLabel = document.getElementById('status_label');
var resultPanel = document.getElementById('result_panel');
var menuForces = document.querySelectorAll('.force input');

var particles = [];
var segments = [];
Expand All @@ -18,8 +17,6 @@
var mouseBody = null;
var mouseConstraint = null;
var playerName = null;
var forcedPlanet = null;
var segmentPercent = null;

//adapt angularVelocity to tend toward 20
var targetSpeed = 20;
Expand Down Expand Up @@ -157,8 +154,7 @@
updatePosition();

var angularVelocity = wheel.body.angularVelocity;
var clockwiseRotation = angularVelocity > 0;
var minVelocity = forcedPlanet ? 0.2 : 0.05;
var minVelocity = 0.05;

if (!wheelSpinning || wheelStopped || Math.abs(angularVelocity) >= minVelocity) {
return;
Expand All @@ -167,30 +163,7 @@
var score = wheel.getScore();
var currentPlanet = wheel.segments[score];

if (!forcedPlanet) {
return handleRotationEnding(currentPlanet);
}

if (currentPlanet.id !== forcedPlanet.id) {
wheel.body.angularVelocity = clockwiseRotation ? minVelocity : -minVelocity;
return;
}

var currentSegmentPercent = clockwiseRotation ? wheel.getSegmentPercent(score) : 1 - wheel.getSegmentPercent(score);

if (!segmentPercent) {
segmentPercent = Math.random();
}

if (currentSegmentPercent < segmentPercent) {
var newVelocity = minVelocity * (1 - currentSegmentPercent / segmentPercent);
newVelocity = newVelocity > 0.05 ? newVelocity : 0.05;
wheel.body.angularVelocity = clockwiseRotation ? newVelocity : -newVelocity;
return;
}

segmentPercent = null;
handleRotationEnding(currentPlanet);
return handleRotationEnding(currentPlanet);
}

function draw() {
Expand Down Expand Up @@ -289,31 +262,6 @@
wheel.deltaPI = Math.PI * 2 / wheel.segments.length;
}

function onForceChange(e) {
if (e.target.checked) {
var disabledInputs = _.reject(menuForces, function(menuForce) {
return menuForce.id === e.target.id;
});
var disabledInputsLength = disabledInputs.length;

for (var i = 0; i < disabledInputsLength; i++) {
disabledInputs[i].setAttribute('disabled', 'disabled');
}

forcedPlanet = _.find(planets, {
id: parseInt(_.last(e.target.id))
});
return;
}

forcedPlanet = null;
var l = menuForces.length;

for (var j = 0; j < l; j++) {
menuForces[j].removeAttribute('disabled');
}
}

window.onload = function() {
initSegments();
initDrawingCanvas();
Expand Down Expand Up @@ -356,13 +304,6 @@
menuSwitches[i].addEventListener('change', onSwitchChange);
}

// Menu force buttons
l = menuForces.length;

for (var j = 0; j < l; j++) {
menuForces[j].addEventListener('change', onForceChange);
}

// Wheel Damping
var wheelDamping = document.getElementById('wheel_damping');
var wheelDampingLabel = document.getElementById('wheel_damping_label');
Expand Down

0 comments on commit 8956dc8

Please sign in to comment.