Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Super happy!

edited November 8 in General Posts: 5

This is a screenshot of what I’m currently messing around with. Haven’t coded in years, and with codea I’m doing more then I have before. I can’t thank the devs enough.

[img]https://i.imgur.com/q1RDmxT.jpg[/img]

Comments

  • Posts: 5

    First I seed the map with random elevation values. I used a range of 1-255 because that maps nicely to grey scale color range. White being high elevation(snow).
    Next I run a really hairy tectonic plate formation algorithm, which seriously needs some cleaning, but works. As it is now it creates 6 contiguous regions. I randomly choose 2 and shift a portion of their mass in a random cardinal direction, a random amount of times.
    And finally I run an erosion algorithm to soften the surface. I’m not happy with this bit either. It’s aggressive.

    Oh but the plans for the future, my head spins…..

  • Posts: 255

    @bitmage Looks nice! Welcome to the Codea Community too :smile:

  • Posts: 1,547

    Wow that’s super cool—and you worked so fast!

    .…hmmmm not to be a troublemaker but it seems like it might just be possible to build voxel terrain out of what you did here (https://codea.io/talk/discussion/12640/terrain-generator-replay)*

    :)

    Added bonus being that you’ll be able to walk around on it, FPS- style, as soon as it’s generated*.

    *if you adapt my adaptation of @dave1707’s code, which is posted to the same discussion ;)

  • Posts: 1,275

    looks interesting

  • dave1707dave1707 Mod
    edited November 9 Posts: 9,725

    Here’s some code that uses perlin.noise. Slide your finger around to move the scene. You can change the values for snow, dirt, etc. for something different.

    function setup()
        dx,dy=0,0
        n=craft.noise.perlin() 
        max=0
        min=99
        snow=.7
        dirt=.58
        grass=.5
        sand=.45
    end
    
    function draw()
        background()
        for x=0,2,.01 do
            for y=0,2,.01 do
                v=n:getValue(x+dx/500,y+dy/500)+1.3
                if v>max then
                    max=v
                elseif v<min then
                    min=v
                end
                if v>max*snow then
                    fill(255)
                elseif v>max*dirt then
                    fill(90, 78, 32)
                elseif v>max*grass then
                    fill(100, 236, 67)
                elseif v>max*sand then
                    fill(233, 210, 77)
                else
                    fill(0, 33, 255)
                end
                rect(x*WIDTH//2.1,y*HEIGHT//2.1,14)
            end
        end
        fill(255)
        text("min  "..min.."   max  "..max,200,HEIGHT-20)
        text("x  "..dx.."   y  "..dy,600,HEIGHT-20)
    end
    
    function touched(t)
        dx=dx-t.deltaX
        dy=dy-t.deltaY
    end
    
Sign In or Register to comment.