Exemplo n.º 1
0
func main() {
	// Parse the command line flags
	flag.Parse()

	// Seed the random number generator
	rand.Seed(*seed)

	// Create a new maze
	m := maze.New(*width, *height)

	// Print the maze
	fmt.Print(m)
}
Exemplo n.º 2
0
func (g *Game) newMaze() {
	g.Maze = maze.New(g.W, g.H)
	g.Image = image.NewRGBA(image.Rect(0, 0, g.W, g.H))
	g.Bounds = g.Image.Bounds()

	for x := 0; x < g.W; x++ {
		for y := 0; y < g.H; y++ {
			switch g.Maze[x][y] {
			case maze.Start:
				g.X = x
				g.Y = y
				g.Image.Set(x, y, Gray)
			case maze.Finish:
				g.Image.Set(x, y, Blue2)
			case maze.Wall:
				g.Image.Set(x, y, Blue6)
			case maze.Empty:
				g.Image.Set(x, y, Gray)
			}
		}
	}

	fmt.Println(g.Maze, "\nNew maze, current score:", g.Score)
}