[Example] Procedurally Generated World

This forum is currently in read-only mode.
From the Asset Store
Unlock platyers earning coins, and save it with Localstorage
  • UPDATE:

    -replaced sprites, added shrubs, added bg sprites to give the "cave" feel to it.

    -the download link below has been replaced

    -currently working on making larger worlds using multiple layouts.

    ----------------------------------------------------------------------------------------

    Here's an example of procedural generation using Perlin Noise. Some screenshots-

    <img src="http://dl.dropbox.com/u/5811650/Blizzard/s4.PNG">

    Here's the cap file-

    http://dl.dropbox.com/u/5811650/Blizzard/pertilegen%20v0.3.cap

    The caveman sprite is from the Asemblee Art Assets. The remaining art was done by Steven.

    Link-http://www.scirra.com/forum/viewtopic.php?f=23&t=7128

    Thanks to 'newt' for introducing me to the Perlin Noise plugin(it's actually his .cap file on which I've been working)

  • actualy i like the tileset and especialy the caveman dude it kind a.... nostalgic ^^

  • I like it, hope you'll continue improving it. To create water, there is good R0J0hound's example

  • [quote:38d0opvc]The current problems are-

    Inability to generate large worlds.

    Cannot implement fluids(lakes etc)

    Saving and loading.(trees cannot be saved as there is no info about them in the array)

    To get a large world you can set perlin to a larger size... say 100 x 100, then set your loop to 50 to 100 for another layout.... using the same seed.

    Not sure what your looking for in terms of fluids, but the cap shows one possibility while showing a possible optimization using one sprite set to different frames.

    http://dl.dropbox.com/u/666516/perlincraft.cap

    Keep in mind you've only used the positive values in the noise. There are a few things you can do with the negative as well.

    As far as trees... All I can think of is making an array of all the created sprites, and then saving, and loading it as an external array.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • [quote:1y69p798]To get a large world you can set perlin to a larger size... say 100 x 100, then set your loop to 50 to 100 for another layout.... using the same seed.

    that could help, but is there any other way like drawing the sprites only when it is in the given distance range from the player? that way I won't have to switch layouts

    [quote:1y69p798]Keep in mind you've only used the positive values in the noise. There are a few things you can do with the negative as well.

    can perlin noise generate negative values too? I thought that it generated values between 0 and the max value.

    [quote:1y69p798]As far as trees... All I can think of is making an array of all the created sprites, and then saving, and loading it as an external array.

    thanks that would certainly help.

  • Nice example.

    For the world size just keep in mind that the perlin's size is independent from any other sizes. You can create a virtual huge world (by setting the width and height of the perlin noise) and then use certain methods to draw the world's current section, like the one newt explained. But there is no limitation (You already experienced this, because in your example you lookup the perlin table at positions outside the perlin's size. It is set to 30x30, but you look up to 50). Just set a "sight-range" half the units of one screen. Then when moving lookup the perlin at sight-range and draw the appropiate sprites (or delete them if they are out of sight). In your example one perlin unit equals one sprite, and one sprite is 32x32 pixel. For one screen (your window is 640x480) that means 20x15 perlin units, and so you would look at your player's unit +/- 10 horizontal and +/- 8 vertical.

    perlin noise is generated around zero on both sides, negative and positive. If you set 4 you will get a value between -4 and +4

    For the trees: Why not make multiple use of values? For example, if you would use integers from 0 to 100, you could define that 50 represents grass, while 51 represents grass with a tree on top, and so on.

  • For the trees: Why not make multiple use of values? For example, if you would use integers from 0 to 100, you could define that 50 represents grass, while 51 represents grass with a tree on top, and so on.

    Aha... trees solved

    + System: int(PerlinNoise.GetNoiseAt(LoopIndex("x"), LoopIndex("y")-1)) Equal to -1
    -> System: Create object tree on layer 1 at (mud.X-16, mud.Y)[/code:3ud3g966]
    
    ^Link updated
    [url]http://dl.dropbox.com/u/666516/perlincraft.cap[/url]
  • man I want play so badly with those cap files but can't, bloody exams are going on so can't do much.

    I'll probably develop this in to some sort of game, not now...maybe after march.

    [quote:20s52cue]perlin noise is generated around zero on both sides, negative and positive. If you set 4 you will get a value between -4 and +4

    For the trees: Why not make multiple use of values? For example, if you would use integers from 0 to 100, you could define that 50 represents grass, while 51 represents grass with a tree on top, and so on.

    great idea, this way i could generate some pretty good looking variations like just grass, grass with a flower or grass with tree.

    [quote:20s52cue]^Link updated

    http://dl.dropbox.com/u/666516/perlincraft.cap

    thanks man,but i haven't downloaded the cap though, I don't want to ruin the fun of learning how to do this on my own. Hope you don't mind

  • No prob.

    Since your in a learning mood.....

    You can also take a "slice" of the noise, or get the data from a single axis.

    http://dl.dropbox.com/u/666516/sea.cap

  • No prob.

    Since your in a learning mood.....

    You can also take a "slice" of the noise, or get the data from a single axis.

    http://dl.dropbox.com/u/666516/sea.cap

    Cool idea!

  • [quote:nfif0l48]You can also take a "slice" of the noise, or get the data from a single axis.

    http://dl.dropbox.com/u/666516/sea.cap

    cool! This could be used in some 'pocket tanks' like games.

    actually my first attempt at procedural generation was to make random terrain like what you did right now but i failed since all I was getting was blobs looking thingys.

    <img src="http://dl.dropbox.com/u/5811650/Blizzard/s3.PNG">

    In this I'm pasting more than 10000 '2x2' sprites on the canvas. Yes, I suck in optimization.

    [quote:nfif0l48]Since your in a learning mood.....

    I should probably use that in learning linked lists and search algorithms for my next test.

  • The file has been updated with some changes, see the first post for details.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)