コード例 #1
0
 public void draw(SolGame game, GameDrawer drawer) {
   SolCam cam = game.getCam();
   Vector2 camPos = cam.getPos();
   Planet p = game.getPlanetMan().getNearestPlanet();
   Vector2 pPos = p.getPos();
   float toCamLen = camPos.dst(pPos);
   float vd = cam.getViewDist();
   float gh = p.getMinGroundHeight();
   if (toCamLen < gh + vd) {
     float sz = gh;
     drawer.draw(myTex, sz * 2, sz * 2, sz, sz, pPos.x, pPos.y, p.getAngle(), SolColor.W);
   }
 }
コード例 #2
0
 public void update(SolGame game) {
   myShouldDraw = false;
   float ts = game.getTimeStep();
   myAnimPerc += ts / 2f;
   if (myAnimPerc > 1) myAnimPerc = 0;
   myAngle += 30f * ts;
   if (myAngle > 180) myAngle -= 360;
 }
コード例 #3
0
ファイル: Teleport.java プロジェクト: Rulasmur/DestinationSol
  // can be performed in update
  public void maybeTeleport(SolGame game, SolShip owner) {
    if (!myShouldTeleport) return;

    TextureAtlas.AtlasRegion tex = game.getTexMan().getTex(TEX_PATH, null);
    float blipSz = owner.getHull().config.getApproxRadius() * 3;
    game.getPartMan().blip(game, owner.getPos(), SolMath.rnd(180), blipSz, 1, Vector2.Zero, tex);
    game.getPartMan().blip(game, myNewPos, SolMath.rnd(180), blipSz, 1, Vector2.Zero, tex);

    float newAngle = owner.getAngle() + myAngle;
    Vector2 newSpd = SolMath.getVec(owner.getSpd());
    SolMath.rotate(newSpd, myAngle);

    Body body = owner.getHull().getBody();
    body.setTransform(myNewPos, newAngle * SolMath.degRad);
    body.setLinearVelocity(newSpd);

    SolMath.free(newSpd);
  }
コード例 #4
0
ファイル: Teleport.java プロジェクト: Rulasmur/DestinationSol
 @Override
 public boolean update(SolGame game, SolShip owner, boolean tryToUse) {
   myShouldTeleport = false;
   if (!tryToUse) return false;
   Vector2 pos = owner.getPos();
   Fraction frac = owner.getPilot().getFraction();
   SolShip ne = game.getFractionMan().getNearestEnemy(game, MAX_RADIUS, frac, pos);
   if (ne == null) return false;
   Vector2 nePos = ne.getPos();
   Planet np = game.getPlanetMan().getNearestPlanet();
   if (np.isNearGround(nePos)) return false;
   for (int i = 0; i < 5; i++) {
     myNewPos.set(pos);
     myNewPos.sub(nePos);
     myAngle = myConfig.angle * SolMath.rnd(.5f, 1) * SolMath.toInt(SolMath.test(.5f));
     SolMath.rotate(myNewPos, myAngle);
     myNewPos.add(nePos);
     if (game.isPlaceEmpty(myNewPos, false)) {
       myShouldTeleport = true;
       return true;
     }
   }
   return false;
 }
コード例 #5
0
 public void updateMtx(SolGame game) {
   myDrawer.setMtx(game.getCam().getMtx());
 }