daily pastebin goal
57%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   hand = (function() {
  2.     function hand() {
  3.       this.held_item = null;
  4.     }
  5.     hand.prototype.interact_at = function(x, y) {
  6.       if (this.held_item !== null) {
  7.         return this.drop_tile_if_over_it(x, y);
  8.       } else {
  9.         return this.pick_up_tile_if_over_it(x, y);
  10.       }
  11.     };
  12.     hand.prototype.move_to = function(x, y) {
  13.       if (this.held_item !== null) {
  14.         return this.held_item.drag_to(x, y);
  15.       }
  16.     };
  17.     hand.prototype.can_interact_with = function(touchable_game_pieces) {
  18.       return this.game_pieces = touchable_game_pieces;
  19.     };
  20.     hand.prototype.drop_tile_if_over_it = function(x, y) {
  21.       var game_piece, _i, _len, _ref, _results;
  22.       _ref = this.game_pieces;
  23.       _results = [];
  24.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  25.         game_piece = _ref[_i];
  26.         if (game_piece.is_at(x, y)) {
  27.           this.held_item = null;
  28.           break;
  29.         }
  30.       }
  31.       return _results;
  32.     };
  33.     hand.prototype.pick_up_tile_if_over_it = function(x, y) {
  34.       var game_piece, _i, _len, _ref, _results;
  35.       _ref = this.game_pieces;
  36.       _results = [];
  37.       for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  38.         game_piece = _ref[_i];
  39.         if (game_piece.is_at(x, y)) {
  40.           this.held_item = game_piece;
  41.           this.held_item.start_dragging(x, y);
  42.           break;
  43.         }
  44.       }
  45.       return _results;
  46.     };
  47.     return hand;
  48.   })();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top