Ejemplo n.º 1
0
// 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
}
Ejemplo n.º 2
0
func AreaPrim(width, height int) area.Area {
	raw := []string{
		`######################################################`,
		`#....................................................#`,
		`#....................................................#`,
		`#....................................................#`,
		`#....................................................#`,
		`#....................................................#`,
		`#....................................................#`,
		`#....................................................#`,
		`#....................................................#`,
		`#....................................................#`,
		`#....................................................#`,
		`#....................................................#`,
		`#....................................................#`,
		`#.......................#######......................#`,
		`#.......................#.....#......................#`,
		`#.......................#....&#......................#`,
		`#.......................#.&.~.####...................#`,
		`#.......................#.~~~~#).#...................#`,
		`#.......................#~~~~~##+#...................#`,
		`#.......................##&..&#......................#`,
		`#...........................&.#......................#`,
		`#....................................................#`,
		`#....................................................#`,
		`#....................................................#`,
		`#....................................................#`,
		`#....................................................#`,
		`#....................................................#`,
		`#....................................................#`,
		`#....................................................#`,
		`#....................................................#`,
		`######################################################`,
	}

	a := area.New(len(raw[0]), len(raw))
	for y, row := range raw {
		for x, cell := range row {
			if cell == ')' {
				c := coord.Coord{X: x, Y: y}
				if stk, ok := a.Items[c]; ok {
					stk.Push(item.Items["Iron Sword"])
				} else {
					a.Items[c] = new(area.Stack)
					a.Items[c].Push(item.Items["Iron Sword"])
				}
			}
			if cell == '+' {
				a.Objects[coord.Coord{X: x, Y: y}] = object.Objects["door (closed)"].New()
			}
			a.Terrain[x][y] = translate(cell)
		}
	}
	return *a
}