예제 #1
0
 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;
 }
예제 #2
0
 public static Polygon getPolygon(Debris debris) {
   // Select a polygon to render a debris object given the debris object's
   // hash code.
   if (polygon == null) {
     polygon = new ArrayList<Polygon>();
     for (int i = 0; i < 8; ++i) {
       polygon.add(getPolygon());
     }
   }
   int index = debris.hashCode() % polygon.size();
   return polygon.get(index);
 }