public void update(long dtime) { super.update(dtime); if (this.health == 0 && this.dead == false) { if (this == Gamestate.getInstance().getPlayer()) { this.setController(new NoController()); } SOUNDS.TANK_EXPLODE.play(); Vector3f bpos = new Vector3f(this.getBase().getPos()); Gamestate.getInstance().addObject(new ExplosionCluster(bpos, new Vector3f(0, 1.2f, 0), 20)); this.setController(new NoController()); this.dead = true; this.base.unjoin(this.turret); this.parts.remove(this.turret); } else { lastFired++; Vector2f lookdir = turret.getPhys().getDir(); if (lookdir.y > 25.0f) lookdir.y = 25.0f; if (lookdir.y < -25.0f) lookdir.y = -25.0f; if (lookdir.x > 55.0f) lookdir.x = 55.0f; if (lookdir.x < -55.0f) lookdir.x = -55.0f; turret.getPhys().setDir(lookdir); } }
public Tank() { super(); base = new Part(MODELS.TANKBASE); turret = new Part(MODELS.TANKTURRET); turret.rotJoin(base); turret.posJoin(base); parts.add(base); parts.add(turret); base.getPhys().setMaxvel(.5f); turret.getPhys().setPos(new Vector3f(0.00f, 0.173f, 0f)); turret.setCenterrot(new Vector3f(-0.1f, 0, 0f)); base.getPhys().setDragconst(.005f); base.getPhys().setRadius(.65f); }
public void setLookImpulse(int x, int y) { turret.getPhys().setDirAccel(-((float) x) / turretRate, -((float) y) / turretRate); }