Exemple #1
0
// Objects is a debug function to generate objects.
func Objects(a *area.Area, num int) {
	o := make(map[coord.Coord]area.DrawPather, a.Width*a.Height)

	log.Println(len(object.Objects))
	var objectList = make([]object.Object, len(object.Objects))
	var index int
	for _, o := range object.Objects {
		objectList[index] = o
		index++
	}
	for x := 0; x < a.Width; x++ {
		for y := 0; y < a.Height; y++ {
			if num <= 0 {
				return
			}

			if util.RandInt(0, 50) != 42 {
				continue
			}

			if !a.IsXYPathable(x, y) {
				continue
			}

			c := coord.Coord{X: x, Y: y}
			o[c] = objectList[util.RandInt(0, len(objectList))].New()
		}
	}
	a.Objects = o
}
Exemple #2
0
// Mobs is a debug function to add mobs to the map.
func Mobs(a *area.Area, num int) {
	var mobList = []creature.Creature{
		// creature.Beastiary["echidna"],
		creature.Beastiary["gobbal"],
		creature.Beastiary["tofu"],
		creature.Beastiary["iop"],
		creature.Beastiary["arachnee"],
	}
	for x := 0; x < a.Width; x++ {
		for y := 0; y < a.Height; y++ {
			if num <= 0 {
				return
			}

			if util.RandInt(0, 50) != 42 {
				continue
			}

			if !a.IsXYPathable(x, y) {
				continue
			}

			g := mobList[util.RandInt(0, len(mobList))]
			g.Inventory = make(creature.Inventory)

			c := coord.Coord{X: x, Y: y}

			g.SetX(x)
			g.SetY(y)

			a.Monsters[c] = &g
			num--
		}
	}
}
Exemple #3
0
func glitch(amount int) {
	for y := 0; y < ui.Terminal.Height; y++ {
		for x := 0; x < ui.Terminal.Width; x++ {
			if util.RandInt(0, amount) != 1 {
				continue
			}
			c1 := util.RandInt(0, len(colors))
			c2 := util.RandInt(0, len(colors))
			a := util.RandInt(0, len(atts))
			termbox.SetCell(x, y, rune(util.RandInt(0, 255)), colors[c2]+atts[a], colors[c1]+atts[a])
		}
	}
	termbox.Flush()
}
Exemple #4
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
}
Exemple #5
0
// Items is a debug function to add mobs to the map.
func Items(a *area.Area, num int) {
	var itemList = make([]item.DrawItemer, len(item.Items))
	var index int
	for _, i := range item.Items {
		itemList[index] = i
		index++
	}
	for x := 0; x < a.Width; x++ {
		for y := 0; y < a.Height; y++ {
			if num <= 0 {
				return
			}

			if util.RandInt(0, 50) != 42 {
				continue
			}

			if !a.IsXYPathable(x, y) {
				continue
			}

			c := coord.Coord{x, y}
			i := item.New(itemList[util.RandInt(0, len(itemList))])
			if i == nil {
				continue
			}
			i.SetX(x)
			i.SetY(y)

			if a.Items[c] == nil {
				a.Items[c] = new(area.Stack)
			}
			a.Items[c].Push(i)
			num--
		}
	}
}