Saturday, February 28, 2009

Big vs Small

During day time, I work for a rather large company. When I'm done work and finally get home, I have a few hours of play with the family and then move on to work for myself. The difference between working for a Big Company and for yourself is extreme. The company I work for employs about 400 people or so. There's multitudes of games being developed in parallel for many markets, all with their different rules and regulations. We have game designers, artists, programmers, QA, integration engineers and delivery managers (this is equivalent of a producer). Add to that managers for each of those groups and probably managers to manage them and you got lots of people working on intertwined projects.

Then I come home, and I'm the manager, designer, programmer, QA and on some occasion, artists *shudder*. That last role is a bit scary...I have no artistic bones in my body except for a bit of photography.

I don't mind day time work; sometimes I can truly find a lot of fun in it. After I'm done filling all my TPS reports that is. I find the overhead of doing things when you are in big groups a bit frustrating. Things are normally very simple, but put a simple problem in a large group and all of a sudden, it becomes really complicated. Politics, egos they don't really play a big role when you are developing by yourself.

Deadlines are probably some of the most frustrating element to deal with. Everyone has deadline. They are part of the software industry, it doesn't matter if you are on the gaming side, or the application side. If you have a client, you will have a deadline. As frustrating as deadline can be, they are a necessary evil in the software cycle. I've read once that if you give two equally bright programmers the same task, give a 1 week deadline to the first and a 2 weeks deadline to the second and they will most likely take the exact amount given to them to finish the task. I believe it. I've seen people take 1 day to do an hour job. Mainly because a task is never schedule for less than a day on a schedule.

What I don't like from deadlines is that they are more often etched in stone by sales department or middle management than by those doing the work. So if the date can't move, that's ok right, we can always throw out some features? Nope, they are etched on the other side of that same stone. So what gives? Personal time and quality of work is normally what goes first.

In my own personal projects, I try as much as possible to impose deadlines on myself. If I do come close to a deadline that I know I can't meet, I might put a bit more of my personal time in the project (but hey, it's all personal time right?) but I will also cut features if I need. As you can read in my post for my first AppStore Application, I had a very real deadline and had a long enough feature list. When I started planning in January, I had a mini game planned for it, although I knew it would be almost impossible to finish on time (I was just too new to Iphone development). So I cut the mini game, I also cut on some needless features. All in all, I finished about half a week ahead of schedule but I rather have more time than not enough. I really didn't know if my app was going to make it through the appstore review in one piece and I'd rather have more time to fix and re-submit than not enough.

I just recently did an estimation on a project I might be moonlighting on(if we get the contract). I normally estimate tasks, not entire projects. I have to say, it's not easy and I don't particularly like it. I've given an estimate that I think will be as accurate as possible given the current knowledge I have of the project. I added time for defect cycles in there for good measures. We'll have to wait and see if the project is approved and what our deadlines will be. Regardless, I think it will be interesting to see how our team of two compares to a team of 20. I bet, that our schedule will hold up better, but it certainly doesn't mean that I can do a schedule to manage 20 people. I probably would fail, like everyone else I know.

Sunday, February 22, 2009

Using an off the shelf engine or build one yourself?

When doing games, this is a question that you will come across over and over again. I've went through the pains of writing a 3D engine and a physics engine a few years back. I never used it in any of my own games, but it was a blast to work through all the different problems, and there was many problems.

One of the biggest problems to coming up with your own 3D engine is a general lack of direction if you don't tie it to a specific project. Aimlessly doing an engine with no goals is not necessarily a bad things. Just make sure you understand what is your own personal objectives of the project. If you want to learn, then this great way to go about it. If you want to build an engine that you'll be able to use on all of your future projects, then I'm afraid you'll probably fail. I'm not attacking your own skills or dedication. The problem is that it takes a lot of time to create a generic 3D engine that can be used by multiple projects. By the time that you get finished a couple of projects with a successful engine, you will probably need to provide an update for it. That time could be much better spent on an actual game. Before creating your own engine, ask yourself what you want out of it. If what you want is to create a game and not the engine itself, then chose an existing engine that will cover your need.

So what are the engine of choice? It really depends at what level you are working at I guess. The only professional engine I've worked with was Gamebryo, so I can't compare it to Unreal or any of the other engines out there. On the free side, I've worked with Irrlicht and Ogre3d. I have a preference toward Ogre since I find the user base larger and more active. There also seems to be more updates on the Ogre engine itself. Although I have to say I was pretty impressed with Irrlicht software renderer.

Wait a minute, this is an IPhone blog. Well, it turns out that at this time, there's no Irrlicht or Ogre port for the IPhone. Although I've thought long and hard about porting Ogre to the IPhone myself, I've decided that my time would be better spent on working on a game instead. So, what engines can we use on the IPhone? Well, if what you want to do is 2D, then I would suggest a look at Cocos2D for the IPhone. This is the engine I'm currently working with and I have to say that I am pleasantly surprised. One thing to note is that it is completely written using Objective-C, which I'm still not completely familiar with at this time. Although looking through the code of the engine, I have a much better appreciation for the language than I did when I started. I just hope that I can get to a point where the code I write in Objective-c just rolls out as easily as C# or C++/STL/Boost. Another alternative if you want to build 3D games would be Oolongengine (doesn't roll of the tongue quite right). I've personally haven't used it yet. It uses mainly C++ with some help from Objective-C for gluing the whole thing together on the IPhone SDK. A person of interest working on this would be Wolfgang Engel, who I believe had started (don't quote me on that) gameversity.com (I attended some class there) a while back and also who is the editor for the Shader X series of books. A personal favorite series of mine along with Game Programming Gems.

Do I regret working on my own engine for the better part of a year? Absolutely not, beside learning a few things of myself, I now understand other peoples engine much easier. Also it's normally not too complicated for me to go and change the engine if there is something that doesn't work the way I like or if there's a defect. For example, I had to rewrite quite a bit of code in the Gamebryo engine to make it work on Linux. It was a challenge, but it was well worth it.

Sunday, February 8, 2009

Why use a Software Configuration Management system?




It’s not just about saving our code somewhere in a generalized place so that it is easily backup.  It’s not only for being able to work with someone else on the same piece of code.  When used from home, it’s main used is to keep you sane!  You will probably be the only person who will be accessing your SCM at home, but it doesn’t make it less useful.  Have you ever thought, “Oh, I wonder how the code would work if I’d changed this”?  Whenever you have a working version of a software and that you ask yourself that question, which might break working code for a few hours, you need a SCM.  This will allow you to have a source directory structure that works at one particular time.  If you are about to make major changes to a working product, check in your current progress and label it if it’s needed.  You can then do major changes and if you don’t like it, come back to your original changes, guaranteed.  Also, if you work on a few days and think you have introduced a bug, you can do diff on your files to see where the bug might have crept in.  There isn’t a day that go buy where I work on code that I don’t use a SCM, it’s that useful!


I do not know how many people do not use SCM when coding from home, I’m guessing most probably don’t, especially if the programming is more informal rather than professional in nature.   If it’s professional and linked to any delivery, then I hope you do have a SCM working for you.  I would also invest in a local backup system for that SCM and look at an offsite backup system for that rare case if your house burns down. I’ve already told my wife, “You grab the baby, I grab the Synology server and we meet at the front of the house”.  I don’t have an offsite backup, but I might be looking into this year if my moonlighting work requires it.


For those of you that don’t have a backup solution, this article is for you.  We’ll try to setup a Perforce SCM solution.  I have been using a Perforce client on my Windows PC for many years now.  We’ve also used Perforce in combination with Jira, which is a bit more process driven.  In my work environment, I can’t checked in a change list without have first written a Jira issue describing in details why I’m doing the check in.  In a home environment, we’ll probably very rarely need such an elaborate process.  You might still use a bug tracking tool, but if you are one or two developer, it will probably not require you to have it tied to your SCM.  If you have the patience for it, great, but in my experience, it would add too much overhead for the work I personally do at home.

Because I already use Perforce at work and at home, I’m going to describe how to do a similar setup, but for Mac OS X.  First thing we will do is to download a few tools from the Perforce Web Site.  Once here I download the Macintosh version of the visual client P4V, the command line tool P4 and the server P4D.



Installation


Once you have everything downloaded, then comes time for the install.  First thing to do is to move the file downloaded to some useful directory.  I’ve created a Perforce folder under Applications to which I then moved my p4v.dmg, p4 and my p4d file.  Once moved, you will probably need to use Terminal to go to that directory and make the p4d file and executable file.  Go to which ever directory you put your files in and execute chmod +x p4d, do the same for the p4 file.  You might want to move the p4 file in a more useful directory, which would be under $PATH.  The reason is that we want to be able to start this program from any directory that we would be working .  /usr/bin might be a good choice, so lets move it into there.   Go in your download directory using terminal and once you are in the correct folder, move the p4 file using the command mv p4 /usr/local/bin.  Hmm, did that not work?  Protected directory you say?  Instead try sudo mv p4 /usr/bin, this runs the same command, but as a root user which is needed to access certain directory.


Running


Now that everything is installed, let’s try running the visual client, P4V.  Go into the applications directory where you installed the P4V.dmg file and click on it.  You’ll see a p4Merge and a p4v in the mount.  Let’s copy those directly in the applications folder we created instead of keeping them in the dmg file.  Now run p4v and you should see something like:




Maybe the 1666 is instead a $P4PORT environment variable, but it will be something close to this screen in either case.  Because perforce isn’t a known host, we’ll go ahead and changed this to localhost or 127.0.0.1, either should work.  For the port, you can either hardcode it to something specific like 1666 or use their environment variable and set it something similar (1666 is the default set by Perforce).


Before we can go forward here, we’ll need to start the Perforce Server.  On my Windows installation, I did not need to install a perforce server since I could just us the filesystem directly instead.  This doesn’t seem possible with the Mac version.  To start the Perforce server, navigate to where you installed the p4d file using Terminal and the simplest way to start the server is by calling simply ./p4d.  If you want to use a different port than the default, you would need to use the -p flag and specify the port as such: ./p4d -p 2666.  If you want to be able to launch the process in the background and forget about it, you can append a & character at the end of the command line.

One thing that you should know about launching the server in this way is that it will create all the file necessary to run the Perforce SCM under the root directory.  So make sure that you are ready to have your file saved in this directory before you proceed.  If you do want to change the root directory of the server, you can either provide a -r followed by the directory path you do want to use, or create an environment variable named P4ROOT that does the same.  On my own setup, once I’m finally done, my command line looks something like ./p4d -p 1666 -r ~/Documents/Perforce/&


As you can see, I created another Perforce directory under my ~/Documents folder.  This will be easier for me when I will be doing backup, since I might not normally backup my Applications folder, but I do backup my Documents folder.

With the server launched and ready, we should be able to create our own user!  In the p4v application we launched earlier, we can see a User field, click the New button on the right of it.  This will ask you to fill in your user name, full name, password (although optional) and email. Once you have filled all this information, you then need to fill in a workspace if you need one.

The Root folder of your workspace should be somewhere under the root directory structure that we started the server with.  Which in my case was the ~/Documents/Perforce.  So in that directory, I created a directory workspace and now my Workspace dum points to that directory.

Here is p4v, started and ready to go.  You can now drop files under that directory and submit them, you can then revert, compare, check out and check in all of your source file for greater control over your home project, little or big.

Next time we’ll look at the integration with XCode

Thursday, January 8, 2009

IPhone Programming, where to start?

During my Christmas vacation, I decided that I will learn Iphone programming.  As soon as I finished ordering my Mac, I was on the Internet to try and find literature about this new development platform.  Sometime it's good when there aren't that many choices of books on a subject, and in the case of Iphone programming, there really isn't that many books available. As long as their some good choices (anyone ever seen a good Direct X book?  I haven't) then having little choices makes shopping much easier and faster.    It really doesn't take me long to see if I'm going to like a book, you can learn a lot from the content pages, the intro and the index, readily available on Amazon.  Most people agreed, "Beginning IPhone Development" was one of the better books to start learning IPhone programming.  

But wait a minute, I need to learn Objective-C also? And Cocoa?  This is slightly more complicate than I first thought.  I certainly don't back down from a challenge so I ordered another book for Cocoa, "Cocoa programming for Mac OS X".  It was rather well reviewed and seems like the goto book for this framework.  Objective-C was a bit more complicated because the book of choice "Programing in Objective-C" by Stephen Kochan is between edition right now.  I would love to get the book as fast as possible, but there was going to be a new release in only 2 weeks!  Surely I could do without having a book on the subject till then.  So I decided to pre-order the "version 2.0" and wait on this book a little while longer.  I received an email today that I should be expecting it by mid to end of February. 

So far, I've read through the Beginning IPhone Development and I've really enjoyed it.  The syntax (Objective-C) is really really getting on my nerve, but more on that later.  I haven't had the need to read the Cocoa book, and I quickly noticed that the IPhone framework although similar is not the same as the Mac OS X programming.  By browsing quickly, I can see that there are things that would be useful for me, but these are normally already well covered by the Beginning IPhone Development book.  If your interest is with IPhone programming, I probably wouldn't get the Cocoa book if you are on a budget.

Objective-C
The IPhone programming book does NOT teach you anything about Objective-C, but it's a good thing.  I hate swiss army knife type books.  If I knew Objective-C well, having a book on IPhone development explain it to me would slow me down with learning what I actually want to learn: IPhone programming.  It would also just do a mediocre job at covering Objective-C compared to a purely Objective-C book.  So many books go down this road and it always annoys me (Appendix are alright).  Kudos on not making this mistake.  Unfortunately I do not know Objective-C, but thankfully the book points you to an online resource that does a great job at covering the basic of the language.  You'll need to register with the IPhone Dev Center, there you will find many resources here that will be absolutely necessary for learning IPhone development quickly. 

I'm normally really quick at picking up new language, the last language I had to learn was C#.  I started and finished "Programming in C#" by Jesse Liberty  on a transatlantic flight over to Europe.  Alright, so it was the first edition and it was slimmer than the current version but nonetheless I was very impressed at how intuitive the language and the environment was.  C# is now the first language I turn to as soon as I have to do any tools.  I also looked at using it for games, unfortunately the support for XNA isn't great for the casual market.  The Visual Studio IDE with C# is top notch when developing user interface, I've never seen a better application for doing GUI development.

Objective-C is no C#!!!  The language feels quite archaic and the Cocoa framework is nowhere as clear as .Net when it comes to naming convention.   I was very surprised by XCode though, I actually find it very good for the most part.  Code Sense is a bit inferior to Intellisense but I was just happy to have something that works!  As I previously mentioned in an earlier post, I love to be able to switch between header and cpp file with a hotkey.  Maybe this is now available in 2008, which I haven't switch to yet, but 2005 only allows the Go to header and in 2003 you don't even have that luxury.  Instead I believe I use King Tools to be able to have this functionality. 

As much as I really like XCode, Interface Builder is a major FAIL in my book.  It reminds me of the old MFC, if I can ding Beginning IPhone programming in only one way is that the authors alludes that this approach is better than generated code. My first annoyance with it is that it's not really integrated in XCode, which makes my environment a mess.  After clicking on a few nib files, I'm forever trying to find the interface that I need to work with.  Thank god for Expose!!  If I could change one thing, this would be it.  Find a way to integrate it into XCode, I want it to go away when I close my project and open another project.  In one instance I had made a copy of a project that I had so I could make some non-destructive changes.  To make sure I didn't mistake one project for another, I closed down XCode but forgot to closed down Interface Builder because it was residing in another space.  Next thing I know I'm modifying the right project, but the wrong interface....grrr.  I'm not sure how often someone would need the Interface Builder up without having the XCode running.  Maybe this is useful for some people and that they now have it part of their workflow.  I just don't see it working for me right now.  Another thing that really annoys me with Interface Builder is that when it comes to programming, I hate magic.  I want to understand how things happen and in C# I know exactly what is happening because I see the code.  I know that I can enter the same code manually and get the same result.  In Interface Builder, I believe the nib is serialized data that does these connections for you.  Because of this, my learning is much slower.  How I register callback functions for my actions?  How do I create a new GUI element programatically.  I can do a bit of digging and figure these out, but because it's not in my face all the time it takes much longer. I'm also always more comfortable looking at code to see if everything is setup right.  Now I have to check my code, then change application and check if everything in Interface Builder also is correct.  I'll get use to it, but I'll never like it like I like C#.  Maybe the comparison to MFC is a bit harsh though :)

As you might have realized from my previous paragraph, I do not currently have any version control system.  I have perforce on my windows machine and I really like it.  I might have to check to see if I can't setup some kind of CVS system on my Synology backup system.  This would be the best approach for me since I could share code base easily between all my OS.  I installed GIT quickly but really haven't played with it.  If anyone has suggestion please fire away.  I need to set something up sooner rather than later.  Time Machine is alright, but it won't replace a good configuration management system. 

Well, back to the grind...

Wednesday, December 31, 2008

More on The Great Transition

My old setup was a duo core PC with a core duo 2.6 gig and a dual 22" monitor setup.  I've grown very accustom to having a dual monitor setup and wouldn't really know how to work without it.  That's on Windows.  My Mac setup is a Macbook Pro 2.8 with a 320 HD hooked up to the Apple Cinema Display 24".  Yes, I've read many many posts about people saying that the ACD LED 24" is way over priced and that for the price of that monitor you could buy 2 24" monitor or at least a 24 in monitor, a mic, a camera and a spare power adapter.  Well, it's still sitting on my desk right now so get over it.  When I jumped to Mac, I really wanted to try the whole apple experience and having the screen in front of me right now, I don't regret it...it is BEAUTIFUL (we'll see how beautiful when I get my visa statement next month!).  Seriously, I'm an amateur photographer and when I put my pictures on this screen they just pop.  I've never seen anything like it.  I do find that it's over priced by about 100$ and I would have loved to pay a bit less than that.

In the first few days of working on the Macbook pro, I was using my laptop open + the ACD. I've since tried it with the laptop closed and just the 24 inch now and I like this much better. One of the reason I didn't like it with 2 monitor is that I couldn't make my ACD screen my primary monitor with the tool bar on it.  The toolbar would always default to the laptop monitor.  It was a real pain because I constantly had to drag my mouse to the other screen to go click on the menu because I had so many short cuts to learn.

Spaces and Expose
These are the greatest OS related tools I ever had to work with!  With this I can often work better on 1 screen than 2 screens on windows.  There are some occasion where I absolutely need 2 screens.  When creating games in fullscreen for example, I normally use one screen for my IDE where I can debug my game running on the other screen.  Most of the time though, I use multiple screen to divide and conquer.  I can run to instance of visual studio side by side on screen while having a few Firefox windows opened in the other.  Now I can run 1 to 2 instance of Xcode in 1 spaces, then use another spaces for Safari and yet another space for Interface Builder.   Would I like working with 2 screens on the Mac?  I probably would, but I don't like working on 2 screens when one is a 24" at eye level and the other is a miniature screen beside it.  Because the screens aren't really balance I'm sitting square toward my 24", while normally, on my Windows setup, I'd be sitting square between the 2 screens.  You can't really do that with a 15.4" macbook pro screen and a 24".  When it comes time to upgrade my PC, who knows maybe I'll get a Mac Pro at which point I'll either buy 2 new screens, reuse my old ones or get a 30" ACD (or other 30" screens that would be good at the time).

Rest of My Stuff
When I moved to the Mac I already had an Ipod loaded with a few apps, a few of albums and some videos.  I tried synching it and I couldn't find a way to synch it without losing everything I had downloaded.  I wasn't too thrilled about this.  I did it a bit hastily and I forgot the name of some of the programs I had previously downloaded and I since lots track of them.  From now on this shouldn't be a problem since I don't really need to synch my touch to the PC.  The Ipod touch was mainly bought for programming, otherwise the old IPod classing or the blackberry bold can do the trick just as well.

I had no problem installing my Wacom tablet, I just needed to download a driver and it was a painless installation.  My Synology CS 407 is a different matter :(.  There doesn't seem to be any easy way of me to use it as my backup system.  In the end, I'm using an old 500GB USB drive I had, although I would have preferred a centralized backup it will have to do for now.

Bootcamp
I was a bit disappointed with Bootcamp, actually, I was downright mad at first.  I tried installing Windows XP professional using Bootcamp.  Unfortunately I THINK that it didn't have the Service Pack 2 pre installed on it.  This was a rather old version that came with MSDN Subscription.  So when I installed the disk in and the machine rebooted to install XP, it went to the DVD menu but then it stuck there.  I couldn't pick any of the choice on the screen and I couldn't get the DVD out.  I finally found a way to get the DVD out by just pressing the mouse button, I thought this would be the end of my troubles.  Instead whenever I rebooted it would show the white screen but no logo and it would just sit there.  I finally found in the documentation how to clear the nvram at boot up and that did the trick.  Although I have to say I was sweating for a little while!  So for now I purchased VMWare Fusion and installed the very same XP version through VMWare with no problem.  I have to say, I have yet to use it.  Of course I have a very good Vista machine sitting right next to this one, so there's no real reason for me to launch the VMWare version other than pure curiosity.  Although I'm curious, practicality normally wins over.  When I'm on the road I'll probably bring my Macbook pro instead of an HP Tablet with Vista and I have no doubt that VMWare will become become a very good friend of mine when that time comes.

The Woes of the Great Switch

With my recent switch to Mac, I am reminded of how dependent on all of my shortcuts I can be.  I launch Pages write a few paragraph and I want to change to a new page and control-enter doesn't work.  I don't use word processor to often, so this isn't a huge concern, and I could always install Neo Office that would probably closely match Open Office for windows.  It took me a while to find the front delete key (fn +delete).  I'm fairly used to start deleting where I land and having to reposition myself was starting to annoy me a bit.  Fn + delete short cut will do just fine though.

My main problem right now is all the little short cut I use every 5 min that seems to be gone. Windows key + e for bringing up explorer, is now replaced by either using command + N or option + command + space if I wasn't clicking on the desktop first.  I haven't really found a way to check for processes running and their performance yet, except for using the terminal and running top.  I've used it a few time so far to close programs that hung(Mac program do hang after all!).  How about an easy way to lock your computer?  I was used to windows key + L, now the best way I've found was to move the mouse in the corner of my monitor to trigger the screen saver.  I hate using the mouse.  I already have my hands on my keyboard, so using the mouse for anything takes more time.  Plus if you move the mouse while it's in the corner and while its triggering the screen saver, it will cancel the screen saver.

It was worst within XCode, not because there's no short cuts, there's an abundance of short cuts and I have to confess that I'm already getting used to them, although I haven't found a way to comment out block of code automatically yet (Ctrl-k + Ctrl-c in visual studio).  Since XCode is what I use the most right now, I'm spending way too much time using the mouse which I normally rarely used during development.  After 3 days in the environment and being very deliberate about using short cuts (going through the menu with the mouse and then canceling out and using the short cut instead), I am getting somewhat comfortable about using them...maybe too comfortable.  I really like the Option+Command+ up array for switching between .h and .m file.  In Visual Studio 2003, I'm using a plug in for this and in 2005 they incorporated a "Go to header" functionality.

All in all, I am on my way to a full transition.  It's not going as fast as I'd like, but I have to be somewhat realistic about how quickly muscle memory will accept new key combination.  After all, I never think about pressing the key combination, it's really just a reflex.  With time, it will come though, now I'm interested in seeing if I can switch easily between Mac mode and Windows mode.  I can't forget my Windows background either since I still need to use it for work!


Windows Programmer Switches To Mac

I've been a Windows user for many years.  My very first computer was an Apple II, but after it came Dos and since then only Windows.  I've skipped a few version here and there, I stayed away from Millenium for example.   Windows 98 Plus?  C'mon.  All in all, I've had very few complaints about Windows although I had the occasional crash.  I'd also reboot my PC weekly,  but nothing that would really really bug me to the point that switching to Mac seemed like the only alternative.  My worst experienced would probably working with the Windows GINA a few years back.  Wow did I ever screw up my machine often.  VMWare would have been a god send back then!

Why now thinking about switching to Mac?  IPhone/IPod touch development is why!  Although I wish I could do development on a PC (it would be much cheaper as I have enough of those :) ), the Intel Mac is currently the only platform that supports development for this interesting new mobile platform.

I've decided that I will be buying a Mac and learn as much as I could over the Christmas Holidays.  I don't have 2 weeks off in a row often, so I'm hoping I can take full advantage of this to learn my way around a new OS, a new IDE and a new language (Objective-C, Cocoa).  I've actually created this blog more or less to document my plunge into the Mac world since I think this is probably the biggest changed I've done in my profession to date (time will tell).