Package co.paralleluniverse.spacebase

Examples of co.paralleluniverse.spacebase.AABB


        try (Element<Record<SpaceshipState>> target = global.sb.readElement(lockedOn)) {
            final Record<SpaceshipState> lockedSpaceship;
            if (target != null && (lockedSpaceship = target.get()) != null) {
                foundLockedOn = true;

                final AABB aabb = getAABB(lockedSpaceship);
                // double angularDiversion = abs(atan2(lockedSpaceship.vx, lockedSpaceship.vy) - getCurrentHeading(shootTime));
                if (inShotRange(aabb) & global.random.nextGaussian() < SHOOT_PROBABLITY) {
                    record(1, "Spaceship", "chaseAndShoot", "%s: shootrange", this);
                    final double range = mag(lockedSpaceship.get($x) - state.get($x), lockedSpaceship.get($y) - state.get($y));
                    final long now = global.now();
View Full Code Here


        chaseAy = acc * udy;
    }

    private void applyNeighborRejectionAndMove(final long now) throws InterruptedException, SuspendExecution {
        record(1, "Spaceship", "applyNeighborRejectionAndMove", "%s", this);
        AABB myAABB = getAABB();
        try (ResultSet<Record<SpaceshipState>> rs = global.sb.queryForUpdate(
                SpatialQueries.range(myAABB, global.range),
                SpatialQueries.equals((Record<SpaceshipState>) state, myAABB), false)) {

//            Scheduler.Job j = rs.getAsyncOp().getJob();
View Full Code Here

            double vx = state.get($vx);
            double vy = state.get($vy);
            double ax = state.get($ax);
            double ay = state.get($ay);

            final AABB bounds = global.bounds;
            final double duration = (double) (now - lastMoved) / TimeUnit.SECONDS.toMillis(1);
            final double duration2 = duration * duration;// * Math.signum(duration);

            x = x + (vx + exVx) * duration + ax * duration2 / 2.0;
            y = y + (vy + exVy) * duration + ay * duration2 / 2.0;

            vx = vx + ax * duration;
            vy = vy + ay * duration;

            // before limitSpeed
            state.set($vx, vx);
            state.set($vy, vy);
            limitSpeed();
            vx = state.get($vx);
            vy = state.get($vy);

            assert !Double.isNaN(vx + vy);

            if (x > bounds.max(X) || x < bounds.min(X)) {
                x = min(x, bounds.max(X));
                x = max(x, bounds.min(X));
                vx = -vx * SPEED_BOUNCE_DAMPING;
                ax = 0;
            }
            if (y > bounds.max(Y) || y < bounds.min(Y)) {
                y = min(y, bounds.max(Y));
                y = max(y, bounds.min(Y));
                vy = -vy * SPEED_BOUNCE_DAMPING;
                ay = 0;
            }

            assert !Double.isNaN(x + y);
View Full Code Here

TOP

Related Classes of co.paralleluniverse.spacebase.AABB

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.