MCPcopy Create free account
hub / github.com/melonjs/melonJS / addPoint

Method addPoint

packages/melonjs/src/renderable/trail.js:106–119  ·  view source on GitHub ↗

* add a point to the trail * @param {number} x - x position * @param {number} y - y position

(x, y)

Source from the content-addressed store, hash-verified

104 * @param {number} y - y position
105 */
106 addPoint(x, y) {
107 if (this._points.length > 0) {
108 const last = this._points[this._points.length - 1];
109 const dx = x - last.x;
110 const dy = y - last.y;
111 if (dx * dx + dy * dy < this.minDistance * this.minDistance) {
112 return;
113 }
114 }
115 this._points.push({ x, y, age: 0 });
116 if (this._points.length > this.maxPoints) {
117 this._points.shift();
118 }
119 }
120
121 /** @ignore */
122 update(dt) {

Callers 1

updateMethod · 0.95

Calls 2

pushMethod · 0.45
shiftMethod · 0.45

Tested by

no test coverage detected