Category Archives: Activities & Adventures

The experience of writing a game

I am typing this post on my iPod touch, just to let everyone know incase I have spelling errors.

A person suggested the possibility of me writin about the process of developing a game app, or perhaps more about the experience of it than the details.
Well, it is a good idea!
One thing that comes to mind almost immediately is the time consuming tasks.
I find that graphic design takes a lot of time, but it is a very fun process.
Anoter thing that comes to mind is all the late nights up, awake, working on one of the many problems. Like tonight.

Good night!

Posted in Activities & Adventures, Technology, Thoughts | Tagged , , | Leave a comment

The organization of a game app

The central-most Objective-C class in this game I’m developing is called “HBDGame”. The main source file has gone beyond the previously-mentioned 6000 lines and is now over 7200 lines. It seems a lot (for my own records).

Now I want to make a quick post because I will forget if I don’t… and because I do not want to write about this in detail right now.

There is a difficulty in maintaining strong organization when I have over 40 classes and dozens or hundreds of images, giant world map files (around 10/25 made so far) with dozens of configured elements within each, and a handful of soundeffects.

So I have probably 100+ pages of hand-written notes and diagrams and pencil illustrations, plus all the source mockup files for the computer graphics, and e-documents typed to keep myself organized.

And it’s becoming very challenging. I make constant use of text-based two-way references. That’s one of the best helps for me to keep track of execution paths in the program. blah. Now this is really starting to sound technical.. hah.

The major point of this post is simply this: the source-code and information hierarchy model I’ve found myself using (and pretty comfortable with) is something like this:

  1. Main game class is HBDGame, and it is the ultimate boss, next to the app delegate itself.
  2. There is a layer of persistent data (game settings that are important to keep the same for every game-session, like music volume and choice of accelerometer control versus touch-screen control). This persistent data is saved and loaded by 3 different simple functions.  The HBDGame controls these, and every class that wants stuff saved goes through the boss class.
  3. Significant game components, including the GamePlayer, menu systems (main menu, pause menu, quick popup menus) and other significant game objects.
  4. Interaction layer which handles the inputs to affect the game.  Some of this goes through the boss, and the boss passes off the inputs to the proper recipient.  Other times it goes directly to the recipient (specifically in the case of menus).
  5. Finally, the graphics themselves.  The graphics are controlled almost all completely through the main game components.

Probably doesn’t qualify as a model-view-controller layout.  More like a Global support-storage-model-controller-view.  I think the model-view-controller is a great model for software, but it seems complex projects have blurry lines of communication between the three concepts.

Perhaps there is a better way to organize what I’m doing, but right now I’m still finishing up the core of the game.

I’ll try to write more about this, with concise details, later on.

Posted in Activities & Adventures, Technology, Thoughts | Tagged , , , , | Leave a comment

Game Optimization Adventures, part 1

Starting on Wednesday (today is Friday) I began the process of optimizing the iPhone game app.

Using Instruments, I could see a total Live Bytes value of around 40 MB for an average while the game was running.  Now, I’ve done a couple tasks and also introduced a PVR texture (not got it working yet).  Suddenly, the live bytes (after everything has loaded) has been reduced not to 20 or 30, but 4.  When the app is started, it loads up about 15-20 MB of memory, and then dumps it all except 4.  I’ll mention more about this later on.

Now, that’s a colossal drop in memory use.  From peaking at 40 to down to 15-20, and then now a mysterious (but very happy) drop after loading to around 4.

In the last 4 hours (and some hours yesterday) I’ve been making pages of notes on values and changes from different configurations of the app.  For the configurations, one thing I’ve done is I have built 4 separate Instruments save files using the Xcode Run>Run with Performance Tool>Object Allocations automated setup.  The four setups use these configurations: using JPG texture and stop recording when at peak live bytes, using JPG texture and stop recording after drop to 4 MB, using PVR texture and stop recording when at peak live bytes, using PVR and stop recording after drop to 4 MB.

These files have let me discover the strange, inexplicable fact of the moment (and which I have not built any conclusion about):  the memory being allocated internally by glTexImage2D for my JPG textures is being released.

One reason I dropped initially from 40 MB to a moderately lower amount is I removed an unused texture that was hogging 12 MB by itself, and wasn’t even being used.  My bad.  Actually it wasn’t my fault. haha- blame someone else.  It was from the 3rd texture channel in blender, and the game engine I use claims to only use two texture channels from Blender, because OpenGL ES only supports two texture channels.  Fine.  So that’s why the documentation for the game engine recommends using texture channels outside the first two.  That I did.  But apparently it exports the rest anyway despite them being beyond the first and second channels.  So I removed that texture (2048×2048 pixels x 3 bytes/pixel = 12 MB).  Also I have removed a handful of other textures that I used before and now I have reduced the peak load size from 40 to 15-20.  The 5 MB difference there is the size of the JPG vs the PVR.

So assuming I’m still using a JPG texture

The peak live bytes is 20.30 MB, and the drop-live bytes is 4.67 MB.  Watching the ObjectAlloc graph in the upper pane of Instruments, it will be at the peak for a second, and then it suddenly nose-dives to the low drop.

Now to examine the useJPG-peakLiveBytes instruments file: sort the Live Bytes column in Summary View from high-to-low, and a person can see what Malloc categories are taking up the most space.  And in my case, the biggest ones  are  Malloc 4.00 MB ( # Living = 2 ), Malloc 1.00 MB (# Living = 5 ).   Beyond that, there is Malloc 2.66 MB (this is not a texture, it is part of the Bullet physics engine so I ignore it), and Malloc 256.00 KB ( # living = 4 ) Add up only the 2×4 + 5×1 + 4×0.25 and there’s 14 MB out of 20 MB right there.  There are dozens or hundreds more memory allocations but they become very small and they are not the significance that these large image textures are.

Examining the useJPG-dropLiveBytes Instruments file in the same manner, the biggest live bytes categories are Malloc 2.66 MB (the previously-mentioned physics stuff) … and nothing of the Malloc 4.00 MB and Malloc 1.00 MB.  So I clicked the Category column header to sort by category, and scrolled down to Malloc 4.00 MB and see the # living = 0, and Malloc 1.00 MB # living = 0, and Malloc 256.00 KB # living = 0.

That was predictable.

But the chart still shows a peak and a nose-dive, and so I asked myself “why does this build up and then nose-dive, and when I started this on Wednesday, it was building up to 40 MB and just staying there?”

Now I know why the peak isn’t so high, but why does it fall?  Instruments to the rescue!

Using the dropLiveBytes file, still sorted by Category, I click the right-pointing arrow-in-circle beside Malloc 4.00 MB.  This shows two rows, and both the rows have a blank cell under the Live column.  If looking at this same Malloc 4.00 category selection in the peakLiveBytes file, the cells would have a little black dot.

Then I clicked on the Extended Detail View button and looked at each of the two rows… in each case the 4 MB were being realloc’ed within glTexImage2D.

Now this is where random clicking and exploring Instruments really helped me.  Clicking the right-pointing arrow-in-circle beside the Object Address values in a row will show the history for that Object Address.  The columns of interest in my case are Event Type, Timestamp, Size, Responsible Caller.  I sort the list of two rows by Timestamp, ascending.

The order of Event type, shows Malloc, and Free. Okay! So what else is in the second row along with Free?  well, obviously the same Address, that’s not important. the Size, shows – 4194304 (which is 4x1024x1024.. = 4.00 MB) and Responsible caller shows glDrawElements.

So I examined the other 4MB and the 1 MB alloc objects in the same manner as above, and discover that they were all being Free’ed in glDrawElements.

So a quick jump over to khronos.org’s glDrawElements page and search the page for “free” came up with no successful information.

And now I’m puzzled… why are these objects being realloc’ed in glTexImage2D, and then freed, but they weren’t being freed before?

I have no idea.  But I know I’ve got to get the PVR texture working, and it’s nice to know that the game should not get dumped by the iPhone OS anymore ( I hope ).

More adventures will follow.  Take care.

Posted in Activities & Adventures, Technology | Leave a comment

Late night development progress

Feb 17th, I have stayed awake almost all night. My iPhone app in development is coming along very well, in spite of the very painful lack of reference and learning materials for the main 3D engine.

There are many things to do yet, but today I have done more in a single day than I have any single day previously.

Posted in Activities & Adventures, Technology | Leave a comment

Today: learning and doing activities. Tomorrow: repeat.

Today has been a day of guitar-playing, reading, interpreting, typing, mouse-clicking, and dragging.

I built a 3D model of the Bahamas islands plus Turks & Caicos islands. I am using it as the sample of a 3D islands world in my iPhone game project. This is fun! Building in 3D is new to me, but things don’t go in one ear and out the other in this sort of subject. There are SO VERY MANY things to learn in Blender, because it’s not a user-friendly 3D modelling program. I didn’t know that when I started learning it, but now I do know it.

I got into using it from someone’s internet article of 3D and 2D graphic rendering engines for iPhone and iPod touch (and I suppose now, iPad). The person had SIO2 and Oolong as the top two ranked options, but in pros-and-cons, listed Blender as a con for SIO2.

But that’s probably because like me, that person had no experience with 3D art and modelling.  Anyway, I spent the latter half of January going through Blender 3D: Noob to Pro, and have progressed about 40-50% through it.  I should really finish, except SIO2 does not fully support everything, and I’m trying to catch up to the 40-50% full competency of SIO2  before going on with more complex Blender subjects (like animated armatures).

So anyway, going through the tutorials in the source code is what must be done, not reading step-by-step how-to documents.  This is a guerilla-style learning.  Gotta get my feet wet by jumping in 100% and swim with the sharks.  Not that anyone associated with SIO2 is a great white shark, more like very pleasant whale shark… that sounds really odd, but I’m tired now.

When complete, this project will be a lot of fun (I hope!).  A lot of ideas come to me when I’m in a lucid state, so immediately in the morning before I am out of bed and just sort of coming out of unconsiousness, I try to figure out what ideas are lurking.. at the edge of thought.  Collect them up!  They’re worth money in the right hands, my hands!

Posted in Activities & Adventures, Technology, Thoughts | Tagged , , , , , , , , , , , , | Leave a comment

Buying some stuff from Amazon

I’m buying the Lonely Planet Planet 2010 calendar and the first season of Criminal Minds for my sister. I typed in the location where she is so the company can ship direct to her, and I found this interesting feature: it spell checks the address. and makes recommendations, and gives a selection to pick your original or the corrected entry. In my case, the spelling of the location is determined to be bad, so it has a suggestion for me, but I believe the spelling I have is correct. But anyway….

That’s really handy! It could have helped the christmas card that some friends sent me early december that took a month and a half to arrive: each of the street name, town, and canadian postal code had spelling mistakes.

Posted in Activities & Adventures | Tagged , , , , , , , , , | Leave a comment

Music buying and organizing

Years ago, along with countless millions (and along with more millions right now) I got into downloading music for free over peer-to-peer (P2P) networks like Napster, Scour Exchange, Kazaa, Limewire, and a few others.

I’ve downloaded lots, but I’ve always had a philosophy that downloading stuff as a permanent alternative to buying is a stupid idea.  Buying music that I appreciate is a tremendous thing, like buying socks instead of ripping them off.

Many times before, the music downloaded would be good, and then I would go buy the album.  Problem is, I have downloaded way too much for me to buy in any single shopping spree.  But I’m moving away from downloading and never paying for things.  The biggest inspiration is the desire for people to pay me for my own services in my solo business ventures.  And so, all this music I like and have downloaded so easily, I’m buying.

Now, I have lots of music I’ve aquired through my multi-year paid subscription to eMusic.  Also, many, many CDs purchased and put on the computer (NOT SHARED) into a music library.  Plus my paid subscription to Audible gives me about 10 audio books. So all this combines into my great music collection, which, including the downloaded unpaid-for stuff, is just under 40 GB.  iTunes tells me that if I played every song through start to finish, it would take  almost 20 days, non-stop.  I think that’s not including the audio books, those would take probably another month.

So now, as I’m going to eventually delete all the free music as I replace it with paid music, I am going to start building colossal playlists.

My favourite styles of music are classical, flamenco, classical guitar, classic rock, instrumental.  And now, I am listening to Adagio.FM and recording all the music I like so I can buy it, including it into the start of my playlists.

Gymnopedie, Die Walkurie, William Tell, Peer Gynt suite No 1 Op. 46, the list goes on and on and on.

I’m also learning.  I’d like to learn to play the Concierto de Aranjuez on the classical guitar someday.

Posted in Activities & Adventures, Thoughts | 2 Comments

Reign Over Me movie review

The movie Reign Over Me is very good.

I borrowed the movie, and it is one to buy, just so you know.
It is deeply moving, similar to The Soloist, which I just saw not long ago… Both stories are about people who are going through the most extreme life experiences, and surviving (barely), and another person makes a fresh new option take form and beckons the tortured soul thither.

Must see it again.

Posted in Activities & Adventures | Tagged , , , | Leave a comment

Crazy day

This morning I woke up to the alarm duck quacking at 5:30 am. Having set the alarm a few hours earlier (2:30 am) I was tired and turned off the alarm. Fortunately I set two extra alarms: 6:00 am and 6:40 am. So I really woke up around 6, then was out of bed around 6:20, trying to become sane.

Prepared for the day, and embarked on a day that took me to a great musician jam, followed by a visit to Dad’s home and a visit to a new photography store in downtown Colborne. Finally, a visit to another friend’s home who I’m doing work for.

I arrived home around 6pm, and have been wanting to go to sleep since. Now, it’s 11:50pm and I’m typing the first entry on the new Edge of Thought blog. I have two domains that are joined: EdgeOfThought.com and TheEdgeOfThought.com so the branding with the word “The” is optional, but both work.

The music was great. Maybe in a week or two I will play Classical Gas in front of a bunch of people. Or maybe something else… must refer to the list of songs I typed on facebook, I cannot remember all the songs I’ve learned.

Posted in Activities & Adventures | Tagged , , , , , , , | 1 Comment