List of usage examples for com.badlogic.gdx.math Vector2 Zero
Vector2 Zero
To view the source code for com.badlogic.gdx.math Vector2 Zero.
Click Source Link
From source file:com.mygdx.game.Sprites.Boss.Boss.java
private void defineStandBoss() { world.destroyBody(b2body);/*from w ww . ja va 2 s. c om*/ BodyDef bdef = new BodyDef(); bdef.position.set(205 / AdventureGame.PPM, 100 / AdventureGame.PPM); bdef.type = BodyDef.BodyType.DynamicBody; b2body = world.createBody(bdef); FixtureDef fdef = new FixtureDef(); PolygonShape shape = new PolygonShape(); shape.setAsBox(25 / AdventureGame.PPM, 20 / AdventureGame.PPM); fdef.isSensor = true; fdef.shape = shape; fdef.friction = 0; fdef.filter.categoryBits = AdventureGame.BOSS_BIT; fdef.filter.maskBits = AdventureGame.BULLET_BIT | AdventureGame.PLAYER_BIT | AdventureGame.DYNAMITE_BIT | AdventureGame.GROUND_BIT | AdventureGame.FLOOR_BIT; b2body.createFixture(fdef).setUserData(this); fdef.isSensor = false; EdgeShape downShape = new EdgeShape(); downShape.set(-51 / AdventureGame.PPM, -22 / AdventureGame.PPM, 51 / AdventureGame.PPM, -22 / AdventureGame.PPM); fdef.shape = downShape; b2body.createFixture(fdef).setUserData(this); b2body.setLinearVelocity(Vector2.Zero); stand = true; }
From source file:com.mygdx.game.Sprites.Enemies.Wheel.Wheel.java
@Override public void update(float dt) { if (destroyed) { return;//from ww w .ja v a 2 s . c om } if (b2body.getLinearVelocity().x >= -1) { b2body.applyLinearImpulse(new Vector2(-1f, 0), b2body.getWorldCenter(), true); } if (lives > 0) { this.setRegion(moveWheel.getKeyFrame(TimeState)); setPosition(b2body.getPosition().x - this.getWidth() / 2, b2body.getPosition().y - this.getHeight() / 2); } if (lives <= 0) { b2body.setLinearVelocity(Vector2.Zero); setRegion(WheelDown.getKeyFrame(TimeState)); if (WheelDown.isAnimationFinished(TimeState)) { setDestroy = true; } } if (setDestroy && !destroyed) { world.destroyBody(b2body); destroyed = true; } TimeState += dt; }
From source file:com.mygdx.game.Sprites.Player.Dynamite.java
public void setToDestroy() { currentState = State.EXPLODING; StateTimer = 0;//ww w. j a v a2s. c o m this.setSize(60 / AdventureGame.PPM, 28 / AdventureGame.PPM); b2body.setGravityScale(0f); b2body.setLinearVelocity(Vector2.Zero); }
From source file:com.sidereal.dolphinoes.behaviors.pathfinding.PathfindingMap.java
License:Apache License
public PathfindingMap(int width, int height) { paths = new ArrayList<PathfindingRoute.Path>(); nodesX = width;/*from ww w . ja va2s .c o m*/ nodesY = height; centerAnchorPosition = Vector2.Zero; nodeSize = new Vector2(100, 100); nodes = new PathfindingNode[width][height]; for (int i = 0; i < nodes.length; i++) { for (int j = 0; j < nodes[i].length; j++) { nodes[i][j] = new PathfindingNode(this, i, j, true); } } bounds = new Rectangle(centerAnchorPosition.x - (nodesX * nodeSize.x) / 2, centerAnchorPosition.y - (nodesY * nodeSize.y) / 2, nodesX * nodeSize.x, nodesY * nodeSize.y); }
From source file:com.stercore.code.net.dermetfan.utils.libgdx.box2d.Box2DUtils.java
License:Apache License
/** @param fixture the fixture to split * @param a the first point of the segment * @param b the second point of the segment * @param store the {@link Pair} to store the resulting {@link FixtureDef FixtureDefs} in * @return if the fixture was split/*w w w . j a va 2 s .c o m*/ * @see #split(Shape, Vector2, Vector2, Pair) */ public static boolean split(Fixture fixture, Vector2 a, Vector2 b, Pair<FixtureDef, FixtureDef> store) { Body body = fixture.getBody(); Vector2 bodyPos = body.getPosition(); Vector2 tmpA = Pools.obtain(Vector2.class).set(a).sub(bodyPos), tmpB = Pools.obtain(Vector2.class).set(b).sub(bodyPos); GeometryUtils.rotate(tmpA, Vector2.Zero, -body.getAngle()); GeometryUtils.rotate(tmpB, Vector2.Zero, -body.getAngle()); @SuppressWarnings("unchecked") Pair<Shape, Shape> shapes = Pools.obtain(Pair.class); boolean split = split(fixture.getShape(), tmpA, tmpB, shapes); Pools.free(tmpA); Pools.free(tmpB); if (!split) { Pools.free(shapes); return false; } FixtureDef aDef = createDef(fixture), bDef = createDef(fixture); aDef.shape = shapes.key(); bDef.shape = shapes.value(); Pools.free(shapes); store.set(aDef, bDef); return true; }
From source file:com.stercore.code.net.dermetfan.utils.libgdx.box2d.Breakable.java
License:Apache License
/** @see #Breakable(float, float, Vector2, float, float, boolean, boolean, Callback) */ public Breakable(float normalResistance, float tangentResistance, boolean breakBody, boolean breakBodyWithoutFixtures) { this(normalResistance, tangentResistance, Vector2.Zero, 0, 0, breakBody, breakBodyWithoutFixtures, null); }
From source file:com.stercore.code.net.dermetfan.utils.libgdx.box2d.Breakable.java
License:Apache License
/** @see #Breakable(float, float, Vector2, float, float, boolean, boolean, Callback) */ public Breakable(float normalResistance, float tangentResistance, boolean breakBody, Callback callback) { this(normalResistance, tangentResistance, Vector2.Zero, 0, 0, breakBody, true, callback); }
From source file:com.sturdyhelmetgames.roomforchange.entity.Entity.java
License:Apache License
public void update(float fixedStep) { if (pause > 0f) { pause -= fixedStep;//from w ww. j a va 2 s .c o m } // tick dying if (blinkTick > BLINK_TICK_MAX) { blinkTick = 0f; } // tick alive & dying times invulnerableTick -= fixedStep; if (invulnerableTick > 0f) { blinkTick += fixedStep; } if (invulnerableTick <= 0f) { blinkTick = 0f; } if (pause <= 0f) { tryMove(); vel.add(accel); if (vel.x > getMaxVelocity()) { vel.x = getMaxVelocity(); } if (vel.x < -getMaxVelocity()) { vel.x = -getMaxVelocity(); } if (vel.y > getMaxVelocity()) { vel.y = getMaxVelocity(); } if (vel.y < -getMaxVelocity()) { vel.y = -getMaxVelocity(); } accel.scl(fixedStep); if (state == EntityState.WALKING) { vel.lerp(Vector2.Zero, getInertia() * fixedStep); } else { vel.scl(fixedStep); } stateTime += fixedStep; } }
From source file:com.tnf.ptm.entities.gun.PtmGun.java
License:Apache License
public PtmGun(PtmGame game, Gun item, Vector2 relPos, boolean underShip) { myItem = item;/*from w w w. ja v a2 s . co m*/ if (myItem.config.lightOnShot) { Color lightCol = PtmColor.WHITE; ProjectileConfig projConfig = myItem.config.clipConf.projConfig; if (projConfig.bodyEffect != null) { lightCol = projConfig.bodyEffect.tint; } else if (projConfig.collisionEffect != null) { lightCol = projConfig.collisionEffect.tint; } myLightSrc = new LightSrc(game, .25f, true, 1f, Vector2.Zero, lightCol); } else { myLightSrc = null; } myRelPos = new Vector2(relPos); DraLevel level = underShip ? DraLevel.U_GUNS : DraLevel.GUNS; float texLen = myItem.config.gunLength / myItem.config.texLenPerc * 2; mySprite = new RectSprite(myItem.config.tex, texLen, 0, 0, new Vector2(relPos), level, 0, 0, PtmColor.WHITE, false); myDras = new ArrayList<Dra>(); myDras.add(mySprite); if (myLightSrc != null) { myLightSrc.collectDras(myDras); } }
From source file:com.tnf.ptm.entities.gun.PtmGun.java
License:Apache License
private void shoot(Vector2 gunSpd, PtmGame game, float gunAngle, Vector2 muzzlePos, Faction faction, PtmObject creator) {//from w w w. j av a 2s . c om Vector2 baseSpd = gunSpd; Clip.Config cc = myItem.config.clipConf; if (cc.projConfig.zeroAbsSpd) { baseSpd = Vector2.Zero; Planet np = game.getPlanetMan().getNearestPlanet(); if (np.isNearGround(muzzlePos)) { baseSpd = new Vector2(); np.calcSpdAtPos(baseSpd, muzzlePos); } } myCurrAngleVar = PtmMath.approach(myCurrAngleVar, myItem.config.maxAngleVar, myItem.config.angleVarPerShot); boolean multiple = cc.projectilesPerShot > 1; for (int i = 0; i < cc.projectilesPerShot; i++) { float bulletAngle = gunAngle; if (myCurrAngleVar > 0) { bulletAngle += PtmMath.rnd(myCurrAngleVar); } Projectile proj = new Projectile(game, bulletAngle, muzzlePos, baseSpd, faction, cc.projConfig, multiple); game.getObjMan().addObjDelayed(proj); } myCoolDown += myItem.config.timeBetweenShots; myItem.ammo--; game.getSoundManager().play(game, myItem.config.shootSound, muzzlePos, creator); }