Legend Terrain

A dive into the feasability of procedural worlds.

Back Go to Github

"Platformer"

I wont lie. The title doesn't captivate me either, but this isn't meant to be a game, so it didn't feel appropriate to make a name.

I wanted to get my vision at least working before the final submission. And I think I can say I somewhat achieved that.

There's a few things that I had to do here. I converted my GameObject and Input and everything else into SFML.

It doesn't look as pretty in a block of code, but it works similarly to the original.

I created a tile system and used perlin noise to generate levels, here's a snippet of that and what it looks like...


std::vector* generateMap(int width, int height) {
    chunkCols = width / Chunk::CHUNK_SIZE;
    chunkRows = height / Chunk::CHUNK_SIZE;
    map = new std::vector();
    map->reserve(chunkCols * chunkRows);
        
    FastNoiseLite noise;
    noise.SetNoiseType(FastNoiseLite::NoiseType_Perlin);
    noise.SetFrequency(0.02);
        
    std::random_device rd;
    std::mt19937 eng(rd());
    std::uniform_int_distribution<> distr(0, std::numeric_limits::max());
    noise.SetSeed(distr(eng));
        
    for (int chunkY = 0; chunkY < chunkCols; chunkY++) {
        for (int chunkX = 0; chunkX < chunkRows; chunkX++) {
            Chunk* chunk = new Chunk(chunkX * Chunk::CHUNK_SIZE, chunkY * Chunk::CHUNK_SIZE);
                        fillChunkWithTiles(*chunk, chunkX, chunkY, noise);
                        map->push_back(*chunk);
        }
    }
        
    if (!isTraversable(/*map*/)) {
        return generateMap(width, height);
    }
        
    return map;
}
            
LegendTerrain 0.1 Screenshot

All this really does is turn the base noise frequency into a conglameration of tiles of type "Air" and "Ground" for our player.

Combined with the input system and object manager. Not to mention some fancy Spatial Partitioning, we have a demo.

Opening each time provides a different map, which was our goal. Please take a look at the github of the technical side of things interesets you. :)

Check out the full project HERE!