Package org.collebol.game.world
Class WorldGenerator
java.lang.Object
org.collebol.game.world.WorldGenerator
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract ChunkgenerateChunk(Chunk chunk) Generate chunk method.
-
Constructor Details
-
WorldGenerator
-
-
Method Details
-
generateChunk
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
-