|
An idea copied from facepunch forums, post what you are currently working on in this thread.
Working on map generation for my RTS.. cl.ly/0f3067e8f60475d2b958TileMap.RegisterGenerator("TerraceMap", function (targetMap, params) { var cliffThreshold = 0.4; var width = params.width; var height = params.height; targetMap.initWithSize(width, height);
var mountainTerrain = new Noise.Module.RidgedMulti; var constval = new Noise.Module.Const; constval.constValue = 5; var combiner = new Noise.Module.Multiply; combiner.SetSourceModule(0, constval); combiner.SetSourceModule(1, mountainTerrain); var baseFlatTerrain = new Noise.Module.Billow; baseFlatTerrain.frequency = 2.0;
var flatTerrain = new Noise.Module.ScaleBias; flatTerrain.SetSourceModule (0, baseFlatTerrain); flatTerrain.scale = 0.125; flatTerrain.bias = -0.75; var terrainType = new Noise.Module.Perlin; terrainType.frequency = 0.5; terrainType.persistence = 0.25;
var terrainSelector = new Noise.Module.Select; terrainSelector.SetSourceModule (0, flatTerrain); terrainSelector.SetSourceModule (1, combiner); terrainSelector.SetControlModule (terrainType); terrainSelector.setBounds (0, 1000.0); terrainSelector.edgeFalloff = 0.125; var NoiseMap = new Noise.Utils.NoiseMap; var NoiseMapBuilder = new Noise.Utils.NoiseMapBuilderPlane; NoiseMapBuilder.setSourceModule(terrainSelector); NoiseMapBuilder.setDestNoiseMap(NoiseMap); NoiseMapBuilder.setDestSize(width, height); NoiseMapBuilder.setBounds(6.0, 10.0, 1.0, 5.0); NoiseMapBuilder.Build(); for(var y = 1; y <= height; y++) { for(var x = 1; x <= width; x++) { var tileName = "Default";
var elevation = NoiseMap.getValue(x,y);
if(NoiseMap.getValue(x-1,y) > elevation+cliffThreshold || NoiseMap.getValue(x,y-1) > elevation+cliffThreshold) { tileName = "Cliff"; } else if(NoiseMap.getValue(x+1,y) > elevation+cliffThreshold || NoiseMap.getValue(x,y+1) > elevation+cliffThreshold) { tileName = "Cliff" } else if(elevation > 0.7) { tileName = "Rock"; } else { tileName = "Grass"; }
var tile = Tile(tileName); tile.elevation = elevation;
targetMap.setTileAt(x, y, tile); } } });
Last Edit: Nov 11, 2010 23:24:20 GMT by Simie
|
|
|
|
|
|
Simultaneous 4 projects: -2 social network type projects -1 Contact Relationship Manager -1 Charity Network
|
|
|
|
Well, I'm supposed to be working on an English essay on thematic poetry...
|
|
|
|
Working on SZv3, bunch of different coding assignments for class (including mapping and constructing a network and understanding the issues that can arise from incorrect communication via nodes), and then a task management program.
|
|
|
|