|
|
@ -52,13 +52,15 @@
|
|
52
|
52
|
return p !== undefined && p.color !== "white";
|
|
53
|
53
|
}
|
|
54
|
54
|
|
|
55
|
|
pixl.draw_pixl = function(pos, color) {
|
|
|
55
|
pixl.draw_pixl = function(pos, color, options) {
|
|
56
|
56
|
var color = color || "black";
|
|
57
|
57
|
pixl.ctx.fillStyle = color;
|
|
58
|
58
|
var screen_pos = pixl.to_screen(pos);
|
|
59
|
59
|
pixl.ctx.fillRect(screen_pos.x, screen_pos.y, pixl.size, pixl.size);
|
|
60
|
60
|
pixl.world[pos.x + "," + pos.y] = {color: color};
|
|
61
|
|
if (pixl.online && !pos.remote) {
|
|
|
61
|
|
|
|
62
|
var options = options || {send: true};
|
|
|
63
|
if (pixl.online && options.send) {
|
|
62
|
64
|
pixl.ws.send(JSON.stringify([{x: pos.x, y: pos.y, color: color}]));
|
|
63
|
65
|
}
|
|
64
|
66
|
}
|
|
|
@ -74,7 +76,7 @@
|
|
74
|
76
|
for (var y = -h2; y < h2; y++) {
|
|
75
|
77
|
var pt = pixl.world[[x, y]];
|
|
76
|
78
|
if (pt !== undefined) {
|
|
77
|
|
pixl.draw_pixl({x: x, y: y}, pt.color);
|
|
|
79
|
pixl.draw_pixl({x: x, y: y}, pt.color, {send: false});
|
|
78
|
80
|
}
|
|
79
|
81
|
}
|
|
80
|
82
|
}
|
|
|
@ -158,9 +160,7 @@
|
|
158
|
160
|
var obj = JSON.parse(msg.data);
|
|
159
|
161
|
if (obj.length !== undefined) {
|
|
160
|
162
|
obj.forEach(function(p) {
|
|
161
|
|
p.remote = true;
|
|
162
|
|
pixl.world[p.x + "," + p.y] = {color: p.color};
|
|
163
|
|
pixl.draw_pixl(p, p.color);
|
|
|
163
|
pixl.draw_pixl(p, p.color, {send: false});
|
|
164
|
164
|
});
|
|
165
|
165
|
} else {
|
|
166
|
166
|
pixl.world = obj;
|