https://github.com/pixelrobin/superpowers-game-noisejs-plugin
🏔 noisejs plugin for Superpowers Game
https://github.com/pixelrobin/superpowers-game-noisejs-plugin
Last synced: over 1 year ago
JSON representation
🏔 noisejs plugin for Superpowers Game
- Host: GitHub
- URL: https://github.com/pixelrobin/superpowers-game-noisejs-plugin
- Owner: Pixelrobin
- License: mit
- Created: 2016-08-11T04:58:03.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2018-10-29T07:44:38.000Z (over 7 years ago)
- Last Synced: 2025-01-19T21:50:00.299Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 2.64 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# superpowers-game-noisejs-plugin
[Noisejs](https://github.com/josephg/noisejs) plugin for [Superpowers Game](https://github.com/superpowers/superpowers-game).

## Installation on Windows
Use the following commands
```
cd %appdata%\Superpowers\systems\game\plugins\extra
git clone --recursive https://github.com/Pixelrobin/superpowers-game-noisejs-plugin noisejs
```
Currently not tested on mac or linux. If anyone is willing to share how to install on those platforms, please open a PR!
## Demo project
The repository contains a little demo project with minecraft-like terrain generation. Just copy the `noisejs-demo` folder from `project\demo.zip` to your superpowers project directory. Make sure you installed the plugin.
On Windows, in a typical installation, your projects folder is located under `%appdata%\Superpowers\projects` and if you followed the directions above, the plugin should be installed in `%appdata%\Superpowers\systems\game\plugins\extra\` as the folder `noisejs`.
## Usage
``` Typescript
// Set the seed of the noise ( float between 0 and 1 or integer between 1 and 65536 )
Noise.seed( seed: number ): void
// Make a random seed for the noise
Noise.makeRandomSeed(): void
// Get the last set seed
Noise.getSeed(): number
// Simplex Noise functions
Noise.simplex2d( x: number, y: number ): number // 2D
Noise.simplex3d( x: number, y: number, z: number ): number // 3D
// Perlin Noise functions
Noise.perlin2d( x: number, y: number ): number // 2D
Noise.perlin3d( x: number, y: number, z: number ): number // 3D
```
## Example
``` Typescript
// Taken and adapted from the original noisejs repo
let width = 10, height = 10, time = 0, values: number[] = [];
Noise.makeRandomSeed();
for (var x = 0; x < width; x ++) {
for (var y = 0; y < height; y ++) {
// All noise functions return values in the range of -1 to 1.
// noise.simplex2 and noise.perlin2 for 2d noise
let value = Noise.simplex2d(x / 100, y / 100);
// ... or noise.simplex3 and noise.perlin3:
let value = Noise.simplex3d(x / 100, y / 100, time);
values[ x, y ] = value // Or whatever. See demo project for a minecraft-like terrain generator
}
}
```
## License
This project is licensed under the [MIT License](https://github.com/Pixelrobin/superpowers-game-noisejs-plugin/blob/master/LICENSE).
It includes code from josephg/noisejs, which is licensed under the [ISC License](https://github.com/josephg/noisejs/blob/master/LICENSE)