MCPcopy Create free account
hub / github.com/microsoft/SandDance / cloudCollide

Function cloudCollide

docs/app/js/sanddance-app.js:140947–140958  ·  view source on GitHub ↗
(tag, board, sw)

Source from the content-addressed store, hash-verified

140945 }
140946} // Use mask-based collision detection.
140947function cloudCollide(tag, board, sw) {
140948 sw >>= 5;
140949 var sprite = tag.sprite, w = tag.width >> 5, lx = tag.x - (w << 4), sx = lx & 0x7f, msx = 32 - sx, h = tag.y1 - tag.y0, x = (tag.y + tag.y0) * sw + (lx >> 5), last;
140950 for(var j = 0; j < h; j++){
140951 last = 0;
140952 for(var i = 0; i <= w; i++){
140953 if ((last << msx | (i < w ? (last = sprite[j * w + i]) >>> sx : 0)) & board[x + i]) return true;
140954 }
140955 x += sw;
140956 }
140957 return false;
140958}
140959function cloudBounds(bounds, d) {
140960 var b0 = bounds[0], b1 = bounds[1];
140961 if (d.x + d.x0 < b0.x) b0.x = d.x + d.x0;

Callers 1

placeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected