|
29 | 29 | // https://stackoverflow.com/questions/11382495/how-to-be-sure-that-message-via-socket-io-has-been-received-to-the-client
|
30 | 30 | //
|
31 | 31 | // TO DO: middle mouse click = focus
|
32 |
| -// TO DO: Shift-c reverse-sorts? |
| 32 | +// TO DO: Shift-c sort? |
33 | 33 | // TO DO: Find a way to switch back to the more responsive piece rotation in board.draw(). (Make incremental changes to piece coordinates, rather than setting targets?)
|
34 | 34 | // TO DO: Add new_piece_layer integer for automatic layered drawing. It has to naturally stay sorted, or
|
35 | 35 | // else is_tray will not work, and selecting pieces would be a problem. Perhaps board.pieces should be {0:[], 1:[], ...}?
|
36 | 36 | // Alternatively, insert_piece() could auto-sort by checking piece layers and incrementing/decrementing when out of order.
|
37 |
| -// TO DO: Server supplies a unique game id so you can work with multiple games of the same type? This would mean |
38 |
| -// setting up your views every time... |
| 37 | +// TO DO: Cookies assigned per web address AND game name. |
39 | 38 |
|
40 | 39 | //// OPTIONS
|
41 | 40 |
|
@@ -187,7 +186,7 @@ function scramble_pieces(pieces, x, y, space, scale) {
|
187 | 186 | // x,y,r, angle,disable_snap,immediate
|
188 | 187 | p.set_target(x + d.n*a.x + d.m*b.x + v.x,
|
189 | 188 | y + d.n*a.y + d.m*b.y + v.y,
|
190 |
| - (Math.random()-0.5)*720*scale, null, null, false); |
| 189 | + (Math.random()-0.5)*720*scale, null, true, false); |
191 | 190 | p.active_image = rand_int(0, p.images.length-1);
|
192 | 191 | }
|
193 | 192 | }
|
@@ -310,10 +309,7 @@ function rotate_pieces(pieces, r_deg, immediate, x, y) {
|
310 | 309 |
|
311 | 310 | // Get the center of the current target coordinates, and the origin target coordinates
|
312 | 311 | if(x == null || y == null) var d = get_center_of_pieces(pieces);
|
313 |
| - else var d = { |
314 |
| - x :x, |
315 |
| - y :y, |
316 |
| - }; |
| 312 | + else var d = {x:x,y:y}; |
317 | 313 |
|
318 | 314 | for(var i in pieces) pieces[i].rotate(r_deg, d.x, d.y, immediate);
|
319 | 315 | }
|
@@ -624,7 +620,7 @@ function PIECE(board, piece_id, image_paths, private_image_paths) {
|
624 | 620 | PIECE.prototype.put_away = function() {
|
625 | 621 |
|
626 | 622 | // x,y,r,angle,disable_snap,immediate
|
627 |
| - this.set_target(this.board.box_x+this.box_x, this.board.box_y+this.box_y, 0, null, null, false); |
| 623 | + this.set_target(this.board.box_x+this.box_x, this.board.box_y+this.box_y, 0, null, true, false); |
628 | 624 | return this;
|
629 | 625 | }
|
630 | 626 |
|
@@ -654,17 +650,20 @@ PIECE.prototype.get_dimensions = function() {
|
654 | 650 | return {width: w, height: h, max: Math.max(w, h), min: Math.min(w, h)};
|
655 | 651 | }
|
656 | 652 |
|
657 |
| -// set the target location and rotation all then rotated by angle |
| 653 | +// set the target location x,y and rotation r, and everything rotated about the board origin by angle |
658 | 654 | PIECE.prototype.set_target = function(x,y,r,angle,disable_snap,immediate) {
|
659 | 655 |
|
660 | 656 | // Set default argument values
|
661 | 657 | x = or_default(x, this.x_target);
|
662 | 658 | y = or_default(y, this.y_target);
|
663 | 659 | r = or_default(r, null);
|
664 |
| - angle = or_default(angle, null); |
| 660 | + angle = or_default(angle, null); |
665 | 661 | disable_snap = or_default(disable_snap, false);
|
666 | 662 | immediate = or_default(immediate, false);
|
667 |
| - |
| 663 | + |
| 664 | + // Always disable if held. This causes a single piece to not be let go on mouseup! |
| 665 | + //disable_snap = disable_snap || board.find_holding_client_index(this) >= 0; |
| 666 | + |
668 | 667 | // if we're supposed to transform the coordinates
|
669 | 668 | if(angle != null) {
|
670 | 669 | var v = rotate_vector(x, y, angle);
|
@@ -745,7 +744,7 @@ PIECE.prototype.rotate = function(r_deg, x0, y0, immediate) {
|
745 | 744 | // If specified, rotate about the supplied center coordinate
|
746 | 745 | if(x0 != this.x_target || y0 != this.y_target) {
|
747 | 746 | var d = rotate_vector(this.x_target-x0, this.y_target-y0, -r_deg);
|
748 |
| - this.set_target(x0 + d.x, y0 + d.y, r_deg + this.r_target, null, null, immediate); |
| 747 | + this.set_target(x0 + d.x, y0 + d.y, r_deg + this.r_target, null, true, immediate); |
749 | 748 | }
|
750 | 749 |
|
751 | 750 | // Otherwise rotate around its center.
|
@@ -1624,7 +1623,7 @@ BOARD.prototype.collect_pieces = function(pieces,x,y,shuffle,active_image,r_piec
|
1624 | 1623 | // x,y,r,angle,disable_snap,immediate
|
1625 | 1624 | pieces[n].set_target(pieces[n].x + (Math.random()-0.5)*this.shuffle_distance,
|
1626 | 1625 | pieces[n].y + (Math.random()-0.5)*this.shuffle_distance,
|
1627 |
| - (Math.random()-0.5)*720, null, null, true); |
| 1626 | + (Math.random()-0.5)*720, null, true, true); |
1628 | 1627 |
|
1629 | 1628 | // Trigger an update to tell everyone the new locations
|
1630 | 1629 | this.send_stream_update();
|
@@ -1656,7 +1655,7 @@ BOARD.prototype.collect_pieces = function(pieces,x,y,shuffle,active_image,r_piec
|
1656 | 1655 | else {x = x+d.x; y = y-d.y;}
|
1657 | 1656 |
|
1658 | 1657 | // x, y, r, angle, disable_snap, immediate
|
1659 |
| - p.set_target(x, y, -r_piece, null, null, false); |
| 1658 | + p.set_target(x, y, -r_piece, null, true, false); |
1660 | 1659 |
|
1661 | 1660 | // If we have an active image specified, set it
|
1662 | 1661 | if(active_image != null) p.set_active_image(active_image);
|
@@ -1728,7 +1727,7 @@ BOARD.prototype.expand_pieces = function(pieces, number_per_row, x, y, spacing_x
|
1728 | 1727 | sps.push(p);
|
1729 | 1728 |
|
1730 | 1729 | // Now set the coordinates x,y,r,angle,disable_snap,immediate
|
1731 |
| - p.set_target(x+d.x,y+d.y,r_piece-this.r_target, null, null, false); |
| 1730 | + p.set_target(x+d.x,y+d.y,r_piece-this.r_target, null, true, false); |
1732 | 1731 |
|
1733 | 1732 | // Set the image
|
1734 | 1733 | if(active_image != null) p.active_image = active_image;
|
|
0 commit comments