JellyFish(float x, float y) { head = new PointMass(x, y, 24); Asteroids.addPM(head); headX = x; // head.pinTo(x, y); tentacles = new ArrayList<PointMass>(); legs = new ArrayList<List<PointMass>>(); for (int leg = 0; leg < 10; leg++) { legs.add(new ArrayList<PointMass>()); PointMass main = new PointMass(head.pos.x + 0.5f, head.pos.y + 0.5f, 1); main.attachTo(head, 80); tentacles.add(main); legs.get(legs.size() - 1).add(main); for (int joints = 0; joints < 10; joints++) { PointMass last = tentacles.get(tentacles.size() - 1); PointMass point = new PointMass( last.pos.x + 5f * (float) Math.random(), last.pos.y + 5f * (float) Math.random(), 1); point.attachTo(last, 60); legs.get(legs.size() - 1).add(point); tentacles.add(point); // Asteroids.audio.scream(); } } for (PointMass point : tentacles) Asteroids.addPM(point); }
public static Debris getDebris(Vec2 position) { Debris debris = Asteroids.newEntity(Debris.class); float minSpeed = 9.f; float maxSpeed = 12.f; debris.body.setLinearVelocity(Asteroids.getRandomVel(minSpeed, maxSpeed)); debris.body.setTransform(position, debris.body.getAngle()); debris.life = LIFE; return debris; }
public void init() { super.init(); SpaceObject a1 = createAsteroid(); a1.setSpeed(2, 0); add(a1, 0, getPrefHeight() / 5 - 10); SpaceObject a2 = createAsteroid(); a2.setSpeed(-1, 0); add(a2, getPrefWidth(), getPrefHeight() / 5 + 10); SpaceObject a3 = createAsteroid(); a3.setSpeed(2, 0); add(a3, 0, getPrefHeight() / 2 - 20); SpaceObject a4 = createAsteroid(); a4.setSpeed(-2, 0); add(a4, getPrefWidth(), getPrefHeight() / 2 + 20); SpaceObject a5 = createAsteroid(); a5.setSpeed(1, 0); add(a5, 0, getPrefHeight() * 4 / 5 - 30); SpaceObject a6 = createAsteroid(); a6.setSpeed(-2, 0); add(a6, getPrefWidth(), getPrefHeight() * 4 / 5 + 30); }
/** * Updates the rock (and wraps the transform). * * @param delta */ @Override public void update(float delta) { Asteroids.wrapTransform(this.body); this.life = Math.max(0.f, this.life - delta); if (this.life <= 0.f) { setActive(false); } }
public Debris() { this.body = Asteroids.getBody(RADIUS - MARGIN, TYPE, MASK, DENSITY); this.setSerializable(false); this.life = LIFE; }