List of usage examples for com.badlogic.gdx.ai.steer.behaviors Arrive Arrive
public Arrive(Steerable<T> owner, Steerable<T> target)
From source file:com.mygdx.entities.DynamicEntities.enemies.En_Goober.java
public En_Goober(Vector2 pos) { super(pos, 30f * RATIO, 30f * RATIO); fd.restitution = 0.2f;/*from w ww .j ava 2 s. co m*/ float sscale = 0.38f * RATIO; moveSprite = new ImageSprite("goober_move", true); moveSprite.sprite.setScale(sscale); isprite = moveSprite; prepSprite = new ImageSprite("goober_prep", true); prepSprite.sprite.setScale(sscale); attackSprite = new ImageSprite("goober-attack2", false); attackSprite.sprite.setScale(sscale); bodyDamageSprite = new ImageSprite("goober-dmg", false); bodyDamageSprite.sprite.setScale(sscale); prepTime = 1.0f; attTime = 0.3f; recovTime = 3f; attackFC = new FrameCounter_Attack(prepTime, attTime, recovTime); //attack sensors attFd1 = new FixtureDef(); PolygonShape vertBox = new PolygonShape(); vertBox.setAsBox(width * 0.4f / PPM, (75f / PPM) * RATIO, new Vector2(0, (75f / PPM) * RATIO), 0); attFd1.shape = vertBox; attFd1.isSensor = true; attFd1.filter.categoryBits = BIT_EN; attFd1.filter.maskBits = BIT_PLAYER; attFd2 = new FixtureDef(); PolygonShape horzBox = new PolygonShape(); horzBox.setAsBox((75f / PPM) * RATIO, width * 0.4f / PPM, new Vector2((75f / PPM) * RATIO, 0), 0); attFd2.shape = horzBox; attFd2.isSensor = true; attFd2.filter.categoryBits = BIT_EN; attFd2.filter.maskBits = BIT_PLAYER; attFd3 = new FixtureDef(); PolygonShape vertBoxSouth = new PolygonShape(); vertBoxSouth.setAsBox(width * 0.4f / PPM, (75f / PPM) * RATIO, new Vector2(0, -(75f / PPM) * RATIO), 0); attFd3.shape = vertBoxSouth; attFd3.isSensor = true; attFd3.filter.categoryBits = BIT_EN; attFd3.filter.maskBits = BIT_PLAYER; attFd4 = new FixtureDef(); PolygonShape horzBoxWest = new PolygonShape(); horzBoxWest.setAsBox((75f / PPM) * RATIO, width * 0.4f / PPM, new Vector2(-(75f / PPM) * RATIO, 0), 0); attFd4.shape = horzBoxWest; attFd4.isSensor = true; attFd4.filter.categoryBits = BIT_EN; attFd4.filter.maskBits = BIT_PLAYER; //ai moveToSB = new Arrive<Vector2>(this, EnvironmentManager.player).setTimeToTarget(0.01f) .setArrivalTolerance(2f).setDecelerationRadius(10); wanderSB = new Wander<Vector2>(this).setFaceEnabled(false).setAlignTolerance(0.001f) .setDecelerationRadius(5).setTimeToTarget(0.1f).setWanderOffset(90).setWanderOrientation(10) .setWanderRadius(40f).setWanderRate(MathUtils.PI2 * 4); seekWanderSB = new Seek<Vector2>(this, seekWanderTarget); //ai this.maxLinearSpeed = 150f; this.maxLinearAcceleration = 500f; this.maxAngularSpeed = 30f; this.maxAngularAcceleration = 5f; }
From source file:EntityManager.EntityManager.java
public void create() { Entity entity = Player.getEntity(0, 0, 15, 1, 100, 1); engine.addEntity(entity);//from w ww.j ava2 s .c o m SceneBuilder.getScene(engine); Body body = CreateCircle.createCircle(world, -50, 0, 20 / PPM); baddie = new Box2DSteeringEntity(body, 30); Box2DSteeringEntity target = new Box2DSteeringEntity(entity.getComponent(BodyComponent.class).body, 30 / PPM); Arrive<Vector2> arriveSB = new Arrive<Vector2>(baddie, target); baddie.setBehavior(arriveSB); // controlsSystem.addedToEngine(engine); }