Skip to content

Commit

Permalink
Updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
neki-dev committed Feb 29, 2024
1 parent 642ff3a commit 6058f21
Showing 1 changed file with 69 additions and 71 deletions.
140 changes: 69 additions & 71 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,119 +29,117 @@ npm i gen-biome
.

## Generator
#### Create world generator
### Create world generator
```ts
const generator = new WorldGenerator<T>(config)
new WorldGenerator<T>(config: WorldConfig)
```
* `config {`
* * `width` - Map width
* * `height` - Map height
* * `frequencyChange` - Frequency of biomes change
* * * _Default: 0.3, Min: 0.0, Max: 1.0_
* * `borderSmoothness` - Smoothness of biomes borders
* * * _Default: 0.5, Min: 0.0, Max: 1.0_
* * `heightRedistribution` - Redistribution of biomes height
* * * _Default: 1.0, Min: 0.5, Max: 1.5_
* * `heightAveraging` - Averaging of biomes height
* * * _Default: true_
* * `falloff` - Scale of falloff area
* * * _Default: 0.0_
* `}`
[`config`] - _World config_

| Prop | Description | Default | Range |
| ---- | ----------- | ------- | ----- |
| width | Map width | | |
| height | Map height | | |
| frequencyChange | Frequency of biomes change | 0.3 | 0.0 - 1.0 |
| borderSmoothness | Smoothness of biomes borders | 0.5 | 0.0 - 1.0 |
| heightRedistribution | Redistribution of biomes height | 1.0 | 0.5 - 1.5 |
| heightAveraging | Averaging of biomes height | true | |
| falloff | Scale of falloff area | 0.0 | |

.

## Biomes
#### Add biome to layer
### Add biome
```ts
for (const { params, data } of ...) {
const biome: WorldBiome = generator.addBiome(params, data)
}
generator.addBiome(
config: WorldBiomeConfig,
data: T,
): WorldBiome<T>
```
* `params {`
* * `lowerBound` - Lower biome bound
* * * _Default: 0.0_
* * `upperBound` - Upper biome bound
* * * _Default: 1.0_
* `}`
* `data` - Data of biome

#### Get layer biomes
[`config`] - _Biome config_

| Prop | Description | Default |
| ---- | ----------- | ------- |
| lowerBound | Lower biome bound | 0.0 |
| upperBound | Upper biome bound | 1.0 |

[`data`] - _Biome data that will be stored in the world matrix_

### Get current biomes
```ts
const biomes: WorldBiome[] = layer.getBiomes()
generator.getBiomes(): WorldBiome<T>[]
```

#### Clear all layer biomes
### Clear all biomes
```ts
layer.clearBiomes()
generator.clearBiomes()
```

.

## Generation
#### Generate world
### Generate world
```ts
const world: World = generator.generate(params?)
generator.generate(
params?: WorldGenerationParams,
): World<T>
```
* `params {`
* * `seed` - Generation seed
* * * _Default: Autogenerate_
* * `seedSize` - Size of seed array
* * * _Default: 512_
* * `offsetX` - Generation offset X
* * * _Default: 0_
* * `offsetY` - Generation offset Y
* * * _Default: 0_
* `}`
[`params`] - _Generation params_ (optional)

| Prop | Description | Default |
| ---- | ----------- | ------- |
| seed | Generation seed | (autogenerated) |
| seedSize | Size of seed array | 512 |
| offsetX | Generation offset X | 0 |
| offsetY | Generation offset Y | 0 |

.

## World
#### Get matrix of biomes data
### Get matrix of biomes data
```ts
const matrix: T[][] = world.getMatrix()
world.getMatrix(): T[][]
```

#### Each all positions
### Each all positions
```ts
world.each(callback)
world.each(
callback: (position: WorldPoint, data: T) => void,
): void
```
* `callback(`
* * `position` - Position at matrix
* * `data` - Biome data
* `)`
[`callback`] - _Callback with position and biome stored data_

#### Get biome data at position
### Get biome data at position
```ts
const data: T = world.getAt(position)
world.getAt(
position: WorldPoint,
): T | null
```
* `position {`
* * `x` - X position at matrix
* * `y` - Y position at matrix
* `}`
[`position`] - _Position at matrix_

#### Replace biome data at position
### Replace biome data at position
```ts
world.replaceAt(position, data)
world.replaceAt(
position: WorldPoint,
data: T,
): void
```
* `position {`
* * `x` - X position at matrix
* * `y` - Y position at matrix
* `}`
* `data` - New data of biome
[`position`] - _Position at matrix_

[`data`] - _New biome stored data_

#### Get current world generation seed
### Get current world generation seed
```ts
const seed: number[] = world.seed
world.seed: number[]
```

#### Get world width
### Get world width
```ts
const width: number = world.width
world.width: number
```

#### Get world height
### Get world height
```ts
const height: number = world.height
world.height: number
```

.
Expand Down

0 comments on commit 6058f21

Please sign in to comment.