Search in sources :

Example 41 with Vec2

use of spacegraph.space2d.phys.common.Vec2 in project narchy by automenta.

the class AbstractPolygonBot method eat.

public void eat(Body eaten) {
    Material m = (Material) eaten.getUserData();
    if (m instanceof Sim.FoodMaterial) {
        nar.input("<goal --> [food]>. :|: %0.90;0.90%");
        nar.input("<goal --> [health]>. :|: %0.90;0.90%");
    } else if (m instanceof Sim.PoisonMaterial) {
        nar.input("<goal --> [food]>. :|: %0.00;0.90%");
        nar.input("<goal --> [health]>. :|: %0.00;0.90%");
    } else {
        return;
    }
    @Deprecated int sz = 48;
    float x = (float) Math.random() * sz - sz / 2f;
    float y = (float) Math.random() * sz - sz / 2f;
    // random new position
    eaten.setTransform(new Vec2(x * 2.0f, y * 2.0f), eaten.getAngle());
}
Also used : Sim(nars.rover.Sim) Vec2(spacegraph.space2d.phys.common.Vec2) Material(nars.rover.Material)

Aggregations

Vec2 (spacegraph.space2d.phys.common.Vec2)41 Body (spacegraph.space2d.phys.dynamics.Body)9 PolygonShape (spacegraph.space2d.phys.collision.shapes.PolygonShape)6 Tuple2f (spacegraph.util.math.Tuple2f)6 MouseJoint (spacegraph.space2d.phys.dynamics.joints.MouseJoint)4 JoglAbstractDraw (nars.rover.physics.gl.JoglAbstractDraw)3 ArrayRealVector (org.apache.commons.math3.linear.ArrayRealVector)3 Color3f (spacegraph.space2d.phys.common.Color3f)3 BodyDef (spacegraph.space2d.phys.dynamics.BodyDef)3 Fixture (spacegraph.space2d.phys.dynamics.Fixture)3 VisionRay (nars.rover.obj.VisionRay)2 Physics2dBody (ptrman.difficultyEnvironment.physics.Physics2dBody)2 CircleShape (spacegraph.space2d.phys.collision.shapes.CircleShape)2 DistanceJoint (spacegraph.space2d.phys.dynamics.joints.DistanceJoint)2 GLCapabilities (com.jogamp.opengl.GLCapabilities)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Material (nars.rover.Material)1 PhysicsModel (nars.rover.PhysicsModel)1 Sim (nars.rover.Sim)1