Sha256: 8ae3ff9b74e13aca62a1dcb79c5e89c05607cd8e8d42236a9f3c535f5cd94cb5
Contents?: true
Size: 743 Bytes
Versions: 2
Compression:
Stored size: 743 Bytes
Contents
/* The point component definess an entity that has a 2d position in space. This can be used for 2d calculations or most commonly 2d sprite positioning. */ re.c('point') .defaults({ posX:0, posY:0 }) .defines({ pos:function(x, y){ if(re.is(x,'object')){ y = x.posY || x.y; x = x.posX || x.x; } this.posX = x; this.posY = y; return this; }, distanceTo:function(x, y){ if(re.is(x,'object')){ y = x.posY || x.y; x = x.posX || x.x; } var kx, ky; kx = x - this.posX; ky = y - this.posY; return Math.sqrt(kx*kx + ky*ky) + 0.5 | 0; } });
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
entityjs-0.3.1 | src/math/point.js |
entityjs-0.3.0 | src/math/point.js |