dist/server-module/lance-gg.js
// wrap-around the world if necessary
wrap-around the world if necessary
wrap - around the world if necessary
objectStep(o, dt) {
        if (dt === 0)
            return;
        if (dt)
            dt /= (1 / 60);
        else
            dt = 1;
        let worldSettings = this.gameEngine.worldSettings;
        if (o.isRotatingRight) { o.angle += o.rotationSpeed; }
        if (o.isRotatingLeft) { o.angle -= o.rotationSpeed; }
        if (o.angle >= 360) { o.angle -= 360; }
        if (o.angle < 0) { o.angle += 360; }
        if (o.isAccelerating) {
            let rad = o.angle * (Math.PI / 180);
            dv.set(Math.cos(rad), Math.sin(rad)).multiplyScalar(o.acceleration).multiplyScalar(dt);
            o.velocity.add(dv);
        }
        if (!o.isStatic) o.velocity.add(this.gravity);
        let velMagnitude = o.velocity.length();
        if ((o.maxSpeed !== null) && (velMagnitude > o.maxSpeed)) {
            o.velocity.multiplyScalar(o.maxSpeed / velMagnitude);
        }
        o.isAccelerating = false;
        o.isRotatingLeft = false;
        o.isRotatingRight = false;
        dx.copy(o.velocity).multiplyScalar(dt);
        o.position.add(dx);
        o.velocity.multiply(o.friction);
        if (worldSettings.worldWrap) {
            if (o.position.x >= worldSettings.width) { o.position.x -= worldSettings.width; }
            if (o.position.y >= worldSettings.height) { o.position.y -= worldSettings.height; }
            if (o.position.x < 0) { o.position.x += worldSettings.width; }
            if (o.position.y < 0) { o.position.y += worldSettings.height; }
        }
    }
objectStep ( o , dt ) { if ( dt === 0 ) return ; if ( dt ) dt /= ( 1 / 60 ) ; else dt = 1 ; let worldSettings = this . gameEngine . worldSettings ; if ( o . isRotatingRight ) { o . angle += o . rotationSpeed ; } if ( o . isRotatingLeft ) { o . angle -= o . rotationSpeed ; } if ( o . angle >= 360 ) { o . angle -= 360 ; } if ( o . angle < 0 ) { o . angle += 360 ; } if ( o . isAccelerating ) { let rad = o . angle * ( Math . PI / 180 ) ; dv . set ( Math . cos ( rad ) , Math . sin ( rad ) ) . multiplyScalar ( o . acceleration ) . multiplyScalar ( dt ) ; o . velocity . add ( dv ) ; } if ( ! o . isStatic ) o . velocity . add ( this . gravity ) ; let velMagnitude = o . velocity . length ( ) ; if ( ( o . maxSpeed !== null ) && ( velMagnitude > o . maxSpeed ) ) { o . velocity . multiplyScalar ( o . maxSpeed / velMagnitude ) ; } o . isAccelerating = false ; o . isRotatingLeft = false ; o . isRotatingRight = false ; dx . copy ( o . velocity ) . multiplyScalar ( dt ) ; o . position . add ( dx ) ; o . velocity . multiply ( o . friction ) ; if ( worldSettings . worldWrap ) { if ( o . position . x >= worldSettings . width ) { o . position . x -= worldSettings . width ; } if ( o . position . y >= worldSettings . height ) { o . position . y -= worldSettings . height ; } if ( o . position . x < 0 ) { o . position . x += worldSettings . width ; } if ( o . position . y < 0 ) { o . position . y += worldSettings . height ; } } }
wrap-around the world if necessary
wrap - around the world if necessary
// calculate factor // TODO: worldsettings is a hack.  Find all places which use it in all games // and come up with a better solution.  for example an option sent to the physics Engine // with a "worldWrap:true" options // replace with a "worldBounds" parameter to the PhysicsEngine constructor // TODO: remove this code in version 4: these attributes are deprecated // TODO: remove this code in version 4: these attributes are deprecated // TODO: remove this code in version 4: these attributes are deprecated // apply gravity // wrap around the world edges