Exemplo n.º 1
0
 public void putInRandomEmptySpace(SmartblobTri blob, Random rand) {
   Rect whereAndSizeNow = blob.boundingRectangle();
   Rect moveTo = findEmptySpace(whereAndSizeNow.height, whereAndSizeNow.width, rand);
   float addToEachY = moveTo.y - whereAndSizeNow.y;
   float addToEachX = moveTo.x - whereAndSizeNow.x;
   blob.addToAllPositions(addToEachY, addToEachX, true);
 }
Exemplo n.º 2
0
 /** TODO various types of objects with various ways of thinking */
 public SmartblobTri addRandomObject(Map optionalParams, Random rand) {
   /*Smartblob blob = SmartblobUtil.wavegear(
   	null, 250, 500, 75, 90,
   	3, 32, 5);
   */
   // blob.mutablePhysics().addAll(defaultChangeSpeeds);
   SmartblobTri blob = CurvblobUtil.simpleSmartblobExample();
   blob.mutablePhysics().clear();
   blob.mutablePhysics().addAll(defaultChangeSpeeds);
   putInRandomEmptySpace(blob, rand);
   smartblobs.add(blob);
   return blob;
 }
Exemplo n.º 3
0
 public void changeSpeed(SmartblobTri blob, float secondsSinceLastCall) {
   float minSq = minSpeed * minSpeed;
   float maxSq = maxSpeed * maxSpeed;
   for (MovCorner c : blob.allMovCorners()) {
     float dy = c.speedY, dx = c.speedX;
     float speedSq = dy * dy + dx * dx;
     if (minSq <= speedSq && speedSq <= maxSq) continue;
     if (speedSq == 0)
       continue; // rare. it will be pushed on by springs and probably have nonzero speed next
                 // time.
     float speed = (float) Math.sqrt(speedSq);
     float newSpeed = Math.max(minSpeed, Math.min(speed, maxSpeed));
     float mult = newSpeed / speed;
     c.speedY *= mult;
     c.speedX *= mult;
   }
 }