Luka967 / OgarII

FOSS implementation of a private Agar.io gameserver, made with Node.js.
Other
66 stars 38 forks source link

Add option for disabling eject collide. #56

Open ar065 opened 4 years ago

ar065 commented 4 years ago

Currently, there is no option to disable ejected mass from colliding.

Phoenix132 commented 3 years ago

There is a way to disable ejected mass from colliding, but it also disables your cells from colliding:

src/worlds/world.js

/**
 * @param {Cell} a
 * @param {Cell} b
 */
resolveRigidCheck(a, b) {
    let dx = 0;
    let dy = 0;
    let d = Math.sqrt(dx * dx + dy * dy);
    const m = a.size + b.size - d;
    if (m <= 0) return;
    if (d === 0) d = 1, dx = 1, dy = 0;
    else dx /= d, dy /= d;
    const M = a.squareSize + b.squareSize;
    const aM = b.squareSize / M;
    const bM = a.squareSize / M;
    a.x -= dx * m * aM;
    a.y -= dy * m * aM;
    b.x += dx * m * bM;
    b.y += dy * m * bM;
    this.bounceCell(a);
    this.bounceCell(b);
    this.updateCell(a);
    this.updateCell(b);
}

basically change the dx and dy variables to zero. Basically it disables all collisions

Phoenix132 commented 3 years ago

Hoped this helped, probably not...