Skip to content

Commit

Permalink
moved solves out of touchmove() and into update()
Browse files Browse the repository at this point in the history
  • Loading branch information
djbutler committed Feb 26, 2016
1 parent c499182 commit 375ea19
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions avoider/avoider.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<script>

var circle = {x: -100, y: -100};
var cursor = {x: -100, y: -100};
var radius = 30;
var thickness = 10;
var solver;
Expand All @@ -26,8 +27,12 @@
solver = new Module.AvoiderSolver;
},
touchmove: function() {
solver.goal_pose = [this.touches[0].x, this.touches[0].y];
solver.stepSolve(10);
cursor.x = this.touches[0].x;
cursor.y = this.touches[0].y;
solver.goal_pose = [cursor.x, cursor.y];
},
update: function() {
solver.timeSolve(0.1);
circle.x = solver.current_pose[0];
circle.y = solver.current_pose[1];
},
Expand All @@ -38,7 +43,7 @@
this.strokeStyle = '#333333';
this.lineCap = 'round';
this.moveTo(circle.x, circle.y);
this.lineTo(this.touches[0].x, this.touches[0].y);
this.lineTo(cursor.x, cursor.y);
this.stroke();
// draw annulus that avoids the cursor
this.beginPath();
Expand Down

0 comments on commit 375ea19

Please sign in to comment.