List of usage examples for com.badlogic.gdx.math Vector2 Vector2
public Vector2(float x, float y)
From source file:com.mygdx.entities.Entity.java
public void setPosition(Vector2 pos) { if (body != null) { body.setTransform(new Vector2(pos.x / PPM, pos.y / PPM), body.getAngle()); }/* w w w. j ava 2 s .c om*/ this.pos = pos; bd.position.set(pos.x / PPM, pos.y / PPM); }
From source file:com.mygdx.entities.esprites.EntitySprite.java
public EntitySprite(EntitySprite esprite, float x, float y, float w, float h, boolean flagForRenderSort, boolean flagForRenderTop) { this(new Vector2(x, y), w, h, esprite.isprite.getKey(), esprite.isprite.getLoop(), esprite.isprite.getFlagForComplete(), esprite.isprite.getXFlip(), esprite.isprite.getYFlip(), 1.0f, false, false, flagForRenderSort, flagForRenderTop); }
From source file:com.mygdx.entities.pickups.Pickup.java
@Override public void init(World world) { try {/* w ww.ja v a 2 s . c o m*/ bd.position.set(pos.x / PPM, pos.y / PPM);//todo: soft code this somewhere else body = world.createBody(bd); body.createFixture(fd).setUserData(userdata); body.setUserData(userdata); body.createFixture(solidfd); body.setLinearDamping(5.0f); pickupFC.start(fm); pickupInit = true; if (flagSpawnForce) { if (spawnDirection == null) { body.applyForceToCenter(new Vector2( (spawnForceValue * rng.nextFloat() * 0.5f + spawnForceValue) * rngNegSet.random(), (spawnForceValue * rng.nextFloat() * 0.5f + spawnForceValue) * rngNegSet.random()), true); } else { body.applyForceToCenter(new Vector2( spawnDirection.x + (spawnForceValue * rng.nextFloat() * 0.5f + spawnForceValue), spawnDirection.y + (spawnForceValue * rng.nextFloat() * 0.5f + spawnForceValue)), true); } } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.mygdx.entities.StaticEntities.breakable.BreakableObject.java
public void spawnReward() { //spawn reward items for (Pickup item : itemRewardPool) { Vector2 iv = new Vector2(body.getPosition().x * PPM + 25 * rng.nextFloat() * rngNegSet.random(), body.getPosition().y * PPM + 25 * rng.nextFloat() * rngNegSet.random()); item.setPosition(iv);//from w ww.ja va2 s .c om Pickup p = (Pickup) EnvironmentManager.currentEnv.spawnEntity(item); p.spawnForce(); } }
From source file:com.mygdx.entities.text.TextDamage.java
public TextDamage(String string, Vector2 pos, boolean isCombo) { super(string, pos); this.duration = 60;//1 sec this.isCombo = isCombo; float dx;/*from w w w . j av a 2s. c o m*/ if (isCombo) { cred = 1.0f; cblue = 0.0f; cgreen = 1.0f; dx = rng.nextFloat() * -7.0f; } else { dx = rng.nextFloat() * 5.0f; } pos.x += dx; this.dv = new Vector2(0, 0.5f); }
From source file:com.mygdx.entities.text.TextHealing.java
public TextHealing(String string, Vector2 pos) { super(string, pos); this.duration = 60;//1 sec float dx = rng.nextFloat() * 5.0f; red = 0.0f;/* w w w . ja v a2 s. c om*/ blue = 0.0f; green = 1.0f; alpha = 1.0f; pos.x += dx; this.dv = new Vector2(0, 0.5f); }
From source file:com.mygdx.environments.EnvDefault.EnvDefault.java
public EnvDefault(int id, int linkid) { super(id);/*from w w w .jav a2 s . c o m*/ this.linkid = linkid; fg = MainGame.am.get(ResourceManager.DEFAULT_SQCOLOR); beginFC.setTime(0); /* Initial room settings */ width = 1000 * RATIO; height = 1000 * RATIO; fgx = 0; fgy = 0; fgw = width; fgh = height; startPos = new Vector2(width * 0.5f / PPM, height * 0.2f / PPM); this.setPlayerToStart(); }
From source file:com.mygdx.environments.EnvDefault.EnvDefault.java
@Override public void init() { super.init(); /***************************************************** * INITIAL WALLS / ENVIRONMENT BOUNDARIES **************************************************/ float border = 25f; spawnEntity(new BlankWall(new Vector2((fgx) + width / 2, height * 0.1f), width / 2, border));//south spawnEntity(new BlankWall(new Vector2((fgx) + width / 2, height * 0.95f), width / 2, border));//north spawnEntity(new BlankWall(new Vector2((fgx) + width * 0.92f, height / 2), border, height / 2));//east spawnEntity(new BlankWall(new Vector2((fgx) + width * 0.08f, height / 2), border, height / 2));//west spawnEntity(EnemyManager.createRandom(new Vector2(500f, 500f))); }
From source file:com.mygdx.environments.Environment.java
public Environment(int id) { world = new World(new Vector2(0.0f, 0.0f), true); world.setContactListener(new MainContactListener(this)); this.id = id; //rng set//ww w . j a v a 2 s . c o m rngNegSet.add(1); rngNegSet.add(-1); dmgFont = MainGame.FONT_DMG; dmgFont.setColor(Color.YELLOW); dmgFont.setScale(0.55f * RATIO); }
From source file:com.mygdx.environments.Environment.java
public void addDamageText(TextDamage text) { Vector2 dv = new Vector2(0, dmgFont.getCapHeight()); for (TextEntity dtext : dmgTexts) { dtext.addToPos(dv);/*from w w w . j av a2 s . c om*/ } dmgTexts.add(text); }