Class WorldGenerator

java.lang.Object
org.collebol.game.world.WorldGenerator

public abstract class WorldGenerator extends Object
Abstract class representing a world generator in the EJGEngine. This class is responsible for generating and saving chunks in the game world.

Usage:

 
 WorldGenerator generator = new MyWorldGenerator(myWorld);
 
 

You have to create your own generateChunk(Chunk) method before using.

For more information, please refer to the EJGEngine Wiki.

Since:
1.0-dev
Author:
ColleBol - contact@collebol.org
  • Constructor Details

    • WorldGenerator

      public WorldGenerator(World world)
  • Method Details

    • generateChunk

      public abstract Chunk generateChunk(Chunk chunk)
      Generate chunk method.

      Here you have to create your own Chunk.

      Example chunk generator:

       
       for (int i = 0; i < chunk.getChunkSize(); i++) {
           for (int j = 0; j < chunk.getChunkSize(); j++) {
               GameLocation location = new GameLocation(i + (chunk.getX() * chunk.getChunkSize()), j + (chunk.getY() * chunk.getChunkSize()));
               float chance = new Random().nextFloat();
               MyTile tile = new MyTile();
               tile.setGameLocation(location);
               chunk.addTile(tile);
           }
       }
               saveChunk(chunk);
               return chunk;
       
       
      Parameters:
      chunk - Chunk base.
      Returns:
      chunk with chunk data, like: Tile's
    • generateRenderDistanceIfNotExists

      public void generateRenderDistanceIfNotExists(GameLocation location)