GithubHelp home page GithubHelp logo

bharadwaj-raju / island Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 2.0 92 KB

Simple Island Generator and Renderer

License: MIT License

C++ 44.61% Python 54.12% Makefile 1.26%
procedural-generation island simplex generative-art generator game-development

island's Introduction

island

Simple Island Generator and Renderer

Algorithm

Requirements

  1. C++ compiler
  2. Python 3
  3. Python modules: pypng and Pillow.

Compile the generators (at the moment, only Simplex):

$ make

Now, you'll get a SimplexIslandGen executable in the bin/ directory.

Generating an Island

$ bin/SimplexIslandGen
Usage: ./SimplexIslandGen SIZE OUTPUT-FILENAME [SEED or "SEED=unset"] [LOWER-BOUND UPPER-BOUND]

Only SIZE and OUTPUT-FILENAME are necessary.

To generate, for example, an island of size 1024 x 1024:

$ bin/SimplexIslandGen 1024 island.hmap
Image size: 1024
Saving data to filename: island.hmap
Seed (unique ID): 929654437
Lower bound: 0
Upper bound: 1

The program will output island.hmap, containing the height values generated.

Now you can render this file into an image:

929654437

Adjusting the LOWER-BOUND UPPER-BOUND argument can make the island's shape much more interesting. For example, try:

$ bin/SimplexIslandGen 1024 island.hmap SEED=unset -0.25 1.0
Image size: 1024
Saving data to filename: island.hmap
Seed (unique ID): 73068098
Lower bound: -0.25
Upper bound: 1

73068098

Rendering an Island

Two Python scripts are provided for rendering the .hmap files: IslandRender.py and Island3DRender.py.

Simple 2D Rendering

Use the provided IslandRender.py with a .hmap file generated.

For example, using the island.hmap we generated before:

$ python3 IslandRender.py island.hmap island.png

Outputs a PNG file with the rendered island divided into water/land.

Render heights as colors

Add the flag --mode=color-heights.

$ python3 IslandRender.py island.hmap island.png --mode=color-heights

929654437-heights

Render biomes

Generate another file, of same size as the .hmap, like this:

$ bin/SimplexIslandGen 1024 island.biome
Image size: 1024
Saving data to filename: island.biome
Seed (unique ID): 2007696746
Lower bound: 0
Upper bound: 1

Now use IslandRender.py like this:

$ python3 IslandRender.py island.hmap island.png --mode=biome --biome-file=island.biome

929654437-2007696746-biome

The island.biome is a moisture map.

Biomes are calculated as a function of elevation and moisture. See the biome(elevation, moisture) function in IslandRender.py to adjust it.

Colors

Colors for the rendering are defined in IslandRenderColors.json. Modify it to your liking.

Other Options

Run IslandRender.py with --help.

3D Rendering

Needs the following modules: numpy, matplotlib.

Renders the island as an x, y, z graph using matplotlib. Slow.

Algorithm

For now, only the Simplex algorithm is implemented.

I made a custom Simplex generator inspired by python-rpg's version, since neither LibNoise, nor FastNoise provided the customization I wanted.

File Formats

The .hmap and .biome files generated are simply space-and-newline separated file, containing height/moisture values.

island's People

Contributors

bharadwaj-raju avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.