Create collidable items
13302
def create_items(self):
        
        if not self.mode['items'] or len(self.mode['items']) == 0: return

        # FIXME: Check if already contains
        self.collman.add(self.player)

        for k in self.mode['items']:
            item = self.mode['items'][k]
            #{'terminal': False, 'num': 50, 'scale': 1.0, 'reward': 2.0}
            radius = item['scale'] * self.player.radius
            for i in range(item['num']):
                self.add_item(radius, k)
1361261
def do_create_tool_item(self):
        """"""
        proxy = SpinToolItem(*self._args_for_toolitem)
        self.connect_proxy(proxy)
        return proxy
1176724
def draw(self, milliseconds, surface):
        """"""
        super(CollidableObj, self).draw(milliseconds, surface)
974122
def query_collision(collision_object):
        
        global collidable_objects
        # Note that we use a Brute Force approach for the time being.
        # It performs horribly under heavy loads, but it meets
        # our needs for the time being.
        for obj in collidable_objects:
            # Make sure we don't check ourself against ourself.
            if obj.obj_id is not collision_object.obj_id:
                if collision_object.is_colliding(obj):
                    # A collision has been detected. Return the object that we are colliding with.
                    return obj

        # No collision was noticed. Return None.
        return None
818802
public void createItems() {
        mItemAdapter.clear();

        int profileOffset = 0;
        if (mAccountHeader != null && mAccountHeader.getAccountHeaderBuilder().mProfileImagesVisible) {
            IProfile profile = mAccountHeader.getActiveProfile();
            if (profile instanceof IDrawerItem) {
                mItemAdapter.add(generateMiniDrawerItem((IDrawerItem) profile));
                profileOffset = 1;
            }
        }

        int select = -1;
        if (mDrawer != null) {
            if (getDrawerItems() != null) {
                //migrate to miniDrawerItems
                int length = getDrawerItems().size();

                int position = 0;
                for (int i = 0; i < length; i++) {
                    IDrawerItem miniDrawerItem = generateMiniDrawerItem(getDrawerItems().get(i));
                    if (miniDrawerItem != null) {
                        if (miniDrawerItem.isSelected()) {
                            select = position;
                        }
                        mItemAdapter.add(miniDrawerItem);
                        position = position + 1;
                    }
                }

                if (select >= 0) {
                    //+1 because of the profile
                    mAdapter.select(select + profileOffset);
                }
            }
        }

        //listener
        if (mOnMiniDrawerItemOnClickListener != null) {
            mAdapter.withOnClickListener(mOnMiniDrawerItemOnClickListener);
        } else {
            mAdapter.withOnClickListener(new OnClickListener<IDrawerItem>() {
                @Override
                public boolean onClick(View v, IAdapter<IDrawerItem> adapter, final IDrawerItem item, final int position) {
                    int type = getMiniDrawerType(item);

                    //if a listener is defined and we consume the event return
                    if (mOnMiniDrawerItemClickListener != null && mOnMiniDrawerItemClickListener.onItemClick(v, position, item, type)) {
                        return false;
                    }

                    if (type == ITEM) {
                        //fire the onClickListener also if the specific drawerItem is not Selectable
                        if (item.isSelectable()) {
                            //make sure we are on the original drawerItemList
                            if (mAccountHeader != null && mAccountHeader.isSelectionListShown()) {
                                mAccountHeader.toggleSelectionList(v.getContext());
                            }
                            IDrawerItem drawerItem = mDrawer.getDrawerItem(item.getIdentifier());
                            if (drawerItem != null && !drawerItem.isSelected()) {
                                //set the selection
                                mDrawer.setSelection(item, true);
                            }
                        } else if (mDrawer.getOnDrawerItemClickListener() != null) {
                            //get the original `DrawerItem` from the Drawer as this one will contain all information
                            mDrawer.getOnDrawerItemClickListener().onItemClick(v, position, DrawerUtils.getDrawerItem(getDrawerItems(), item.getIdentifier()));
                        }
                    } else if (type == PROFILE) {
                        if (mAccountHeader != null && !mAccountHeader.isSelectionListShown()) {
                            mAccountHeader.toggleSelectionList(v.getContext());
                        }
                        if (mCrossFader != null) {
                            mCrossFader.crossfade();
                        }
                    }
                    return false;
                }
            });
        }
        mAdapter.withOnLongClickListener(mOnMiniDrawerItemLongClickListener);
        mRecyclerView.scrollToPosition(0);
    }
1236738
private void mergeForceCollapse() {
        while (stackSize > 1) {
            int n = stackSize - 2;
            if (n > 0 && runLen[n - 1] < runLen[n + 1])
                n--;
            mergeAt(n);
        }
    }
1305068
function (time) {
    var el = this.el;
    var data = this.data;
    var intersectedEls;
    var intersections;
    var prevCheckTime = this.prevCheckTime;
    var prevIntersectedEls;

    // Only check for intersection if interval time has passed.
    if (prevCheckTime && (time - prevCheckTime < data.interval)) { return; }

    // Store old previously intersected entities.
    prevIntersectedEls = this.intersectedEls.slice();

    // Raycast.
    this.updateOriginDirection();
    intersections = this.raycaster.intersectObjects(this.objects, data.recursive);

    // Only keep intersections against objects that have a reference to an entity.
    intersections = intersections.filter(function hasEl (intersection) {
      return !!intersection.object.el;
    });

    // Update intersectedEls.
    intersectedEls = this.intersectedEls = intersections.map(function getEl (intersection) {
      return intersection.object.el;
    });

    // Emit intersected on intersected entity per intersected entity.
    intersections.forEach(function emitEvents (intersection) {
      var intersectedEl = intersection.object.el;
      intersectedEl.addState('hovered');
      intersectedEl.emit('raycaster-intersected', {el: el, intersection: intersection});
    });

    // Emit all intersections at once on raycasting entity.
    if (intersections.length) {
      el.emit('raycaster-intersection', {
        els: intersectedEls,
        intersections: intersections
      });
    }

    // Emit intersection cleared on both entities per formerly intersected entity.
    prevIntersectedEls.forEach(function checkStillIntersected (intersectedEl) {
      if (intersectedEls.indexOf(intersectedEl) !== -1) { return; }
      intersectedEl.removeState('hovered');
      el.emit('raycaster-intersection-cleared', {el: intersectedEl});
      intersectedEl.emit('raycaster-intersected-cleared', {el: el});
    });
  }
46855
function _resolveCollisionWithStationaryObject(collision, physicsParams) {
  const contactNormal = collision.contactNormal;

  let physicsCollidable;
  if (collision.collidableA.physicsJob) {
    physicsCollidable = collision.collidableA;
  } else {
    physicsCollidable = collision.collidableB;
    vec3.negate(contactNormal, contactNormal);
  }

  const previousState = physicsCollidable.physicsJob.previousState;
  const nextState = physicsCollidable.physicsJob.currentState;
  const center = physicsCollidable.centerOfMass;
  const contactPoint = collision.contactPoint;

  const contactPointOffset = tmpVec3;
  vec3.subtract(contactPointOffset, contactPoint, center);

  // Calculate the relative velocity of the bodies at the point of contact. We use the velocity from
  // the previous state, since it is the velocity that led to the collision.
  const velocity = vec3.create();
  vec3.cross(tmpVec1, previousState.angularVelocity, contactPointOffset);
  vec3.add(velocity, previousState.velocity, tmpVec1);

  if (vec3.dot(velocity, contactNormal) <= 0) {
    // If the relative velocity is not pointing against the normal, then the normal was calculated
    // incorrectly (this is likely due to the time step being too large and the fact that our
    // contact calculations don't consider velocity). So update the contact normal to be in the
    // direction of the relative velocity.

    // TODO: Check that this works as expected.

    console.warn('Non-collision because object is moving away from stationary object.');

    vec3.copy(collision.contactNormal, velocity);
    vec3.normalize(collision.contactNormal, collision.contactNormal);
    vec3.negate(collision.contactNormal, collision.contactNormal);
  }

  _applyImpulseFromCollisionWithStationaryObject(physicsCollidable, collision, velocity,
      contactPointOffset, physicsParams);

  // Revert to the position and orientation from immediately before the collision.
  vec3.copy(nextState.position, previousState.position);
  quat.copy(nextState.orientation, previousState.orientation);

  // Also revert the collidable's position and orientation.
  physicsCollidable.position = previousState.position;
  physicsCollidable.orientation = previousState.orientation;

  nextState.updateDependentFields();
}
406725
function _resolveCollisions(collisions, physicsParams) {
  collisions.forEach(collision => {
    // If neither physics job needs the standard collision restitution, then don't do it.
    if (_notifyPhysicsJobsOfCollision(collision)) {
      if (collision.collidableA.physicsJob && collision.collidableB.physicsJob) {
        // Neither of the collidables is stationary.
        _resolveCollision(collision, physicsParams);
      } else {
        // One of the two collidables is stationary.
        _resolveCollisionWithStationaryObject(collision, physicsParams);
      }
    }
  });
}
1266233
def append_item *args
      options = args.extract_options!
      target = args.first
      self.items.create options.slice(:position).merge(:target => target)
    end
439792
def check_collision(self, other):
        """"""
        other = Network(other)
        return self.network_long() <= other.network_long() <= self.broadcast_long() or \
            other.network_long() <= self.network_long() <= other.broadcast_long()
432216
function() {
        // clear the background
        me.game.world.addChild(new me.ColorLayer("background", "#000000", 0), 0);
        // add a few squares
        me.game.world.addChild(new game.square(200, 230, {width: 100, height: 100}), 1);

        // add a droptarget entity
        me.game.world.addChild(new game.droptarget(400, 200, {width: 200, height: 150}), 1);

        // add another droptarget entity
        me.game.world.addChild(new game.droptarget2(400, 400, {width: 200, height: 150}), 1);
    }
167466
def collide_point(self, x, y):
        
        if not self.collider:
            return False
        return (x, y) in self.collider
81990
function CollisionMatrix(x, y, r) {
    this.resolution = r;
    this.xc = x;
    this.yc = y;
    this.matrix = new Array(x);
    for (var i = 0; i <= (x + 5); i++) {
        this.matrix[i] = new Array(y);
        for (var j = 0; j <= (y + 5); ++j) {
            this.matrix[i][j] = new DropItem(null);
        }
    }
}
104683
private void addPoint(Point point, Collidable collidable)
    {
        final Integer group = collidable.getGroup();
        if (!collidables.containsKey(group))
        {
            collidables.put(group, new HashMap<Point, Set<Collidable>>());
        }
        final Map<Point, Set<Collidable>> elements = collidables.get(group);
        if (!elements.containsKey(point))
        {
            elements.put(point, new HashSet<Collidable>());
        }
        elements.get(point).add(collidable);
    }
1269178
def add(bullet, *items)
      items.each do |item|
        @bullet_data << [bullet.to_s, item]
        bullet = ""
      end
    end
304271
def is_colliding(self, other):
        """"""
        if isinstance(other, BoundingCircle):
            #Calculate the distance between two circles.
            distance = Vector2.distance(self.coords, other.coords)

            #Check to see if the sum of thier radi are greater than or equal to the distance.
            radi_sum = self.radius + other.radius

            if distance <= radi_sum:
                #There has been a collision
##                print "Distance: ", distance, "\nRadi Sum: ", radi_sum
##                print "Self Coords: ", self.coords, "\nOther Coords: ", other.coords
                return True

            #No collision.
            return False