Archive for February, 2009

Three Things

Friday, February 27th, 2009

My brother sent me this thing where you have to answer a bunch of questions with three responses each. So here goes:

Three Names I go by

  1. Tony
  2. Dexter
  3. Mach

Three Jobs I have had in my life

  1. Financial Analyst
  2. Computer Science Lecturer
  3. Visual Effects Artist

Three Places I have lived

  1. Chigasaki, Japan
  2. Vancouver, Canada
  3. Honolulu, America

Three TV Shows that I watch

  1. 30 Rock
  2. Samantha Who?
  3. Battlestar Galactica

Three places I have been

  1. Athens, Greece
  2. Mexico City, Mexico
  3. Moscow, Russia

People that e-mail me regularly

  1. Tracy
  2. Mom
  3. People who want new features for Mach Dice

Three of my favorite foods

  1. Tacos
  2. Curry
  3. Sushi

Things I am looking forward to

  1. Taking three months off from work
  2. Finishing my next iPhone app
  3. Discovering I have super powers

Spot the Difference, String Formatting

Wednesday, February 25th, 2009

Check out these two snippets of code and see if you can spot the difference:

NSString *homeDir = NSHomeDirectory();
NSString *dataDir = [NSString stringWithFormat:@”%s/Documents/Data”, homeDir];

NSString *homeDir = NSHomeDirectory();
NSString *dataDir = [NSString stringWithFormat:@”%@/Documents/Data”, homeDir];

The first one uses the “C”-style “%s” format field for the string, which is incompatible with the NSString type string. It will subsequently scatter your files in seemingly random directories filled with jibberish in their names causing you untold hours of grief as you try to find them in what you believe to be the correct locations. The second one uses the correct “%@” format field. The moral of the story is that C and Objective-C are different in subtle but painfully significant ways…

Sometimes I suspect that my life is actually a series of cautionary tales for others.

Happy Birthday Mom!

Monday, February 23rd, 2009

(Actually, Mom’s birthday was Saturday, but this is my first post since then. Since it was her birthday and I know she reads this, I’m dedicating this post to her.)

According to the Chinese astrological calendar (which the Japanese also use), my mom was born in the Year of the Monkey. As it happens, she’s just like a monkey in that she’s very inquisitive and smart. She went off to college in a completely new city away from her home town and then she traveled to America where she met and married my dad. These days, she’s still learning new things like how to drive and how to use the computer. She’s an inspiration to my brother and me to keep trying new things. (Like, creating apps for the iPhone!)

I drew the above card for her birthday. It’s supposed to be a bunch of snow monkeys relaxing around in a hot spring. For reference, I used some friends’ photographs taken in Nagoya, Japan where snow monkeys really do lounge around in natural hot springs. Man, that would be a sweet life.

Happy birthday, Mom!

Osaka

Friday, February 20th, 2009

As you might have guessed from my last name (Kobayashi), I’m Japanese. More specifically, I was born and raised in the US, but my ancestors were from Japan. Even more specifically, my mom’s from Osaka, Japan where I spent a few summers as a kid.

I used to wonder if it had much effect on me to have spent so much time in Osaka and then I see something like this:

and it makes me think: yeah, I think it did…

Laserdiscs, Part II

Wednesday, February 18th, 2009

One of the laserdiscs we got was American Boyfriends, which is about a group of Canadian girls and the “wild” adventures they have on a road trip to America. Yeah … it’s about as exciting as it sounds. Anyways, after watching it, I turn to Tracy and we have this conversation:

“We can put that on the pile of discs to sell.”

“But what if someone comes over some day, sees it and says, ‘ooh, American Boyfriends! I remember that movie from when I was a kid. Let’s watch that!’?”

“…”

“?”

“Few things in this life are certain. But one thing that I do know from the very depths of my soul is that that would never happen.”

Laserdiscs

Monday, February 16th, 2009

Hey! Remember Betamax? Neither do I. But I do remember Laserdiscs. A lot of people are getting rid of their laserdisc collections because DVDs and Bluray have rendered them obsolete. Also, everyone’s laserdisc players have broken down. But not ours! So we’ve been collecting free laserdiscs from various people who no longer want them.

We’ve ended up with some classics like Pink Floyd The Wall, My Favorite Year, and Midnight Cowboy but also some laserdiscs of … dubious quality like Roddy Piper in Marked Man and Leprechaun 2 (“This time, luck has nothing to do with it!”).

Oh yeah…

(In other news, iPhone app #2 is coming along. I’ve roughed out most of the basic functionality. Now I’ve got to implement file I/O so that the app remembers what you did between sessions.)

500 Million

Friday, February 13th, 2009

Apparently, there have been over 500 million app downloads and about 20,000 apps on the iTunes store. According to apptism.com, the breakdown is something like 4,832 free apps and 15,764 paid apps. But the real question is how many downloads does the average app get?

Well, let’s speculate that the average free app get downloaded 10 times as much as the average paid app. (Hey, at least it sounds plausible, right?) If that’s true, then with a little algebra (10 * x * 4,832 + x * 15,764 = 500,000,000), we can extrapolate about 7,800 downloads for the average paid app and 78,000 downloads for the average free app. Pretty cool…

I’ve written little programs and games on other platforms but it’s never been like this until now. And that’s the greatest thing about developing for the iPhone / iPod — it gives small developers and hobbyists like me a chance to reach a bigger audience than ever before.

glBlendFunc()

Wednesday, February 11th, 2009

If you’re doing 3D graphics on the iPhone, you’re mostly dealing with OpenGL. And if you’re doing OpenGL, you’re using glBlendFunc(GLenum source_factor, GLenum destination_factor) to indicate how polygons draw on top of each other. The way it works is it multiplies a source image (what you’re putting on top) by something, multiplies the destination image (the background) by something, and adds the two results together. The glBlendFunc() specifies what those two somethings are.

Here are a few examples from my own code:

The source image is just a circle that's half black and half white. The destination is a background image that comes with the iPhone simulator.

glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);testing

This is the standard operation, which is used 99% of the time. It specifies that you multiply the source image by one, which leaves is alone, and multiply the background by (1 - source_alpha), which cuts a hole for the source image to fit in. I've also seen examples which replace the first GL_ONE with GL_SRC_ALPHA but in my experience, images with transparency tend to be pre-multiplied so GL_ONE is more correct.

glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_ALPHA);erase

This is pretty much like the last example, except that we multiply the source image by zero so that all we're left with is a hole in the shape of the source image.

glBlendFunc(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA);darken

I've used this combination to blend or tint the background. For example, I used this on Mach Dice to burn shadows on backgrounds. It works by multiplying the source and destination images together and plopping it on top of the hole cut out of the background.

glBlendFunc(GL_DST_COLOR, GL_ONE);
lighten

This is pretty much just like the previous example except that a hole isn't cut out of the background. The result? The tinted image is added on top of the background making it lighter. I've used this to create highlights on backgrounds.

Elephant Seals

Monday, February 9th, 2009

I was going to do a post today about glBlendFunc and a few of the different ways you can use it to get different effects. But over the weekend, I got a chance to go on a trip to check out the elephant seals in Ano Nuevo State Park. So you’re going to hear about that first.

Elephant seals are big. I mean, really big. The biggest ones can get about 15 feet long and up to 5000 pounds heavy. To give you an idea of what that’s like, imagine three of me lined up on the floor. Now drop another 40 of me in a pile on top of that. And that’s about how big they can get.

They can also move surprisingly fast. The shuffle their bulk in a sort of … waddle-gallop? galumph? I’m not sure what you call it. But it’s pretty impressive. Check them out if you ever get the chance.

Humor

Friday, February 6th, 2009

Humor is a funny thing. (Har, har.) It’s very individual and yet universal at the same time. As a kid, I was fascinated but also confused by it. I remember obsessively reading each of the comics in the Sunday paper, trying to figure out what made them funny but mostly I’d ask my dad. My parents never really told jokes or anything like that but I do remember them laughing at things we did or said. They were both pretty literal as well, so for the longest time, I didn’t “get” sarcasm. Boy, that made for some awkward times in high school and college. (“Hey guys, that girl said I’m totally her type!”) Good times, good times…

Anyways, I started thinking about this whole thing recently because I just recently ran across a phrase that made me go, “Wow, yes, that phrase perfectly describes my concept of what I think is funny.” It’s actually a title of a book. I don’t know if it’s any good or even if it’s out yet. But as a phrase, it’s pure awesome. And that phrase is: “Pride and Prejudice and Zombies“. (The italics are mine because that’s the part that’s awesome but I have to admit, I do have a thing for Jane Austin novels.)