Apple Developer Connection
Advanced Search
Member Login Log In | Not a Member? Contact ADC

Building WingNuts in Xcode with OpenGL: Freeverse Creates a Great Mac-only Game

The 11-person team at Freeverse, Inc. might be small, but the company has scored big with the action arcade game Wingnuts 2: Raina’s Revenge, which won the 2006 Eddy Award for Best Game and was named runner-up for the 2006 Apple Design Awards for Best Mac Game.

Freeverse created a fun and addictive game, and according to the development team, the road to outstanding creative development was paved with Apple technologies such as Xcode, QuickTime, Core Image, the platform’s OpenGL implementation, and Mac OS X as a whole.



Lead designer Bruce Morrison explains that, for starters, QuickTime made the development team’s life easy.

Morrison says, “Because of its APIs, we can use it to read any graphic file format. I work in PNG, but we also sometimes deal with files in TARGA or JPG, or even Photoshop’s native PSD. But we really don’t have to waste our time worrying about formats because if QuickTime can read a file, we can use it right away.”

And Freeverse applied those graphics well. The first thing you notice when you launch Wingnuts 2 is its rich visual appeal, which Macworld called “beautiful to look at, and delightful to play.” Reflections, fog, warping, screen wipes, backgrounds, animated explosions, sprites—all seem to jump off the screen and draw the gamer into battle with Baron von Schtopwatch and the elusive Raina. Although primary credit goes to artist Steven Tzé and lead coder Mark Andersson, both also tip their hats to Mac OS X’s superb graphics handling, in particular OpenGL and Core Image.

“I was doing bitmapped graphics in UNIX and on an old Mac, probably a blue-and-white G3,” says Andersson. “Then somewhere along the way I discovered an OpenGL book and was just blown away. I used to spend a lot of effort on ‘blitting’—routines that copied graphics from the buffer to the screen. But when I implemented the same thing in OpenGL I found I could have hundreds of objects moving around at the same speed with gorgeous blending and rotation. Blitting was instantly extinct, and that whole programming paradigm shifted for me.”

Not that OpenGL didn’t have a learning curve. Andersson notes that he was writing extremely inefficient OpenGL code at first. But on the Mac it still ran really fast, and he got a lot of effects goodies—like rotation, transparency and scaling—for free.

Although he wouldn’t consider himself an OpenGL guru, Andersson was happy with the results he got from it using fairly simple coding.

“This is a bit embarrassing,” Andersson says, “but all the graphics in Wingnuts 2 are in ‘immediate mode,’ which is like the kindergarten way of doing OpenGL. So, unlike Quake (from id Software, Inc.), which has a high polygon count, Wingnuts 2’s figures are comparatively simple. We’re really using OpenGL as a 2D sprite engine—everything’s at Z=0. It’s another way of using OpenGL and a testament to OpenGL’s flexibility.”

Morrison is especially pleased with OpenGL’s implementation in Mac OS X. He says that working with OpenGL is fine on other platforms as well, but it’s “dirt-simple” on the Mac. Nonetheless, Morrison stresses the benefit of staying informed about living standards such as OpenGL.

Bruce says, “We keep on top of Apple developments. For example, we take advantage of multithreading in OpenGL in our Mac version of Heroes of Might and Magic V. That leverages the dual-core architecture in Macs that have it, giving us performance improvements that the user can see as better frame rates and shading effects. That’s a real boon, and at the time, you couldn’t get that in Windows, no matter how many CPUs you put in the box.”

Freeverse used another Apple graphics technology to enhance its puckish sense of humor. Using iSight or any other digital camera, successful players can put their pictures on the High Score board and then warp and morph them using effects built into Apple’s Core Image.

Essentially, Morrison explains, they got all the effects that Apple put into PhotoBooth for free.

It All Started With Mac OS X and Xcode

So it’s easy to see how Apple graphics technologies improved Wingnuts 2’s gameplay. But the behind-the-scenes story is just as compelling.

“The biggest Apple technology we had was Mac OS X itself,” explains Morrison. “The way that Mac OS X works facilitates development on every level. For example, Steve would iChat new graphics to me as soon as they were ready. We run a development server on an Xserve in our Manhattan home office. Mark, who lives in Texas, uses AppleShare to upload new builds, which I download the same way. The flow of Mac OS X is what allows us to work.”

Perhaps the biggest productivity boost came from using Apple’s IDE, Xcode. However, Wingnuts 2 didn’t start out in Xcode: Andersson initially used an old version of another IDE. He put off switching to Xcode for a while and, in fact, even stopped upgrading his usual IDE a few years ago, as it was doing everything he needed when he started writing Wingnuts 2 in 2001.

He explains, “But then we started doing the final layer of gameplay stuff, music and sound, and the game scenario. Bruce was central to that, and his involvement was one reason to move it to Xcode. What really pushed us over the edge was that we needed to make a universal binary. I always wanted to make the switch, anyway; I just hadn’t gotten around to it. And you know something? It wasn’t that bad. We ran into only one issue during the compile, and Apple’s developer support was able to help us through it. Then it didn’t take long at all. I especially like the fact that I can build several versions—one for retail, one for shareware, one for a specific game store—from one project. At this point there’s no way I’d go back to my old IDE.”

Morrison appreciated the speed and structure Xcode provides. If they were doing it again, he says, they would definitely start in Xcode because it gave them the organization they needed, and the first time they had to turn out a universal binary, Xcode “just did it.” In fact, Andersson once turned out a universal binary for another of the company’s products, Burning Monkey Casino, during a plane ride to Worldwide Developers Conference (WWDC).

Development From the Ground Up

Unlike the first Wingnuts title, which was released in 2001, Wingnuts 2 was built with extensibility in mind. Lead coder Andersson says he got inspired by an idea from the old book series, Game Programming Gems: Try not to hard-code anything, and make it all easily changeable, preferably in an external file, so you can edit it without having to recompile the entire program.

So first, he created the game engine and a level editor called Wingnuts and Bolts. (A military aircraft enthusiast, he also created the graphics of the aircraft carrier and the 100-plus historically accurate planes.) Then he handed the pieces to Morrison, who used the level editor to create the Raina’s Revenge scenario, which comprises more than 30 levels. Both Andersson and Morrison marveled at how quickly they were able to create the level editor using Apple’s Interface Builder.

“We’re big fans of Interface Builder for everything we do; it’s so easy to use,” says Morrison. “A lot of the level editor is pull-down menus and such, and Interface Builder made it easy to create, really just a point-and-click process. And with Interface Builder, Wingnuts and Bolts can take any QuickTime-compatible file format, with no additional coding.”

Andersson agrees. He says that Wingnuts and Bolts is really an internal development tool, but Interface Builder made it so easy to create that the final result was good enough to release to the public.

“But I unfortunately didn’t use Cocoa,” he laments. “I think I could have gotten even more out of Interface Builder if I had and probably saved hours of development time. Next time...!”

Mac First, Mac Only

Back in the front office, Tzé talks about how many of the tools Freeverse used for sound and graphics were only available on the Mac.

Steven says, “We had a screenplay, and we improvised a fair amount from that.  We used Comic Life which we publish (developed by plasq and currently Mac-only) for some of the cut scenes we had in the game, and also Still Life (also Mac-only) by Granted Software.  We also used Sound Studio which we also publish and was developed by Felt Tip (Mac-only) exclusively for the audio in the game.”

Freeverse is bullish on the Mac market, as well, and has been since its 1994 debut (Hearts Deluxe, featuring Apple’s Speech Recognition) won the company its first award. Of its 36 titles, 26 are Mac only, including games that employ iSight as an virtual game controller (Toysight) and a graphics program that lets you easily apply many of Core Image’s effects to your own images (Lineform).

The company is also dedicated to the platform’s audience in its marketing. Vice President Colin Lynch Smith tells of one profitable partnership with Apple:

“The original Wingnuts sold very well for a long time,” says Smith, “and when sales finally started slowing down a bit we did something really smart: In conjunction with Apple’s .Mac team, we offered the game as a free download to .Mac members. This was a huge win/win. It provided a great game for free to .Mac subscribers, and it increased our audience and name recognition dramatically, paving the way for the success of WingNuts 2.”
Morrison sums it up: “We realize that some people want our products on other platforms, but we’re Mac-first. That’s just how we operate. We think, ‘How can we make this the best for Mac?’”

For more information about WingNuts 2, see the Freeverse website.