Friday, September 11, 2009

On ur iPhone! Stealin' ur CPU cyclez!

Last night, I finally managed to build and run my engineering test app for my game engine on my iPhone. Since OS 3.0 have come out, what use to be a tricky and error prone process (I'm talking about provisioning and code signing) have been improved vastly (BTW, thanks Apple!). If you have been in the iPhone development business for more than 6 months, you know what I'm talking about.

In fact, since it had been a while since I had to create an app-id or a provision profile, I was pleased to see that Apple had added an assistant to complete such basic (and yet daunting) tasks! And what do you know, it did more or less work as expected! I said more or less 'cause I got a little confused when creating the app-id, and instead of ending with the id been com.cocoageek.test, I just ended up with the id test. Here, I'd like to blame the assistant for this, simply because it fail to giving some example of what each fields expect. Make you think that it will be nice to be able to delete app-id ...

Anyway, the test app is running well. The frame rate (with collision between objects happening) seems smooth (I haven't measured it) so far. I'm a bit disappointed, however, by the anti-aliasing which doesn't seems to be as nice on the device as it is on my laptop (within the emulator). I guess I'll have to dig this a bit more.

Tuesday, September 8, 2009

I can haz physicz?

Since these days I am mainly a full-time dad when I get home from the day job, I was somewhat surprised when I completed the integration of Chipmunk physics to my game engine over the long weekend (Labor day FTW!). Needless to said, it is pretty exciting when things are starting to come together after weeks of intense preparations :-)

Like I was saying in my previous post, there's various API to chose from when looking to add real world (2D) physics to your game. I picked Chipmunk mainly because it's in C and relatively simple. My main grip with it, is the lack of a complete, and correct, documentation. I found myself having to dive in its source code to understand or clarify some things, and while it's great to be able to do so, I shouldn't have to. A 3rd party API should be well documented, including comments in the header files! Here's a (lame) example: once you have created a body (cpBody) the API provide a set of functions which allow you to physically manipulate it, such as applying a force on it. The thing is, the wording of the purpose on the function cpBodyApplyForce is a little ambiguous: "Apply (accumulate) the force f on body at a relative offset r from the center of gravity. Both r and f are in world coordinates." ... Is the force applied for a single simulation step or permanently? It turns out that it will be applied at each steps, until all forces on the body are reset (using cpBodyResetForces) ... Maybe it's just me? The mention to "accumulate" should have been enough? Also, the r and f cited are most definitely NOT in world coordinate, but in offset from the body's center of gravity ...

Anyhow, overall Chipmunk physics is a big win, I could have grabbed Physics for Game Developers at my local book store, but this is saving me time and headache so: Yeah! :-)

Now that two majors items on my engine's to-do list are done with (the first been the rendering), I'm moving on to handling user inputs, which by it-self isn't that hard, but I'd like to be able to detect the basic gestures that we, as iPhone users, are used to: flicking and pinching. I'm not sure if I need them for the first game I have planned, but ... since I'm doing a game framework, mind as well try to be as complete as possible! At least, I'll need to provision for gestures handling even if I leave the detection for a later version of the framework ... That's one of the malediction of being a framework kind of guy, most of your time is spend on the framework rather than the end result ...

Thursday, September 3, 2009

Ping!

Hello dear readers (yes, the two of you)! Well I'm still around and kicking as you may have seen if you follow me on Twitter. I'd like to said that I have been über busy with making cool iPhone apps, but it will not be exactly accurate. I'm working on a couple of apps, that is true, but the reason that I haven't posted since June as more to do with the lack of interesting things to said (can't always blame Twitter ...). I'll try to improve this over the coming weeks (year right ...) even though idiotic rambling on this blog have never stopped me before ;-)

So, let's talk a bit about one of the project I'm working on: an iPhone game. Yep that's right, a video game. Now, this is my first game (I'll skip the lame ones I wrote in BASIC back in the days or the ones for my pocket calculators) so this is a brand new experience for me and so far I'm loving it :-)

Since I suffer from the NIH syndrome, I'm building my own game framework to support the development of this game (and others to follow hopefully!), when I could have just use one of the existing framework, such as the widely popular Cocos2D. My needs are pretty simple really as I'm making a 2D retrogaming style game (using OpenGL). I could have save myself the trouble, but since I thrive for challenges and enjoy learning stuff, I though it'll be more fun that way. And it is! :P

Yeah now, I'm not totally insane, so I have integrated Chipmunk physics into the engine, instead of spending the next months banging my heads on complex math&physic problems. Here again, there is a lot of physics frameworks to choose from, like Box2D, but I wanted something simple and in C (so that it'll be easier to integrate with my Objective-C based engine).

Anyway, things are looking good at this point although I'm mostly working on the game engine, while the game concept is maturing in my head (with some great inputs from experienced game developer @madgarden). Unlike many other iPhone developers, like Owen Goss, I'm a little hesitant to reveal too much about the game itself, at least until it is well advanced. It's not that I'm working on a revolutionary game (far from it, really!), but the competition is fierce on the App Store! Since I have no idea how long it is going to take me to complete it, I rather not be beaten to the store if you see what I mean (even though there's already similar game in the store) ;-)