Tuesday, April 6, 2010

The Doodle Contest

Oh yeah. I know I mentioned this below, but in case you missed it, definitely check out the Doodle Contest. Just click on the image for more info:
As a bonus, here are a couple of pictures from the iPad launch crowds in front of the local Apple store this past Saturday. The first is just a mood shot. The second is my attempt at pretending to be sociable and hip as a local developer. Both of these masterpieces are courtesy of ReesPhoto.com.

(Here I'm the model, not the photographer - just to be clear)

iPad Impressions and Other Goodies

The weekend is over and I can start thinking more rationally about the iPad. Haha! Right... Anywho, here are some impressions.

It’s a sleek little device - thin, light, and just shiny enough to invite your fingers to rub it all over. However, the more I keep looking at it, the more it looks like an oversized iPhone. I have to laugh each time I see my iPod Touch right next to it. I can just imagine women pulling an iPad out of their purses to answer a telephone call or jocks with iPads strapped to their biceps as they jog on treadmills in the gym.

If you disregard the perf boost needed to deal with the quadruple-sized screen, the iPad doesn't seem to run that much faster than the iPhone. It doesn't run slower either, which is a good thing, but it's not the speedy bullet that Apple initially implied. If you use the same tricks you use on the iPhone, though, it runs just fast enough.

Initially, I was more than a little worried when I developed code against the iPad simulator. Using Cocos2D, whenever I plopped a large texture on the screen, say a background, the frame rate would immediately drop to 20-30 FPS, even with OpenGL blending completely disabled. If you write a game, you need at least one large background texture most of the time, so the potential frame rate limitation posed a serious problem. That said, I was very happy to find out that the actual iPad handles all OpenGL calls much more gracefully. Doodle Blast! ran on full 60 FPS with the screen mostly empty and barely dipped into the 40s with everything in motion. I must say that the game looks quite slick on the big screen, especially when the camera zooms in and out while everything is in motion. Best looking doodles five bucks can buy!
In the end, I don’t think the iPad will reach nearly the popularity levels of the iPhone (watch me be completely wrong!). It’s definitely a fun toy to play with, though.

So, what’s next? Not sure. Right now I’m taking a little bit of time to catch my breath. I can hardly believe that it has been only one month and two weeks since Doodle Blast! first hit the stores – now there is an update, and iPad version, a blog, a web site, two trailers, over 11,000 lines of code and a contest. Talk about busy!

On a different note, I was browsing through the Doodle Blast! code base and I ran into two Cocos2D utility classes that I keep using and re-using all over the place. So, I thought I would share them with you. The way I generally write code under pressure is to write and polish the code paths that I need, leaving all others to be flushed out when they are actually needed. What that means for you is that these snippets are not fully complete, but they work as a great starting point. Feel free to use them however you please. A mention of credit is always nice, but not required.

The first utility is an action, EyeBlink (EyeBlink.h, EyeBlink.m), that does just that – blinks "eyes" on sprites. Basically, it takes 1 or 2 sprite frames as input. You can either specify two frames – one with eyes open and one with eyes closed – or just a single frame of closed eyelids that will be superimposed over an image of your character. The action then switches between these frames (or hides them if only one frame is specified) with some randomness built in to simulate irregular eye blinks. Here is how you’d use it:

Option 1:
CCSpriteFrame* openFrame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"eyesOpen.png"];
CCSpriteFrame* closedFrame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"eyesClosed.png"];
CCSprite* myCharacter = [CCSprite spriteWithSpriteFrame:openFrame];
[myCharacter runAction:[EyeBlink actionWithOpenDuration:0.7 openVar:0.3 closedDuration:0.1 closedVar:0.05 openFrame:openFrame closedFrame:closedFrame repeatForever:true]];
[myLayer addChild:myCharacter];

In this case you create two frames and alternate between them. The duration of the open frame will last 0.7 +/- 0.3 seconds while the duration of the closed frame will last 0.1 +/- 0.05 seconds.

Option 2:
CCSpriteFrame* characterWithEyesOpenFrame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"myCharacter.png"];
CCSpriteFrame* closedEyeLidsFrame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"eyesClosed.png"];
CCSprite* myCharacter = [CCSprite spriteWithSpriteFrame: characterWithEyesOpenFrame];
CCSprite* eyeLids = [CCSprite spriteWithSpriteFrame:closedEyeLidsFrame];
[eyeLids runAction:[EyeBlink actionWithOpenDuration:0.7 openVar:0.3 closedDuration:0.1 closedVar:0.05 openFrame:nil closedFrame: closedEyeLidsFrame repeatForever:true]];
[myCharacter addChild:eyeLids];
[myLayer addChild:myCharacter];

The same frame duration parameters apply here as well, but instead of switching between two frames, the code shows and hides a single frame.

The second snippet is a Chipmunk / Cocos2D debug node (DebugDrawNode.h, DebugDrawNode.m) that automagically draws debug outlines of all collision shapes associated with a given cpSpace object. It’s a simple subclass of CCNode with a custom draw() method. To use it, instantiate it and add it to your layer at the proper Z-depth thusly:

cpSpace* space = … ;
[myLayer addChild:[DebugDrawNode nodeWithSpace:space] z:SOME_Z_VALUE];


Monday, April 5, 2010

Doodle Blast! Update Released

I guess Apple was busy with the avalanche of iPad apps for the past several days so it took a while longer, but Doodle Blast! update has finally hit the stores on Saturday. It took about three weeks to put together and now the code line count is up to over 11,000 from the original 7693. Phew!

By popular request, I've added a health bar and the ability to post your scores online later. I've also added a news ticker (which I'm about to test later today) and a mini-game - The Attack of Evil Vampire Bunnies . They were originally intended to be Easter bunnies, but I had to put the project on hold for about a week to port Doodle Blast! onto the iPad, so Evil Easter Bunnies became Evil Vampire Bunnies. Shhhhh!!! No one will ever know...

I was up all night last night trying to come up with a trailer and here is the result:

I should really try to find someone to do these for me. Not that I mind expressing my artistic side, but, let's face it, I'm probably a better coder than animator. Nonetheless, I hope you enjoy it and download the update if you haven't yet!

Saturday, April 3, 2010

Alive and Kicking!

Doodle Blast! HD has hit the streets today and so have I! I just came back from the Apple store in U Village in Seattle, where countless number of “early adopters” and geeks like myself spent the wee hours of the morning waiting for their shiny box. More on that tomorrow, because I'm exhausted after two weeks of very little sleep and the couch is calling my name. However, I was finally able to see Doodle Blast! HD on the device itself. All I can say is - smooth as butta'...

Thursday, April 1, 2010

Ready to Go

After some confusion and near heart-attacks yesterday when I thought that Doodle Blast! HD was rejected from the AppStore, I came to find the following message this morning:
Boys and girls, it's official! I, of course, have no clue _how_ the game runs on the iPad, but it seems that it least runs. I'm guessing that I'll be updating the iPad version sometime this weekend once I actually see it running on the device. Until then, I'm biting my nails in anticipation.

And check out the updated Game Collage web site. Brand new as of yesterday! Here is the welcoming image for you: