Coder Social home page Coder Social logo

bevy_noise_map's Introduction

This is example project, showing how to use Perlin Noise for procedural generation of terrain from 2d tiles. For different noises explore Noise repo.

Use WASD to move camera, ZX to zoom, ui button to reset map.

All map-building logic located in main.rs for easier exploration. (While running this project, you can move camera with WASD)

I didn't find any for bevy, so I implemented this solution found on Unity forums.

For showcase, I used simple color tiles, feel free to use any tilesets you want, and custom tiling function.

Version Bevy Version
0.1 (current) 0.12
- -

Level generated with this example:

Generated level

Same approach level generation in my pet project:

Live level For terrain tiles I used terrace inverted noise with threshold for ground\water tiles.

pub fn terrain_noisemap(seed: u32) -> NoiseMap {
    let perlin = Perlin::new(seed);

    let terrace_inverted = Terrace::new(perlin)
        .add_control_point(-1.0)
        .add_control_point(-0.5)
        .add_control_point(0.1)
        .add_control_point(1.0)
        .invert_terraces(true);

    PlaneMapBuilder::new(terrace_inverted)
        .set_size(NOISEMAP_SIZE.0, NOISEMAP_SIZE.1)
        .build()
}

For flora I used hybridmulti perlin noice

pub fn flora_noisemap(seed: u32) -> NoiseMap {
    let hybrid_multi = HybridMulti::<Perlin>::new(seed);
    PlaneMapBuilder::new(hybrid_multi)
        .set_size(NOISEMAP_SIZE.0, NOISEMAP_SIZE.1)
        .build()
}

Also, I implemented transition detection in resulting noise to place transition tiles correctly, but this problem lies outside of topic a bit.

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.