David McLain thought he knew something about ball games.

Like a lot of 46-year-old American men, McLain grew up playing some kind of game using a ball just about every day. But all those hours of playing three-on-three hoops in someone’s driveway did not prepare him for the apparent chaos and crushing humanity of a game he filmed a few years ago in the Scottish town of Kirkwall.

“They had about 400 men crowded into the center of town, then somebody threw the ball into the crowd and it just disappeared,” said McLain, sitting in his home office in North Yarmouth. “There are no rules, no uniforms. They just pass the ball to each other, hand it, any way they can. The only way to know who is on your team is to know what part of town he lives in. It can go on for hours.”

The game is known in the local dialect as ba’, or ball. McLain filmed the scene while making the documentary “Bounce: How the Ball Taught the World to Play.” He collaborated with director Jerome Thelia and writer and anthropologist John Fox to create a 76-minute exploration of play, how instinctive it is for all animals and humans, and what a crucial role it has had in the development of arts, culture, morals and entire societies.

The film began playing at film festivals this past spring. It will show for three days, Oct. 9-11, at the Portland Museum of Art.

McLain, who makes films and also works as a still photographer for publications like National Geographic, is a co-producer on the film. He will be at the museum showings, along with Thelia and Fox, to answer questions.

McLain filmed odd games that have survived for hundreds of years as a local tradition, like the one in Kirkwall. Locals say the game stems from the legend of a young villager who killed an evil king and brought his severed head home. But the old king’s tooth had cut the boy, who later died of an infection. The villagers were so mad they began kicking the king’s head all over town, or so the legend goes.

The film also shows games that have survived for thousands of years, like ulama in Mexico. In that game, players move a solid, nine-pound, rubber ball past their opponents by hitting it only with their hips.

McLain and other cinematographers on the film shot footage of animals playing with balls as if they were human, and they found remote villages where plastic and paper tied with string took the place of factory- produced soccer balls.

While working on the film, between 2012 and 2014, McLain traveled the globe to film interviews with experts in language or history talking about the unique role play has had in world development.

“Play is really central to being human,” said McLain. “It leads to creativity, it helps define competition and cooperation for us. But the point of playing, is to play. The other things come from it.”

The film is based on Fox’s book, “The Ball: Discovering the Object of the Game,” which came out in 2012. In graduate school, Fox spent time in Central America and became fascinated with ulama. Writing about that game and its ancient origins, he became interested in how we came to play games and how we came to play, at all.

While writing the book, Fox was approached by McLain and Thelia about making a film. The three have known each other since the late 1990s, when they worked together on an interactive web series for students, traveling the world to explore history and culture. Which is what they did for “Bounce.”

For McLain, the big questions about play are rooted in his own upbringing in the town of Fredonia, New York, south of Buffalo. His father taught sociology at State University of New York and his mother ran a campus daycare.

He remembers sports as more spontaneous than they are now. He played a sport nearly every day but rarely played on an organized team. He knows firsthand that unorganized play, even if it is playing a sport with defined rules, can help young people develop important skills, like conflict resolution, and prepares them for the realities of life.

“People get left off teams, feelings get hurt, but it’s where you learn to work things like that out,” McLain said.

McLain became fascinated with photography at a young age and was mentored as a high school student by a freelance news photographer who worked out of Buffalo. Before he went to college, McLain was shooting events for the Associated Press and other news organizations.

After graduating from Syracuse University and teaching English in Japan, he got a job at the Niagara Gazette newspaper. He later worked for the Connecticut Post, a daily newspaper in Bridgeport. Around the same time, he and his fiancée (now his wife) decided to move to Maine after spending vacation time here. They moved to Portland in the mid-1990s.

McLain began working for publications around the country, including National Geographic. He and his wife now have two teenage children who play organized team sports.

“David’s cinematography is just beautiful. He has the ability to bring to life the things I wrote about,” Fox said. “The movement of the ball just draws you in.”

One of the biggest differences between his book and the film is that the book has more history, in chronological order, of how play and games developed in various parts of the world. The film, Fox said, is more of a “meditation” on the subject, and the scenes of play have an “emotional power” all their own.

The film’s scenes are visual punctuations of the ideas and theories espoused in the film. Apes in Congo are shown playing with balls, throwing and catching as if they had been trained by a high school basketball coach. Untrained dolphins are shown dribbling soccer balls underwater, with their mouths.

“The idea of free play, the urge to play, is pre-human and pre-culture,” McLain said. “It doesn’t always make sense, because for animals, the urge to play presents a great risk. Seal pups who are playing get eaten by sharks.”

The film helps to explain what makes play different from other forms of physical activity in animals, and humans, said Thelia, the director. Playing involves unspoken rules, collaboration and even a moral code among the players.

“When you watch animals during rough-and-tumble play, there are strong rules of respect there. Without those elements, it’s just a fight,” said Thelia. “The rules involved in play, the respect, are probably the origins of morality and law.”