How to generate Blocks like Terraria (2D)

Hey guys, I’m making a Terraria + Castlevania SotN mix, got Characterstats, Inventory, etc. done.

When reaching the point where I have to create the world the player will be wandering, I just made a quick and dirty solution.
I took the PerlinNoise, put in a 128x128 Texture to show me the output (this grey noise).
Checked the output values, saw there is always something bewtween 0.0f and 0.6f (with my current settings).

I created 9 Blocks for testing, and placed the blocks depending on the Noisevalue…

0.0f - 0.1f dirt
0.1f - 0.2f stone

etc…

My problem is, I don’t know how to modify the noise correctly to create biomes with it.
I found barely anything that could help me on my topic, so I hope you could give me at least a nice hint.

[19799-unity+forum.png|19799]

Have a nice day

i don’t claim to know how its normally done but the way i’d do it.

Define each bio as a class

have in it a list of blocks which that bio can choose from to spawn

assign each block a random chance of being selected

so for example

DesertBio
{
list<blocks> BlocksSpawnable;

BlocksSpawnable.add(DesertTile);
BlocksSpawnable.add(WaterTile); //small chance of an oasis
BlocksSpawnable[1].getComponent<BlockScript>().SpawnChance = 80;
BlocksSpawnable[0].getComponent<BlockScript>().SpawnChance = 20;

//create bio returns a 2 dimensional list of blocks to spawn
blocks[,] CreateBio(int Length, int Width)
{
blocks[,] BlocksToSpawn = new blocks[Length, Width];

// at this point you can start specializing
//for example if height is  != 0 (not at ground level) remove snowy ground cover blocks from 
//possible spawn list and redistribute there spawn chance.

//check all neighboring blocks and if a water block exists chance to spawn water goes to 75%
//so for example

for(int X = currentX - 1 ;X <= currentX + 1; X++
{
for (int Y = currentY - 1; X <= currentY + 1; Y++
{
   if(Blocks[X,Y].tag == "water")
      //Modify spawn chance
}
}

//now that you've done all the modifications you just generate a number and compare to figure out which block to spawn.



}

Hope this helps, post if you need more help

This guy is a genius:

The code is in AS3, so easy to port to JS, I am using this to make island shapes and it works very well. The key is to hook the threshold, etc variables up to public variables so you can tweak them while the game is running.

Try using Perlin Noise as a function

When doing something similar in 3D, I used different Perlin Noise calls with different parameters to set some basic values:

Call one gave me the height of the terrain
Call two gave me the humidity of the terrain
Call three gave the temperature.

Earth biomes actually work basically on these 3 data.

You can now set biomes depending on the above results. Google Image search “biome graph”. This should help with the idea.

You than specify how each biome should behave