Skip to content

A1essandro/php-map-maker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MapMaker

##Usage example:

use MapGenerator\DiamondAndSquare;
use MapMaker\Base\Grid;
use MapMaker\Base\Map;
use MapMaker\GDVisualiser;
use MapMaker\HeightLayer;
use MapMaker\WaterlineGDVisualiser;
use MapMaker\WaterlineLayer;

require __DIR__ . '/vendor/autoload.php';

//init map
$map = new Map(new Grid(100, 100));
$map->setVisualiser(new GDVisualiser(GDVisualiser::TYPE_PNG));

// See https://github.com/A1essandro/Diamond-And-Square
$heightMap = DiamondAndSquare::generateAndGetMap(7, 100);

//HeightLayer
$heightLayer = new HeightLayer($map, $heightMap);
$heightLayer->cut(2, 2);
$heightLayer->generate();
$map->attachLayer($heightLayer);

//Waterline layer
$waterLayer = new WaterlineLayer($map, $heightLayer);
$waterLayer->setWaterRatio(1 / rand(2, 5));
$waterLayer->generate();
$map->attachLayer($waterLayer);

//add visualiser for WaterlineLayer
$waterlineVisualiser = new WaterlineGDVisualiser();
$waterlineVisualiser->setLayer($waterLayer);
$map->addLayerVisualiser($waterlineVisualiser);

echo $map->render();

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages