Wednesday, June 30, 2010

Day Three: First obstacles run into, yet overcome

Well, today I set off at 9:01 a.m. with one goal: get the accelerometer working within the OpenGL ES framework given by xcode. Something I honestly thought 'How hard could this be?' I started off the day watching two segments from the lecture videos regarding 3D programming on the iPhone, with an in-depth look at the hardware being used on the device. It was all fairly interesting, but I'm not too sure a whole lot of it will concern me for my first game, as I my plan is for top-down 2D-style gameplay.

I started to look at a few sample code examples of implementations of the Accelerometer, specifically one that used openGL as well. To make a long story short, the sample code and the template are not on the same page. The iPhone uses a view manager, with different views building the program. In an openGL game, the openGL rendering surface is applied to one of these views and than sent to core animation to be prepared for display. The accelerometer is implemented through an Objective-C/XCode setup known as a 'delegate' which I'm not really all that familiar with yet. This delegate needs to be attached to a view. Now, in the sample code all the rendering was done within the view, so the accelerometer values were already in the correct class. However, in the template the view handling the rendering surface passes off rendering duties to one of two seperate classes, depending on whether the app is running OpenGL 1.1 or 2.0. This led me to attaching the delegate to the view, but not having the values in the right class. I ended up adding variables and setter methods in the rendering class for view controller to pass the accelerometer data to it. It's ugly, but all of the work I'm doing now is to familiarize me with the technologies and the development environment. When it comes time to structuring the actual game there will be classes and methods in place for stitching all these different parts of the engine together so hacks like I used today won't be necessary.

I wanted to get some more openGL work done today, but I pretty much ran out of time. As I said in an earlier post the method of using openGL on the iPhone is quite unlike that which I'm used to, so I have quite a bit to figure out. Tomorrow I would like to get some basic objects drawn to the screen, and tie the accelerometer data into those objects. I did some basic color changing in the built-in openGL example with the data as proof of concept today, but what I plan to use the accelerometer for requires a "balance board", where the accelerometer controls an aspect of the game. Once I have a stronger handle on the openGL objects and parsing the accelerometer data I don't think this will be a problem, but that is tomorrow's job.

Tuesday, June 29, 2010

Day Two: More fairly unintersting intro crap

So I've just about finished up day two here in my little office. Today I started messing around with Objective-C a bit more, just doing some basic terminal apps, class creation and linking, etc. As it is a superset of C, I know a bulk of the language already, it is just the object-oriented side that I need to become familiar with. It's similar to C++, and performs most of the same actions but goes about them in different ways. Also, it is dynamically typed which I'm hoping to figure out how to take better advantage of.

I got the sample code from the developer's center working as well. I hadn't installed the newest version of the SDK out of fear that it wouldn't be backwards compatible, but I'm still able to compile with my older device as a target, so all is well. The first sample program I've played with is an accelerometer graph as it's the first input mechanism I want integrate with openGL.

Lastly I watched a lecture on openGL. It went over the API's involved in running openGL ES on the iPhone and some tricks for a few performance gains. It also introduced a diagnostic tool on the Mac called 'Instruments' which allows for all sorts of data to be collected while running code on the iPhone (or the Mac itself).

Tomorrow I plan on tinkering with the openGL code a bit more. The method I used for graphics programming previously was quite inefficient, and completely unsupported in openGL ES. I suppose it's for the better, as now is the time I need to start going about my work with the focus of organization and performance, and programming at a professional level. Depending on how well that goes I'll start to tie the accelerometer into openGL, and go from there.

Recap of day one

Since I want to take my iPhone game development work as seriously as possible, I've decided I'm going to implement some checks and balances for myself, and part of this keeping track of the things I do each day. Even though this is day two of development, I didn't do this last night so I need to document what I did yesterday. Xcode 3.2.3 and the SDK 4 are downloading right now anyway, so I've got a moment.

I had previously setup Xcode and an older version of the SDK, so I had the ability to mess around with some code and all that before I started yesterday morning. The first thing I needed to do then was get my iPhone Developer's License which gets me into the Apple Dev Program. It's $99/year and gives me access to a boatload of Apple documentation, development conference lectures and labs, sample code, etc. It also is a requirement for getting the proper certificates to sign compiled code to execute on the iPhone. I don't really agree with having to pay to run code on a device, but that's the deal. Also, it allows me to upload final versions of apps to the App Store approval process where my work will be scrutinized, checked for bugs, and hopefully be put onto the App Store when all is said and done.

Once I had these resources, I dove in. I watched about two hours of conference lectures, 'Introduction to Mac and iPhone Development' and 'Introduction to Game Development for iPhone'. A lot of it was information available in the resource docs, but I tend to pick things up easier when they are spoken to me rather than reading it myself.

I also ordered two books, The iPhone Developer's Cookbook and iPhone Game Development, the first of which is praised as required reference for any iPhone developer, app or game, and the second one that seemed to have a good step by step flow for introducing me to a lot of the iPhone specific concepts used in game development.

Lastly, towards the end of the day I got all the certificates necessary setup for building the code for the device and had a colorful spinning cube displayed on my iPhone. All in all it was an extremely successful day and I'm looking forward to writing today's entry later this afternoon.