示例#1
0
文件: terrain.go 项目: karlek/reason
func translate(r rune) *terrain.Terrain {
	switch r {
	case '#':
		return terrain.New(terrain.Fauna["wall"])
	case '&':
		return terrain.New(terrain.Fauna["bush"])
	case '~':
		return terrain.New(terrain.Fauna["water"])
	case '.':
		return terrain.New(terrain.Fauna["soil"])
	default:
		return terrain.New(terrain.Fauna["soil"])
	}
}
示例#2
0
文件: terrain.go 项目: karlek/reason
// Area is a debug function to generate terrain.
func Area(width, height int) area.Area {

	// Placeholder for terrain generation.
	var ms = []terrain.Terrain{
		terrain.Fauna["soil"],
		terrain.Fauna["soil"],
		terrain.Fauna["soil"],
		terrain.Fauna["soil"],
		terrain.Fauna["soil"],
		terrain.Fauna["soil"],
		terrain.Fauna["soil"],
		terrain.Fauna["bush"],
		terrain.Fauna["wall"],
		terrain.Fauna["water"],
		terrain.Fauna["water"],
		terrain.Fauna["water"],
		terrain.Fauna["water"],
		terrain.Fauna["water"],
		terrain.Fauna["water"],
	}

	a := area.New(width, height)
	for x := 0; x < width; x++ {
		for y := 0; y < height; y++ {
			a.Terrain[x][y] = terrain.New(ms[util.RandInt(0, len(ms))])
		}
	}
	return *a
}