Chapter 9. Wooden Labyrinth 3D

Developer Name: Elias Pietilä

Development Company: Elias Pietilä

Tags: Workflow; Fun; Outdoing Copycats

URL: http://qvik.fi/

Elias Pietilä is not a developer. He's not a businessman, either, or even much of a video gamer. To hear him tell it, he's just a student living in the ghetto. "Okay, maybe not the ghetto," he says, "but definitely a low quality area near Helsinki."

Pietilä's labyrinth shifts perspective as it receives input from the iPhone's accelerometer, creating its three-dimensional effect.

Figure 9.1. Pietilä's labyrinth shifts perspective as it receives input from the iPhone's accelerometer, creating its three-dimensional effect.

What Pietilä is, however, is a mathematically talented Mac devotee whose iPhone game, Wooden Labyrinth 3D, has been downloaded almost two million times from the iTunes Store. A slick, addictive incarnation of an ages-old wooden maze game, the paid version of Wooden Labyrinth 3D, seen above in Figure 9-1, had netted him $68,000 USD by the time he earned the 2009 Apple Design Award for best student iPhone application—a period of just four months.

It wasn't supposed to be this way. Before he developed Wooden Labyrinth 3D, Pietilä didn't have an incipient career in programming for the Mac. He wasn't even studying computer science; his concentration at the Helsinki University of Technology is telecommunications science. In fact, when he began writing iPhone games, he wasn't actually in school at all. He was on a year-long hiatus from his Master's program, helping build prototype applications for—of all things—Nokia phones. (Figure 9-2, Nokia's headquarters in Espoo, dubbed Nokia House.)

It's tempting to think of the "student" category of the Apple Design Awards as a minor-league accolade. But the rapid evolution of Pietilä's successes is in many ways more telling of the nature of the iPhone platform than the careers of many of his fellow winners. His ideas for apps were borne of curiosity, not profit; his build was the result of trial-and-error hacking, not daylighting; and his initiative came from nothing more than his 16-year passion for the Macintosh. Accidental successes like WL3D are the only evidence needed to show that the App Store is perhaps the best forum to make a living in today.

Nokia's cultural and economic shadows loom over Finnish smartphone developers.

Figure 9.2. Nokia's cultural and economic shadows loom over Finnish smartphone developers.

The Dropout

When Pietilä initially took his leave of study from University, it was to pursue a full-time job at Finnish software firm Digia, which programmed for Nokia's S60 platform. He had begun work at Digia as a summer intern prototyping in Flash and ActionScript, and when the school year ramped up, they asked him to stay on as full-time employee. He took leave from school and did.

To work in the technology industry in Finland is to be in the shadow of Nokia. The Finnish culture of technological education that has evolved with Nokia—or perhaps, cultivated it—has made Finland one of the most technologically-oriented countries in Europe. Nearly a third of the country's college graduates enter employment in the sciences, many from the country's premier technical university, Helsinki University of Technology. The university, which is abbreviated "TKK," offers 19 degree programs, nearly all of which lead to a six-year Master's level diplomi-insinööri,or "engineer with university dimploma." Elias Pietilä was getting ready for his fourth year of study at TKK towards just such a degree when he accepted the offer from Digia.

Applying for that job, Pietilä had written on his resume that he was could code in Objective-C. "That was a bit of a lie," he admits. "I got some book on it—it was my brother's—and I think I finished the first two tutorials."

In the fall of 2008, after a year working doing Flash for Digia's Nokia projects, Pietilä quit and prepared to take yet another leave of study; he was going to catch up on school work and return to TKK in the spring. The the iPhone SDK came out, and he didn't even bother registering for classes. "Isn't it true that all the computer geniuses drop out?" he laughs.

At the time, the iPhone wasn't even available in Finland—Pietilä was still using his company cell phone, a Nokia E70. When the Apple device went on sale at the end of the summer, Pietilä got one immediately and downloaded the developer kit. "I had never really programmed anything in any C language," he says.

What he did have was experience with Open GL from an introductory C++ class. Open GL ES would later become the lynchpin of Wooden Labyrinth 3D's success, which Pietilä attributes almost entirely to its intuitive 3D look and feel. "Everyone knows the original game labyrinth," he says of the real-life wooden analog. "It's been beaten to death," he adds. Indeed, there was already a labyrinth game in the App Store by July of 2008. But it was the lush 3D play-scape that Pietilä believes drew customers to his game, vaulting it past his competitor's when it appeared in February 2009. Like its real-life wooden counterpart, Wooden Labyrinth 3D consists of an articulated, walled maze and a steel marble. The object: tilt the playing field to guide the marble to toward the end of the maze, avoiding holes interspersed through the maze as traps. In the game, the iPhone's accelerometer takes the place of the wooden knobs that manipulate the box in the real-life version, allowing a user to intuitively roll the ball around the maze by tilting the phone. As the levels get harder, there are more hole traps, requiring more abrupt stops and starts, and more manual dexterity. Increase the level of difficulty, and the ball slides along the playing surface more readily, as if it were greased with graphite. The responsiveness is incredible at all difficulty levels, and the game is instantly addictive—if ultimately maddening at high levels. Wooden Labyrinth 3D wasn't Pietilä's first iPhone app, but he was hardly a veteran when it soared to the #1 spot in the Finnish App Store. His first iPhone app was a game called Pajatzo, seen below in Figure 9-3, an iPhone incarnation of a popular Finnish gambling game found in gas stations and shopping malls—a kind of Scandinavian equivalent of pinball played with gold coins. It sold brilliantly in Finland—though nowhere else—topping the app list in the Finnish iTunes Store and getting Pietilä some media attention. Pietilä was taken aback. "Pajatzo fits very well on the iPhone's screen, and has a 'wow' effect," he says, "but it's not the best game. Yet people's immediate response was: it's cool because it assimilates the real life thing onto a computer," he says. The phenomenon stuck with him.

It was around that time that Pietilä saw a YouTube video, shown in Figure 9-4, demonstrating a brilliant hack for the Nintendo Wii. In it, Johnny Chung Lee of Carnegie Mellon's Human-Computer Interaction Institute discusses how to improvise something he calls a "head-tracking virtual reality display," using a Wiimote and a pair of LED-equipped glasses. Head-tracking, Lee explains, makes 3D games more real by allowing the computer to know the location of your head—and therefore, your viewing angle—relative to the screen. Tracking your viewing angle allows the computer to manipulate a virtual world with the proper motion parallax, making the screen appear uncannily three-dimensional, as though you were looking through a door or window, and not at a flat surface.

Pietilä's first game, Pajatzo, showed him that real-life games could succeed on the iPhone—if they were made realistically.

Figure 9.3. Pietilä's first game, Pajatzo, showed him that real-life games could succeed on the iPhone—if they were made realistically.

The Challenge

Pietilä set out to build a simulator that took advantage of head tracking on the iPhone. "I thought, okay, let's try to calculate the direction you're looking from based on the phone's tilt," he says. By programming for the accelerometer, he found he was able to give the phone enough data about viewing angle to allow it to construct a convincing 3D model. "I didn't plan on making the labyrinth game, I just planned on making demo of that effect," he says.

It was only once he saw the two-dimensional Labyrinth game by Codify AB in the App Store that he realized the proper home for his creation. "It struck me as odd that they didn't make the three-walled walls," he says.

Johnny Chung Lee's head-tracking virtual reality display, as seen on YouTube, prompted Pietilä to imitate head-tracking on the iPhone.

Figure 9.4. Johnny Chung Lee's head-tracking virtual reality display, as seen on YouTube, prompted Pietilä to imitate head-tracking on the iPhone.

Pietilä realized that he could trump the original Labyrinth, pictured in Figure 9-5, if he could give it the Pajatzo treatment: graft the real-life game into a slick, attractive package. "Even by autumn last year, it was obvious that there were some developers making money, but it was kinda quiet," he observed. "I thought [Codify AB's] Labryinth hadn't really gotten the love it deserved—their other games seem to have a lot higher production values." He set to work on a new labyrinth game with view-tracking 3D. "I knew that with a little bit of polish, it could really stand out."

Pietilä went to work with the kind of low-overhead essentials that have come to define the grassroots iPhone dev environment. "I only used my home computer, my Mac Pro," he says, "the first model they came out with." Besides Apple's tools—Xcode, Interface Builder, Instruments and the like—Pietilä's only other standby was Adobe Photoshop. He used Box2D's premade physics engine, applying textures to the head-tracking model he had made earlier.

His incremental approach to Wooden Labyrinth 3D allowed the flippancy of what he was doing—making a copycat app—to escape him. At least at first. "I became a bit worried, because it was a copy," he says. "But I just sort of went ahead and did it."

The whole app, he estimates, took him between 100 and 120 hours of coding and testing, parceled into early morning bursts of discipline. "Most of the developing time on both games was after midnight," he says. "I would be at home, doing other stuff, thinking, 'oh, I should code today, I should develop.' After midnight I'd think: now I have to do it." He'd code from 12am to 5am, he says, and sleep till noon, noting that he believes Finland to be the highest consumer of coffee per capita in the world. (He is right: each Fin consumes an average of 11.4 dry kilograms of the stimulant annually.)

"Now we get to the fun part, where I tell you that I can't actually code or program; I'm more of a hacker," Pietilä says. In a weird testament to the robustness of the iPhone platform, he says he's certain that both his games are leaking memory constantly. "I used to test for leaks when I was making Pajatzo, but then my version of Instruments stopped working," he says, prompting him to quit. Still he says, neither of his apps so far have suffered problems with crashing because of his loose programming style.

"I'm a normal person—I hate memory management," he explains. "You have to be a freak to enjoy that." His humility belies his obvious competency, but he insists that Apple's platform operates as a kind of mistake-eraser. "Compared to other smartphone platforms, iPhone is more of a desktop," he says, "so you get more leeway with things like memory. Usually you have to be careful about that, and it takes being a mathematical wizard. On the iPhone, you can be a normal person and still code." Comparing it to his first area of mastery, he says, "It's a lot like Flash—we've seen a huge explosion in Flash because you have a lot of ready-made action points. You just draw a shape and tell it to move from here to here." Coding for the iPhone isn't quite that easy, he admits, "but you don't have to be a demi-god to understand it."

Codify AB's Labyrinth game, which Pietilä set out to beat with his 3-D view.

Figure 9.5. Codify AB's Labyrinth game, which Pietilä set out to beat with his 3-D view.

Building the Labyrinth

Building Wooden Labyrinth 3D, Pietilä found himself investing just as much time mucking around inside his app as he did writing. "I know a lot of people who can code and compile in 2 hours. I code for two minutes, and I run it and feel around," he says. Due mostly to his impatience, testing was at least 60 hours of his development time, or about half of the total development time, he admits. "I couldn't code for a day and then see what happens," he says. His workflow went in cycles: code, load, space out, and test. "It takes like 30 seconds to build and install the app on iPhone," he explains. "What happens in that 30 seconds: I open my Web browser and then 30 seconds becomes 30 minutes." Reflecting on his workflow, he says sheepishly: "When you're not working for someone, it's hard to keep up your discipline."

Making the process more halting was the fact that his relationship with the game, he says, was a love-hate affair. "The pain of development truly started when I started to make use of the accelerometer data," he says, describing hours devoted to getting the settings dialed for each level of difficulty. "If you want to make the game experience good, you have to run it over and over again to get the feel right, resetting the parameters." The rest of the actual coding process, he says, is relatively benign, if not outright simple. "People think that because you're programming for multitouch that it must be hard. But those effects—they're only a couple of lines of code. You just look it up, and in five minutes you're making yourfirst app."

The "Magic" Piece

All of Wooden Labyrinth 3D is only 5–10,000 lines of code, Pietilä says, and the secret sauce is the 3D perspective effect that he originally designed as a prototype. "[This] piece of code is called every frame to allow the view to distort based on the accelerometer," Pietilä says. What you see below is the code that Pietilä wrote to gather data from the accelerometer and convert it into coordinates for Wooden Labyrinth 3D's virtual camera.

-(void) megaPerspective:(double) fovy aspectRat:(double) aspect nearZ:(double) zNear farZ:(double) zFar lateralDist:(double)lateralDistance bilateralDist:(double)bilateralDistance
{
                  float b;
                  float fov;
                  float STEREO_FOCAL_LENGTH = 300.0f;
                  float STEREO_CAMERA_SEPARATION =lateralDistance;

                  /* DO FORMULA CALCULATIONS */
                  glMatrixMode(GL_PROJECTION);
                  glLoadIdentity();
                  fov = fovy / 180.0f * M_PI; // convert FOV to radians

                  up = zNear * tan(fov * .5f);
                  b = zFar / STEREO_FOCAL_LENGTH;

                  left = - aspect * up + (STEREO_CAMERA_SEPARATION * .5f) * b;
                  right =  aspect * up + (STEREO_CAMERA_SEPARATION * .5f) * b;
                  down = - up;
                  up += (bilateralDistance* .5f) * b;
                  down += (bilateralDistance* .5f) * b;

                  /* SET THE PROJECTION MATRIX FRUSTUM */
                  glFrustumf(up, down, right, left, zNear, zFar);
}

WL3D's three-dimensional camera makes the game fun to look at, but ultimately any game's playability is determined by the levels of play. Wooden Labyrinth 3D presents players with a nearly limitless array, thanks to an auto-generating level editor. Here, Pietilä explains the algorithm behind his app's other magic piece, the generation engine:

"We start of by dividing the area into a grid of squares—6 × 4 [pixels]—and put walls between these boxes. We then begin at a random square and start "digging" a route in a random direction, removing the wall between those two squares. Then we replace the removed wall with either nothing, a half-wall or a hole. We proceed in random directions until we have visited every square on the board. It's of course rather apparent that we sometimes hit dead-ends. If this happens, we just begin the lottery anew," he says. It takes around 20 to 100 tries for the algorithm to complete a labyrinth where every square is visited. If a random direction yields a visited square or a wall, it attempts to decrement in the other direction before giving up.

"The difficulty is actually the probability of replacing the removed wall with a hole," he says. Since more holes means a harder game, that probability determines the difficulty of the level.

"It's all pretty simple, but the end result is deceptively good-looking and fun to play," he says.

Into the Fray

As of this writing, nearly half the iPhone OS audience lives outside the United States. As an international developer, Pietilä made two smart moves: he sought help in the U.S., which would ultimately help his game's popularity there, but made sure to keep the game appealing primarily to his domestic audience.

When it came time to beta test, Pietilä enlisted the help of an unlikely ally: a 17-year-old kid named Stephen Huber. Pietilä had befriended Huber after the American had posted the first English review of Pajatzo in the iTunes Store, something that Pietilä never thought he'd see because of Pajatzo's dearth of sales in the U.S. Precocious and eager to help, Huber was repaid when Pietilä asked him to help beta test Wooden Labyrinth before its release. Huber went above and beyond the call, uploading video reviews (in English) to YouTube that sparked tons of attention for Wooden Labyrinth when it finally hit the App Store.

When the paid version of the app debuted on February 5, it was priced at $2.99, where it would stay for two months until the Pietilä added the level editor to the package; that boosted the price to $3.99. "Right after I launched my version, they dropped their price from seven dollars to three dollars," he says of Codify AB's app, Labyrinth. Static between the two competing camps developed immediately. "Someone on the forums at TouchArcade[.com] asked them if they dropped their price because they were scared of Wooden Labyrinth 3D," he says. Writing on TouchArcade, developers from Codify AB accused him of copying their game, and not competing on his own merits. "We had words," Pietilä says tersely.

Once Wooden Labyrinth 3D started selling big, Pietilä added AppViz to his suite of tools, to manage his sales statistics. "Apple only provides you with these stupid text files, and you have to import them to Excel, assuming you own Excel, which I don't," he says. AppViz, which is made by developer Ideastorm, works by downloading sales data from every country's constituent App Store for you, then automatically drawing the graphs and pie charts.

The story that AppViz's graphs told Pietilä was a good one. By the time he won his ADA award, the lite version of his star game was still pulling 12,000 downloads a month. The paid version had sold over 35,000 copies at $2.99 or $3.99 a pop.

Even before he won an ADA, Pietilä was enamored of the iPhone SDK. "I'm a true believer, and I don't see anything wrong with it. I think it's pretty goddamn awesome," he says, speaking with particular affection for Xcode. "The package is so well done: you edit the code and press command-enter, and it starts the app directly on the iPhone, checking the values of every field during runtime. It's obviously like that on a desktop, but being able to do that on a mobile is pretty unique," he says, "especially compared to anything that was available on the S60 platform. "After my experience developing for S60, I would never want to do that. Expensive tools, bad channels for selling apps; it just doesn't suit the independent developer."

Pietilä has used his newfound reputation as an iPhone game-maker to work on a new venture he's calling Qvik (pronounced "quick.") The company, which he founded with two classmates, Lari Tuominen and Tuukka Puumala, back when he was an iPhone noob, will provide iPhone consulting and contracting, building custom iPhone apps for businesses.

Pietilä is hoping Qvik will piggyback on Wooden Labyrinth 3D's positive press, but says that he's been careful not to subsume his game under the company brand. Unlike in the U.S., where a unified company facade implies professionalism, Pietilä hypothesizes that Fins prefer to see his surname stay on the games he builds. "There are lots of other Finnish developers that use company names," he says. "But when I made Wooden Labyrinth, I was pretty sure that if I had my name on it, it would attract more media attention." Finland's population is about a quarter the size of the New York metropolitan area at 5.3 million, and its land area is roughly the same size as New Mexico—familiar quarters with a pretty homogeneous population. "It doesn't help if you have crazy-ass software in Finland," Pietilä says. "But if you have a good name, people think it's cute." Having his name on his app, he argues, is part of what helped his games gain national media attention over faceless dev shops like Codify AB.

Pietilä says that European customers will also respond differently to the concept of buying things within an app than have Americans. "In-app purchasing is the lamest thing," he says. "It gives the customer a fake price for the app." Pietilä says that because customers can't adequately judge exactly which features the initial cost of an app actually buys them, they could become disenfranchised. The hidden price of in-app buying will also make comparison shopping for apps harder, he says, which could conceivably drive down prices as unscrupulous publishers figure out ways to hide the true cost of their apps. While some of his American counterparts seem to look forward to in-app buying as a way to monetize new features—features they might have otherwise given away for free with updates—Pietilä maintains that Europeans might find it disingenuous. "Such practices are frowned upon by European trade laws," Pietilä admonishes. Maybe so, but not all developers can afford to forgo monetization options. That's one of the most fascinating things about Pietilä's game; because of its popularity, he can afford to choose a high road and he can stick to it. That's not an assumption that most student developers have the privilege to work under, and it shows that the market for iPhone apps is much more vulnerable to disruptors than is the market for traditional software. Freedom isn't necessarily won by the most elegant UI or the most parsimonious code; it's sometimes simply visceral appeal that can earn developers a following.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.26.138