Time for action – distinguishing the intersected lines
Let's increase the thickness of those intersected lines so we can distinguish them in the Canvas
- Open the
untangle.drawing.js
file in the text editor. - We have the
thinLineThickness
variable as the default line thickness. We add the following code to define a thickness for bold lines:untangleGame.boldLineThickness = 5;
- Open the
untangle.data.js
file. We create a function to check whether the given two lines intersect. Add the following functions to the end of the JavaScript file:untangleGame.isIntersect = function(line1, line2) { // convert line1 to general form of line: Ax+By = C var a1 = line1.endPoint.y - line1.startPoint.y; var b1 = line1. startPoint.x - line1.endPoint.x; var c1 = a1 * line1.startPoint.x ...
Get HTML5 Game Development by Example : Beginner's Guide - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.