Skip to content

Commit

Permalink
Rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
neki-dev committed Feb 29, 2024
1 parent 6058f21 commit 02898ed
Show file tree
Hide file tree
Showing 12 changed files with 129 additions and 4 deletions.
15 changes: 15 additions & 0 deletions dist/generator/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { WorldGenerationParams } from "./types";
import { World } from "../world";
import { WorldBiome } from "../world/biome";
import type { WorldConfig } from "../world/types";
import type { WorldBiomeConfig } from "../world/biome/types";
export declare class WorldGenerator<T extends object> {
readonly config: WorldConfig;
private biomes;
constructor(config: WorldConfig);
addBiome(config: WorldBiomeConfig, data: T): WorldBiome<T>;
clearBiomes(): void;
getBiomes(): WorldBiome<T>[];
peakBiome(height: number): WorldBiome<T> | null;
generate(params?: WorldGenerationParams): World<T>;
}
22 changes: 22 additions & 0 deletions dist/generator/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export type WorldGenerationParams = {
/**
* Generation seed
* Default: Autogenerate
*/
seed?: number[];
/**
* Size of seed array
* Default: 512
*/
seedSize?: number;
/**
* Generation offset X
* Default: 0
*/
offsetX?: number;
/**
* Generation offset Y
* Default: 0
*/
offsetY?: number;
};
7 changes: 5 additions & 2 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
export * from './world-generator';
export * from './generator';
export * from './generator/types';
export * from './world';
export * from './types';
export * from './world/types';
export * from './world/biome';
export * from './world/biome/types';
export * from './utils/perlin';
export * from './utils/seed';
2 changes: 1 addition & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions dist/utils/perlin/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import type { PerlinParameters } from "./types";
export declare function generateNoise(parameters: PerlinParameters): number;
7 changes: 7 additions & 0 deletions dist/utils/perlin/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { WorldConfig } from "../../world/types";
export type PerlinParameters = {
seed: number[];
config: WorldConfig;
x: number;
y: number;
};
1 change: 1 addition & 0 deletions dist/utils/seed/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare function generateSeed(size?: number): number[];
7 changes: 7 additions & 0 deletions dist/world/biome/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { WorldBiomeConfig } from "./types";
export declare class WorldBiome<T extends object> {
readonly lowerBound: number;
readonly upperBound: number;
readonly data: T;
constructor(config: WorldBiomeConfig, data: T);
}
14 changes: 14 additions & 0 deletions dist/world/biome/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export type WorldBiomeConfig = {
/**
* Lower biome bound
* Default: 0.0
* Min: 0.0
*/
lowerBound?: number;
/**
* Upper biome bound
* Default: 1.0
* Max: 1.0
*/
upperBound?: number;
};
12 changes: 12 additions & 0 deletions dist/world/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { WorldPoint } from "./types";
export declare class World<T extends object> {
readonly width: number;
readonly height: number;
readonly seed: number[];
private matrix;
constructor(matrix: T[][], seed: number[]);
getMatrix(): T[][];
each(callback: (point: WorldPoint, biome: T) => boolean | void): void;
getAt(point: WorldPoint): T | null;
replaceAt(point: WorldPoint, data: T): void;
}
42 changes: 42 additions & 0 deletions dist/world/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
export type WorldConfig = {
/**
* World width
*/
width: number;
/**
* World height
*/
height: number;
/**
* Frequency of biomes change
* Default: 0.3
* Min: 0.0, Max: 1.0
*/
frequencyChange?: number;
/**
* Smoothness of biomes borders
* Default: 0.5
* Min: 0.0, Max: 1.0
*/
borderSmoothness?: number;
/**
* Redistribution of biomes height
* Default: 1.0
* Min: 0.5, Max: 1.5
*/
heightRedistribution?: number;
/**
* Averaging of biomes height
* Default: true
*/
heightAveraging?: boolean;
/**
* Scale of falloff area
* Default: 0.0
*/
falloff?: number;
};
export type WorldPoint = {
x: number;
y: number;
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gen-biome",
"description": "Procedural generation 2D map with biomes",
"version": "3.0.0",
"version": "3.0.1",
"keywords": [
"map",
"generation",
Expand Down

0 comments on commit 02898ed

Please sign in to comment.