示例#1
0
文件: main.go 项目: ajhager/rog
func render() {
	base_x += 1.0
	base_y += 1.0

	alpha = alpha_lerp()
	beta = beta_lerp()

	r := uint8(r_lerp())
	g := uint8(g_lerp())
	b := uint8(b_lerp())

	for x := 0.0; x < width; x++ {
		for y := 0.0; y < height; y++ {
			px := base_x + x
			py := base_y + y

			perlin := perlin.Noise2D(px, py, int64(seed), alpha, beta, octaves)
			perlin = (perlin * .5) + .5
			perlin = math.Max(0.0, perlin)
			perlin = math.Min(1.0, perlin)

			color := rog.RGB{r, g, b}
			result := rog.Black.Alpha(color, perlin)

			rog.Set(int(x), int(y)+1, nil, result, "")
		}
	}

}
示例#2
0
func (self *World) Feature2(x uint16, z uint16) float64 {
	noise := perlin.Noise2D(float64(x-MAP_DIAM)/(NOISE_SCALE/4), float64(z-MAP_DIAM)/(NOISE_SCALE/4), self.seed, 3, 5, 7)
	if noise > 1.0 {
		noise = 1.0
	}
	if noise < -1.0 {
		noise = -1.0
	}
	return noise
}
示例#3
0
func (self *World) Feature1(x uint16, z uint16) float64 {
	noise := perlin.Noise2D(float64(x-MAP_DIAM)/(NOISE_SCALE/4), float64(z-MAP_DIAM)/(NOISE_SCALE/4), worldSeed, 6, 8, 14)
	if noise > 1.0 {
		noise = 1.0
	}
	if noise < -1.0 {
		noise = -1.0
	}
	return noise
}
示例#4
0
func (self *World) SoilThickness(x uint16, z uint16) uint16 {
	noise := perlin.Noise2D(float64(x-MAP_DIAM)/(2*NOISE_SCALE), float64(z-MAP_DIAM)/(2*NOISE_SCALE), self.seed, 1.8, 1.6, 8)
	if noise > 1.0 {
		noise = 1.0
	}
	if noise < -1.0 {
		noise = -1.0
	}

	return uint16(noise*2.5 + 2.5)
}
示例#5
0
func (self *World) Copper(x uint16, z uint16) uint16 {
	noise := perlin.Noise2D(float64(x-MAP_DIAM)/(NOISE_SCALE/2.5), float64(z-MAP_DIAM)/(NOISE_SCALE/2.5), self.seed, 3.1, 2.0, 6)
	if noise > 1.0 {
		noise = 1.0
	}
	if noise < 0.54 {
		noise = 0
	}

	noise = noise * 3

	return uint16(noise)
}
示例#6
0
func (self *World) Iron(x uint16, z uint16) uint16 {
	noise := perlin.Noise2D(float64(x-MAP_DIAM)/(NOISE_SCALE/2.2), float64(z-MAP_DIAM)/(NOISE_SCALE/2.2), self.seed, 2.5, 1.9, 6)
	if noise > 1.0 {
		noise = 1.0
	}
	if noise < 0.56 {
		noise = 0
	}

	noise = noise * 3

	return uint16(noise)
}
示例#7
0
func (self *World) Coal(x uint16, z uint16) uint16 {
	noise := perlin.Noise2D(float64(x-MAP_DIAM)/(NOISE_SCALE/2), float64(z-MAP_DIAM)/(NOISE_SCALE/2), self.seed, 1.9, 1.2, 12)
	if noise > 1.0 {
		noise = 1.0
	}
	if noise < 0.55 {
		noise = 0
	}

	noise = noise * 4

	return uint16(noise)
}
示例#8
0
func (self *World) Rocks(x uint16, z uint16) uint16 {
	noise := perlin.Noise2D(float64(x-MAP_DIAM)/(NOISE_SCALE/2), float64(z-MAP_DIAM)/(NOISE_SCALE/2), self.seed, 1.5, 3.0, 12)
	if noise > 1.0 {
		noise = 1.0
	}
	if noise < 0.8 {
		noise = 0
	}

	noise = noise * 5

	return uint16(noise)
}
示例#9
0
func (self *World) Ore(x uint16, z uint16, blockid BlockId, occcurrence float64) uint16 {
	xloc := (float64(x) + MAP_DIAM*float64(blockid)) / (NOISE_SCALE / 2)
	zloc := (float64(z) + MAP_DIAM*float64(blockid)) / (NOISE_SCALE / 2)
	noise := perlin.Noise2D(xloc, zloc, self.seed, 2.4, 1.8, 4)
	if noise > 1.0 {
		noise = 1.0
	}
	if noise < occcurrence {
		noise = 0
	} else {
		noise = 5 * (noise - occcurrence) / (1 - occcurrence)
	}
	return uint16(noise)
}
示例#10
0
func (self *World) GroundLevel(x uint16, z uint16) uint16 {
	noise := perlin.Noise2D(float64(x-MAP_DIAM)/(4*NOISE_SCALE), float64(z-MAP_DIAM)/(4*NOISE_SCALE), self.seed, 1.4, 1.2, 4)
	if noise > 1.0 {
		noise = 1.0
	}
	if noise < -1.0 {
		noise = -1.0
	}
	if noise < 0.0 {
		noise /= 10
	}

	ground := uint16(SEA_LEVEL + ((CHUNK_HEIGHT-SEA_LEVEL)*0.9)*(noise+0.1)/1.1)
	return ground
}
示例#11
0
func (self *World) GroundLevel(x uint16, z uint16) uint16 {
	noise := perlin.Noise2D(float64(x-MAP_DIAM)/(4*NOISE_SCALE), float64(z-MAP_DIAM)/(4*NOISE_SCALE), worldSeed, 1.4, 1.2, 4)
	if noise > 0.85 {
		noise = noise + (1.0-noise)*0.5
	}
	if noise > 1.0 {
		noise = 1.0
	}
	if noise < -1.0 {
		noise = -1.0
	}
	if noise < 0 {
		noise /= 15
	}
	ground := uint16((CHUNK_HEIGHT/2)*(noise+0.1)/1.1 + CHUNK_HEIGHT/3.0)
	return ground
}
示例#12
0
文件: main.go 项目: laochailan/rain
func NewPane(w, h, n int) *Pane {
	p := new(Pane)
	p.w = w
	p.h = h
	p.fw = dx * float64(w)
	p.fh = dx * float64(h)
	p.coat = make([]float64, w*h)
	p.dirt = make([]float64, w*h)
	p.droplets = make([]Droplet, n)

	for i := range p.droplets {
		p.droplets[i].init()
	}

	for i := range p.dirt {
		p.dirt[i] = perlin.Noise2D(float64(i%w)/10, float64(i/w)/10, 1, 2, 2, 3)*0.7 + 1
	}
	return p
}
示例#13
0
func (self *World) Precipitation(x uint16, z uint16) float64 {
	return perlin.Noise2D(float64(x-MAP_DIAM)/(NOISE_SCALE), float64(z-MAP_DIAM)/(NOISE_SCALE), self.seed, 2.0, 0.6, 1)
}