Sputnik = function(pos,curPoint,nextPoint,path)
{
var self = this;
this.pos = pos;
this.curPoint = curPoint;
this.nextPoint = nextPoint;
this.path = path;
this.move = function (item)
{
//Хочешь идти? - Иди.
console.log("move " + item.pos);
item.pos++;
};
this.atPoint = function(item)
{
//Пришел в точку? - Топай в следующую.
var nextCount = item.curPoint.next.length;
if (nextCount > 0)
item.nextPoint = self.path.findPoint(item.curPoint.next[MathTools.getRandomInt(0,nextCount - 1)]);
};
this.draw = function(ctx,x,y)
{
//Пришла пора рисовать? - Рисуй синие квадраты.
ctx.fillStyle = "#00F";
ctx.fillRect(x - 10,y - 10,20,20);
};
}