Android Open Source - CircleWorldGDX Universe Generator Default






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 ww .jav  a2s . c o  m*/
import com.fdangelo.circleworld.universeengine.tilemap.Planet;

public class UniverseGeneratorDefault extends UniverseGenerator {

  @Override
  protected void addGalaxy() {
    final int galaxyOrbits = random.nextInt(10) + 10;

    final short galaxySafeRadius = (short) (things[currentThing].safeRadius / 2);
    final short solarSystemRadius = (short) (galaxySafeRadius / (galaxyOrbits * 2));

    for (int i = 0; i < galaxyOrbits; i++) {
      final short solarSystemDistance = (short) ((galaxySafeRadius * i) / galaxyOrbits);

      final int minSolarSystems = (Math.max(i * 5, 1) + 1) / 2;
      final int maxSolarSystems = Math.max(i * 5, 1) + 1;

      final int solarSystems = random.nextInt(maxSolarSystems - minSolarSystems) + minSolarSystems;

      short solarSystemOrbitalPeriod = (short) (random.nextInt(120) + 120);
      if (random.nextInt(2) == 0) {
        solarSystemOrbitalPeriod = (short) -solarSystemOrbitalPeriod;
      }

      for (int j = 0; j < solarSystems; j++) {
        final short solarSystemAngle = (short) ((36000 * j) / solarSystems);

        pushThing(ThingType.SolarSystem, solarSystemAngle, solarSystemDistance, (short) 0, solarSystemOrbitalPeriod, (short) 0, solarSystemRadius, 0);
        {
          final int suns = random.nextInt(3) + 1;

          final short solarSystemSafeRadius = things[currentThing].safeRadius;

          final short minRadius = (short) ((solarSystemRadius / 8) / 2);
          final short maxRadius = (short) (solarSystemRadius / 8);

          final short sunRadius = (short) (random.nextInt(maxRadius - minRadius) + minRadius);

          if (suns == 1) {
            pushThing(ThingType.Sun, (short) 0, (short) 0, (short) 0, (short) 0, Planet.getClosestValidRadius(sunRadius), (short) 0,
                random.nextInt());
            popThing();
          } else {
            final short sunDistance = (short) (sunRadius * 4 / 3);
            short sunOrbitalPerdiod = (short) (random.nextInt(30) + 30);
            if (random.nextInt(2) == 0) {
              sunOrbitalPerdiod = (short) -sunOrbitalPerdiod;
            }

            for (int k = 0; k < suns; k++) {
              final short sunAngle = (short) ((36000 * k) / suns);

              pushThing(ThingType.Sun, sunAngle, sunDistance, (short) 0, sunOrbitalPerdiod, Planet.getClosestValidRadius(sunRadius), (short) 0,
                  random.nextInt());
              popThing();
            }
          }

          final int planetsOrbits = random.nextInt(7) + 1;

          final short planetSafeRadius = (short) ((solarSystemSafeRadius - sunRadius * 6) / (planetsOrbits * 2));

          for (int l = 0; l < planetsOrbits; l++) {
            final short planetDistance = (short) (sunRadius * 6 + ((solarSystemSafeRadius - sunRadius * 6) * l) / planetsOrbits);

            final short planetAngle = (short) random.nextInt(36000);

            short planetRotationPeriod = (short) (random.nextInt(30) + 30);
            if (random.nextInt(2) == 0) {
              planetRotationPeriod = (short) -planetRotationPeriod;
            }

            short planetOrbitationPeriod = (short) (random.nextInt(30) + 30);
            if (random.nextInt(2) == 0) {
              planetOrbitationPeriod = (short) -planetOrbitationPeriod;
            }

            final short minPlanetRadius = (short) (planetSafeRadius / 16);
            final short maxPlanetRadius = (short) (planetSafeRadius / 9);

            short planetRadius;
            if (maxPlanetRadius - minPlanetRadius > 0) {
              planetRadius = (short) (random.nextInt(maxPlanetRadius - minPlanetRadius) + minPlanetRadius);
            } else {
              planetRadius = minPlanetRadius;
            }

            pushThing(ThingType.Planet, planetAngle, planetDistance, planetRotationPeriod, planetOrbitationPeriod,
                Planet.getClosestValidRadius(planetRadius), planetSafeRadius, random.nextInt());
            popThing();
          }

        }
        popThing();
      }
    }
  }
}




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