Tuesday, April 28, 2009

Interesting iPhone Development Presentation

Snappy Touch, a company owned by Noel Llopis who previously has worked on massive console games, is now working on his own start-up. Just a one-person "team" rather than two hundred. He has gone solo and started making iPhone games. He has made an interested presentation at GDC 09 and he shares some knowledge on the process of getting aboard this interesting journey.

Check out the GDC 09 presentation including audio. You can sink the slides manually with the audio pretty easily.

Friday, April 24, 2009

The pains of converting from Java to Objective-C

I'm still compiling a list of the annoyances I encounter when converting from Java to Objective-C, which I will publish soon. But so far the worst one was to be careful when using the math functions like abs instead of fabs! The abs function works with ints and if you try using it with a float, you are going to get some bogus result. Why why aren't such methods overloaded!?!

Wasted a good two hours trying to hunt down such a bug in some code which worked fine in actionscript.

Mental note: remember as well sinf, cosf, asinf, acosf

Migrating current actionscript code to Xcode... check :D
Next task...

Thursday, April 23, 2009

Refactoring in XCode needs improvement

I'm used to Eclipse refactoring, and the refactoring capabilities in XCode compare to Eclipse are abysmal to say the least. Ok, I know Java is much easier to parse, and so the refactoring tools are "easier" to do, but I would expect that at least renaming a field of an Objective-C class would be done across the header and implementation files, and not just the header file. So instead I have to the use the rename dialog box, which of course is very error prone.

Maybe I'm doing something wrong, but I don't see what that could be. I'm just selecting the field, Edit->Refactor->Rename.

Friday, April 17, 2009

Killing bugs before they happen on the iPhone

You can easily set up a Static Analyzer, which will check your Objective-C code for bugs, like memory leaks, dead assignments, etc, without actually running the app on the iPhone (that's why "static"). Check out this tutorial to setup the LLVM/Clang Static Analyzer for iPhone Apps.

You need to dirty your hands slightly with the Terminal to run the analyzer. You might want to add analyzer to your path to your .bash_profile so that you can run the analyzer from anywhere.

When you run the analyzer, you will see a bug report with links to your source files to show you the exact line where you have a bug. Sweet!


Drawing a Textured Line in OpenGL ES


Currently I'm still playing around with the CrashLanding demo app as my sandbox :) Those red spotted lines are my textured lines.

I wanted to draw a textured line and opengl doesn't support drawing textured lines as such. You need to create a polygon (actually two triangles), and texture them.

So I created a simple class which takes two points, calculates the length and angle with the horizontal line. Then I calculate the vertex coordinates and the texture coordinates.

These coordinates are generated as if I am creating a horizontal line. And then before drawing I simply rotate the model view matrix. The vertex coordinates would be something like this
0, -w/2
0, w/2
length, w/2
length, -w/2
where length is the length of the line and w is the width of the line

The texture coordinates would be calculated as follows:
0, 0
0, 1
length / tw, 1
length / tw, 0
where tw is the texture width.

Then draw the two triangles to create the textured line.

glBindTexture(GL_TEXTURE_2D, [_texture name]);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glTranslatef(_point.x, _point.y, 0);
glRotatef(_angle, 0, 0, 1);

glVertexPointer(2, GL_FLOAT, 0, _vertexArray);
glTexCoordPointer(2, GL_FLOAT, 0, _textCoordArray);
glEnableClientState(GL_VERTEX_ARRAY);

glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glPopMatrix();

Tuesday, April 14, 2009

Adding an SCM SVN Repository to XCode

I needed to set up some subversion. Having a subversion (SVN), or any other source control management is very important. Besides backing up the code remotely, I can quickly diff with previous releases, commit with comments, tag files and code branches, etc.

I googled a bit for free SVN hosting and found XP-Dev.com. After creating my repository I set up XCode to know about my XP-Dev repository. That was a breeze, but then a problem crop up when I wanted to import my existing prototype in the repository. It was complaining about some SCM Error 155007.

Googled a bit more, and luckily some other guys had the same problems. They suggested to do the initial commit from the terminal. This did the trick:

svn import /path/to/project http://username@svn.xp-dev.com/svn// -m “Initial import”

Remember the to do the name when importing, otherwise you won't be able to do a proper checkout. After the import is done, you need to go to XCode>SCM>Repositories and do a checkout to a different directory. It should prompt you to automatically open the XCode project when it finishes.

To check if it's working fine, you can simply type something in some existing file and save, and you should see an M to the left of the Groups & Files sidebar, meaning it is modified and can then be committed at your will :D

Renaming an XCode Project

I found it is pretty painful to rename a project in XCode. Then I found that someone has done a script besides describing how to do it manually. Learn more on renaming an XCode project.

Monday, April 13, 2009

Starting Phase 2 of iPhone project

I have just finished phase 1 for my little iPhone project, which was basically getting acquainted with Mac OS X, XCode, the iPhone Simulator, ObjectiveC, memory management, brushing up some opengl. That was quite a lot! I'm not as proficient as I am with Java on eclipse, but at least I'm starting to walk.

Now I will start on phase 2, which is basically migrating my little game prototype I have done some weeks ago in ActionScript on Flash. It's a very simple game, similar to the old Frenzy game that we used to play on my cousin's old BBC micro. The concept is similar, but you can do diagonal lines, and the prototype I have done so far uses the mouse to draw the lines. The iPhone version will be obviously using the touch interface. When I imagined this game, I always had a touch interface in my head. I have other ideas I need to experiment with to make the game even more interesting.

I better check how to setup some source code management (SCM) on XCode...

Saturday, April 11, 2009

Changing Process Priority on Mac OS X

On Windows I used to bring up the Task Manager (Ctrl-Shift-Esc) and quickly change the priority of a process, e.g. to a lower priority so that some process doesn't make the machine feel slow when some CPU intensive task takes over.

On Mac OS X I thought I would fire up the Activity Monitor and right click to change the priority. Apparently it's not that easy. I fired up google and found out that I need to get the PID from Activity Monitor and then launch a terminal and use the renice command.

E.g. sudo renice +1 -p 3692

A process can have a priority between +20 (lowest priority) and -20 (highest priority). 0 is the default priority. The above will make the the process with PID 3692 with a slightly lower priority.

Wednesday, April 08, 2009

Migrating Shortcuts from Windows to Mac

Copy Pasting
Instead of Control use the Command Key (⌘). So Ctrl-C becomes ⌘-C on the Mac.
First of all, if you plugged in a Windows keyboard, the Start button acts as the ⌘ key.

Undo Redo
The Undo shortcut is similar, ⌘-Z however the Redo you need to hold the shift key while doing ⌘-Z.

The hash/pound # key
To type the hash / pound # key, you need to press the Alt together with the 3. I got stuck on this when I wanted to do a #import :)

Navigating Text
In Windows Ctrl-arrow keys would navigate the text word by word. On the Mac you need to use the Alt instead of the Ctrl. (Luckily on XCode, the Ctrl shortcut does the same thing). The End and Home keys will take you the very end and start position of the whole text. Very annoying since on Windows we are used to be related with the current line being edited. To go to the end or start of the line you need to press Ctrl together with an arrow key.

Quick Dark Scheme
In Windows I use WindowBlinds and my Dark Aqua scheme, (inspired from the Mac). There are some skinning applications on the Mac, but I haven't found what I'm looking for to be able to switch completely to a black skin. However there's a quick native shortcut which will invert the colors, and so if you feel that your eyes are getting strained during those late night coding hours, you can easily switch to a black scheme by hitting Ctrl-Alt-⌘-8.

Killing processes
You can either launch Activity Monitor to replace Task Manager. Or you can launch the Force quit menu by pressing Alt-⌘-Esc.

Fell in Love with the Mac

This is going to be a brain dump of the last two weeks using the MacBook.

I have been a Windows user from the beginning. I didn't like Macs a lot ("where's the right mouse button?"), until I saw the release of Mac OS X. And finally I got my own MacBook. It felt like an alien dropped by and gave me his laptop. Every shortcut I knew in Windows needs to be rewired in my brain.

Very nice machine. Besides being impressed by the hardware and OS, I was mostly impressed by getting started to develop for the mac and iphone/ipod touch.

I love the fact that I can drop into a terminal window and have unix commands at my fingertips. I have done some remote unix server admin, although I still need to learn a lot in this area.

Installing applications is dead easy...dragging into the Applications folder. You want to uninstall? You just remove it from the Applications folder! Hah. Although I have found a small application called AppDelete which will make sure to remove any config files, etc which won't be used any more.

Why oh why didn't I switch to a Mac ages ago? Money is always the problem.

I got the Macbook for development. So I got a second hand Macbook and I want to plug it to a keyboard and monitor (considering KVM switch until I put my Windows machine down). I also got a Mini-DVI to DVI connector, so now I'm using SGI 1600sw as the primary monitor and the Macbook as the secondary monitor. The SGI is quite old now but IMHO it is still a very good monitor :D. I like this dual monitor setup... on the macbook I keep the documentation and on the SGI I keep XCode windows.

Which reminds me about XCode and Objective-C. Currently I'm learning about Objective-C which apparently was released in the same year as C++, but I didn't hear about it before this year. It has some interesting concepts like categories, and I missed the fact of passing functions as parameters. I have used Java to much now. Got me lazy with that garbage collector :) Finding it annoying now to have to use reference counting to properly release variables. Got a lot to learn...

I started an OpenGL ES application for the IPhone. That just only means that I let XCode generate the template :) I'm still looking at tutorials. First stumbling block was drawing text. There are two ways how to do that. You either create a texture for the text you want to show, but that leads to a problem if you are changing the text every frame plus its memory inefficient. The second approach is creating a single texture containing all the characters and keep track of each characters kerning and spacing. Ughhh I had done the latter ages ago on Windows. Guess someday I will need to reimplement it unless I find some ready made class (which I have found yet). For now I will create a texture for each string :(.

Monday, March 23, 2009

Getting a macbook!

It's been a while. Have been busy working with a game company last year, and this year I'm working as a lecturer. Teaching students takes a lot of my time, but hopefully during the summer time I will have some time to do some small game project.

I'm hoping of developing something small on the iphone and try my luck publishing on the app store. It's not for the money, it's for the fun of it. The iphone is a pretty cool device and I've hear good things about its APIs. I've already got a quick prototype in Flash, but now I will need to port it to iphone SDK.

First things first... I need some mac machine. So I just bought a second hand macbook through ebay. Waiting for it to arrive on this island! Let the iphone adventure begin...

Wednesday, June 13, 2007

Lunch Prodigy interview

Lunch Prodigy has been featured in the following blog - http://www.odinjobs.com/blogs/page/thatsinteresting?entry=what_s_for_lunch_log

Editing of items, printing options and timestamp

We have now introduced the facility to also edit the items when the user is in the add items page. Previously (if the user had the privileges), he could just click on the name or price when in the menu and type the new values. But with the introduction of food categories, we needed a page where you could select the new category if you want to move a food item from one category to another.

We have also introduced some printing options by request. Some companies want to view the ordered food grouped by the item being ordered. Other companies want to view the ordered food grouped by the user who ordered them. So we introduced both options in the Company Profile settings where they can be ticked accordingly.

By request, the timestamp of when the order is printed is placed on the order print page.

We have also experienced a bit of problems with a number of concurrent users accessing the service. We are conducting some tests to resolve this issue. UPDATE: after a lot of testing it turned out to be a connectivity issue from a client's side.

Monday, June 11, 2007

Minor fixes for Lunch Prodigy

We have fixed some problems encountered by our users.

  • backspace in the search field was not behaving properly in IE
  • added searching capability only in the selected category
  • minor glitch in the time differences between server and clients
  • adding of providers can now only be done by privileged users or if users are allowed to edit content
  • fixed a bug when creating a new provider
Coming soon...
  • lost password feature
  • timestamp when printing an order
  • edit/deleting items in a menu

Saturday, June 09, 2007

Lunch Prodigy updated

We were contacted by a big company which were interested in using LunchProdigy.com however there were some missing features which they wanted to be in there. So we gave high priority to Lunch Prodigy this weekend and here are the updates:
  • Support for categories. Food can now be entered into categories and each provider can has it's own categories
  • Printing also shows who ordered what
  • Support for comments. Users can now enter a comment when making an order. Very useful for the picky ones who don't like mushrooms or whatever :)
  • Some options to make adding/editing only for privileged users
  • Option for roster to be disabled and always the same person will be taking the order.
We will be adding soon the possibility to edit an existing item provided by some provider to be placed in some category.

Thursday, May 31, 2007

Site design updated

We have finally updated the design for SoftwareProdigy.com.

We are busy doing small flash games for CartoonDollEmporium.com and we're also doing a multiplayer cooperative flash game prototype. You can find more on our website.

Saturday, March 24, 2007

Interesting Facts upgraded

We have updated the Interesting Facts page for Lunch Prodigy. It now displays the providers entered by the company, and how much the company spent at the providers so far. It also calculates the money spent by the user who clicked to view the page.

Saturday, March 17, 2007

Lunch Prodigy minor fixes

We made some minor fixes to some annoyances when using Lunch Prodigy.
  • When the order has already been taken and the user tries to delete an order item, the user is now informed that he cannot delete anything from an already taken order.
  • When the user tries to delete a non-empty order, an error is displayed that all orders must first be deleted.
  • When the user tries to add something to the order, and the order has already been printed, he will be warned that he should inform the person who has printed the order to make sure he gets what he wants.

Thursday, March 15, 2007

Lunch Prodigy beta launched

Lunch Prodigy beta has been launched. It is primarily targeted for companies whose employees work on a computer on a regular basis and do lunch orders. Instead of having some employee running around the premises to see what his colleagues will be taking for lunch, everyone simply logs in to Lunch Prodigy and makes their order. When everyone has ordered, someone prints the order and phones up the food provider and makes the order.

After the beta phase, we will start signing up providers locally in Malta, and then we will go global.