项目作者: esimov

项目描述 :
Simplex noise based minecraft map generator
高级语言: JavaScript
项目地址: git://github.com/esimov/minecraft.js.git
创建时间: 2016-04-01T09:18:39Z
项目社区:https://github.com/esimov/minecraft.js

开源协议:MIT License

下载


minecraft.js

This is an experiment adapted from Notch’s Javascript Minecraft renderer, but extended with new aditions, like random terrain generation, fog and fake shadows, possibility to navigate and look over the generated landmark.

As a fundation is using the simplex noise random seed distribution algorithm. For the Javascript port of simplex noise algorithm check simplexnoise.js.

Screenshot

Live demo

Features

  • Highly adaptive
  • Customizable
  • Using fake shadow and fog for generating atmospheric environment
  • Posibility to navigate through the map (hovevery this is somehow limited)
  • You can look around and change the altitude of the camera with the mouse
  • You can play with with the sliders from the side panel to generate different maps and environments

How to run

  • npm install to install the node-static package
  • node app.js to run the server
  • localhost:3000 to run in the browser

If you wish to change the default seed distribution you can change the code below:

  1. for (var pixel = 0; pixel < noise.length; pixel += 4) {
  2. var x = (pixel / 4) % ww;
  3. var y = Math.floor(pixel / hh / 4);
  4. x /= ww;
  5. y /= hh; // normalize
  6. var size = GUI.frequency || 2; // pick a scaling value
  7. // add octaves
  8. var value = Math.floor(
  9. (simplex.noise(size * x * GUI.x, size * y * GUI.y, 0.1 + GUI.z) +
  10. simplex.noise(2 * size * x * GUI.x, 2 * size * y * GUI.y, 0.1 + GUI.z) * 0.5)
  11. * 177);
  12. noise[pixel] = noise[pixel + 1] = noise[pixel + 2] = value;
  13. noise[pixel + 3] = 255;
  14. }

If you wish to replace the simplex noise algorithm to Perlin noise you need to change the line below:

  1. var simplex = new NOISE.Simplex();
  2. simplex.init();
  3. simplex.noiseDetail(4, 2);

with

  1. var simplex = new NOISE.Perlin();
  2. simplex.init();
  3. simplex.noiseDetail(4, 2);

The Perlin noise algorithm is included in the package.

Running example:
www.esimov.com/experiments/javascript/minecraft_v2/

Author

License

Copyright © 2016 Endre Simo

This software is distributed under the MIT license. See the LICENSE file for the full license text.