示例#1
0
文件: main.go 项目: kirbywarp/rogue
func NewStoneFieldGenerator(db *engine.EntityDB, fill float64) *StoneFieldGenerator {
	grass := db.New()
	db.Set(grass, "art", base.NewArt('.', 0, 1, 0, 0, 0, 0))
	stone := db.New()
	db.Set(stone, "art", base.NewArt('#', .7, .7, .7, 0, 0, 0))
	return &StoneFieldGenerator{stone: stone, grass: grass, fill: fill}
}
示例#2
0
文件: main.go 项目: kirbywarp/rogue
func NewGameState(numbats int64) *GameState {
	// Game Data Initialization
	db := engine.NewEntityDB()
	base.RegisterTypes(db)

	tilemap := CreateMap(db)

	player := db.New("movement")
	db.Set(player, "ai", base.NewAI(NewPlayerAI()))
	db.Set(player, "art", base.NewArt('@', 1, 0, 0, 0, 0, 0))
	base.HelperPlace(db, player, tilemap, 0, 0, 1)

	bat := db.New("movement")
	db.Set(bat, "ai", base.NewAI(NewFollowAI(player)))
	db.Set(bat, "art", base.NewArt('b', 0, 0, 1, 0, 0, 0))

	// Create bats from the template entity
	for i := int64(0); i < numbats; i++ {
		newBat := db.Instance(bat)
		base.HelperPlace(db, newBat, tilemap, rand.Int63n(numbats)-numbats/2, rand.Int63n(numbats)-numbats/2, 2)
	}

	return &GameState{DB: db}
}