Android Open Source - CircleWorldGDX Universe Generator






From Project

Back to project page CircleWorldGDX.

License

The source code is released under:

MIT License

If you think the Android project CircleWorldGDX listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.fdangelo.circleworld.universeengine;
//from  w w w  . j  a  v  a2 s  .  c om
import java.util.Random;

public class UniverseGenerator {
  protected Thing[] things;
  protected Random random;
  protected short thingsAmount;
  protected short currentThing;

  public final short generate(final int seed, final Thing[] things) {
    this.things = things;
    random = new Random(seed);

    things[0].type = ThingType.Galaxy;
    things[0].safeRadius = Short.MAX_VALUE;

    currentThing = 0;
    thingsAmount = 1;

    addGalaxy();

    updateBrothers((short) 0);

    this.things = null;
    random = null;

    return thingsAmount;
  }

  protected void addGalaxy() {

  }

  private final short updateBrothers(short index) {
    final int childs = things[index].childs;
    index++;

    short prevBrother = 0;

    for (int i = 0; i < childs; i++) {
      prevBrother = index;

      index = updateBrothers(index);

      if (i + 1 < childs) {
        things[prevBrother].nextBrother = index;
      }
    }

    return index;
  }

  protected final void pushThing(final short type, final short angle, final short distance, short rotationPeriod, final short orbitalPeriod,
      final short radius, final short safeRadius, final int seed) {

    // TODO: Remove once planet rotations are correctly implemented
    rotationPeriod = 0;

    // TEST
    // orbitalPeriod = 0;

    things[currentThing].childs++;

    things[thingsAmount].parent = currentThing;
    things[thingsAmount].type = type;

    things[thingsAmount].angle = angle;
    things[thingsAmount].distance = distance;
    things[thingsAmount].rotationPeriod = rotationPeriod;
    things[thingsAmount].orbitalPeriod = orbitalPeriod;
    things[thingsAmount].radius = radius;
    things[thingsAmount].safeRadius = safeRadius;
    things[thingsAmount].seed = seed;

    if (orbitalPeriod != 0) {
      things[thingsAmount].orbitalPeriodInv = 1.0f / orbitalPeriod;
    } else {
      things[thingsAmount].orbitalPeriodInv = 0.0f;
    }

    if (rotationPeriod != 0) {
      things[thingsAmount].rotationPeriodInv = 1.0f / rotationPeriod;
    } else {
      things[thingsAmount].rotationPeriodInv = 0.0f;
    }

    currentThing = thingsAmount;
    thingsAmount++;
  }

  protected void popThing() {
    currentThing = things[currentThing].parent;
  }
}




Java Source Code List

.AssetsUpdater.java
com.fdangelo.circleworld.GameLogicState.java
com.fdangelo.circleworld.GameLogic.java
com.fdangelo.circleworld.MainActivity.java
com.fdangelo.circleworld.Main.java
com.fdangelo.circleworld.MyGdxGame.java
com.fdangelo.circleworld.RobovmLauncher.java
com.fdangelo.circleworld.client.GwtLauncher.java
com.fdangelo.circleworld.gui.AvatarEditControlScreen.java
com.fdangelo.circleworld.gui.AvatarMoveControlScreen.java
com.fdangelo.circleworld.gui.HudScreen.java
com.fdangelo.circleworld.gui.core.Gui.java
com.fdangelo.circleworld.gui.core.ScreenTable.java
com.fdangelo.circleworld.gui.core.Screen.java
com.fdangelo.circleworld.universeengine.IUniverseListener.java
com.fdangelo.circleworld.universeengine.ThingPosition.java
com.fdangelo.circleworld.universeengine.ThingType.java
com.fdangelo.circleworld.universeengine.Thing.java
com.fdangelo.circleworld.universeengine.UniverseFactory.java
com.fdangelo.circleworld.universeengine.UniverseGeneratorDefault.java
com.fdangelo.circleworld.universeengine.UniverseGenerator.java
com.fdangelo.circleworld.universeengine.Universe.java
com.fdangelo.circleworld.universeengine.objects.AvatarInput.java
com.fdangelo.circleworld.universeengine.objects.Avatar.java
com.fdangelo.circleworld.universeengine.objects.FollowParentParameters.java
com.fdangelo.circleworld.universeengine.objects.IUniverseObjectListener.java
com.fdangelo.circleworld.universeengine.objects.ShipInput.java
com.fdangelo.circleworld.universeengine.objects.Ship.java
com.fdangelo.circleworld.universeengine.objects.UniverseObject.java
com.fdangelo.circleworld.universeengine.tilemap.ITilemapCircleListener.java
com.fdangelo.circleworld.universeengine.tilemap.PlanetType.java
com.fdangelo.circleworld.universeengine.tilemap.PlanetTypes.java
com.fdangelo.circleworld.universeengine.tilemap.Planet.java
com.fdangelo.circleworld.universeengine.tilemap.TileDirection.java
com.fdangelo.circleworld.universeengine.tilemap.TileHitFlags.java
com.fdangelo.circleworld.universeengine.tilemap.TileHitInfo.java
com.fdangelo.circleworld.universeengine.tilemap.TileSubtype.java
com.fdangelo.circleworld.universeengine.tilemap.TileType.java
com.fdangelo.circleworld.universeengine.tilemap.TileTypes.java
com.fdangelo.circleworld.universeengine.tilemap.TilemapCircle.java
com.fdangelo.circleworld.universeengine.utils.DataPools.java
com.fdangelo.circleworld.universeengine.utils.PoolByte.java
com.fdangelo.circleworld.universeengine.utils.PoolColor.java
com.fdangelo.circleworld.universeengine.utils.PoolFloat.java
com.fdangelo.circleworld.universeengine.utils.PoolInt.java
com.fdangelo.circleworld.universeengine.utils.PoolVector2.java
com.fdangelo.circleworld.universeengine.utils.PoolVector3.java
com.fdangelo.circleworld.universeengine.utils.UEProfilerSample.java
com.fdangelo.circleworld.universeengine.utils.UEProfiler.java
com.fdangelo.circleworld.universeview.FollowCameraParameters.java
com.fdangelo.circleworld.universeview.UniverseViewCamera.java
com.fdangelo.circleworld.universeview.UniverseViewFactory.java
com.fdangelo.circleworld.universeview.UniverseView.java
com.fdangelo.circleworld.universeview.objects.AvatarInputEditTool.java
com.fdangelo.circleworld.universeview.objects.AvatarInputMode.java
com.fdangelo.circleworld.universeview.objects.AvatarViewInput.java
com.fdangelo.circleworld.universeview.objects.AvatarView.java
com.fdangelo.circleworld.universeview.objects.InputAreas.java
com.fdangelo.circleworld.universeview.objects.ShipInputMode.java
com.fdangelo.circleworld.universeview.objects.ShipViewInput.java
com.fdangelo.circleworld.universeview.objects.ShipView.java
com.fdangelo.circleworld.universeview.objects.UniverseObjectView.java
com.fdangelo.circleworld.universeview.tilemap.PlanetView.java
com.fdangelo.circleworld.universeview.tilemap.TilemapCircleViewBackgroundRenderer.java
com.fdangelo.circleworld.universeview.tilemap.TilemapCircleViewRenderer.java
com.fdangelo.circleworld.universeview.tilemap.TilemapCircleView.java
com.fdangelo.circleworld.utils.Mathf.java
com.fdangelo.circleworld.utils.Vector2I.java