I'm following a book with the following code, I can't seem to make the lines between the circles show up. It seems to be because if I do
drawLine(context, 1, 1, 100, 100, 3);
it works, however if I do:
drawLine(context, untangleGame.circles[1].x, 1, 100, 100, 3);
It wont work. So my question is how do I access that value. This is an example from a book which used jQuery for this.
It is for this bit of code, which draws a line from the first circle to every other circle, it then iterates over the other circles:
for (var i = 0; i < untangleGame.circles.length; i++) {
var startPoint = untangleGame.circles[i];
for (var j = 0; j < i; j++) {
var endPoint = untangleGame.circles[j];
drawLine(context, startPoint.x, startPoint.y, endPoint.x, endPoint.y, 1);
untangleGame.lines.push(new Line(startPoint, endpoint,
untangleGame.thinLineThickness));
}
}
I have the example here:
The game I'm trying to follow is called untangle.
Aucun commentaire:
Enregistrer un commentaire