Divine Robot Dev
Progress! The Blobster scenes now loads and transforms semi-correct and in the foreground is the first render of Blobster himself. So far I have been using SpriteBatches for all images but since Blobster is blobby I have to draw him with triangles to be able to distort the image. Next up is trying to match the transforms of spriteBatches with the transforms of 3D drawing.

Progress! The Blobster scenes now loads and transforms semi-correct and in the foreground is the first render of Blobster himself. So far I have been using SpriteBatches for all images but since Blobster is blobby I have to draw him with triangles to be able to distort the image. Next up is trying to match the transforms of spriteBatches with the transforms of 3D drawing.

Some useful links for textured triangles

General tutorial on XNA: Riemer’s XNA Tutorials

Useful example on how to render textured triangles:

http://www.charlespetzold.com/blog/2010/03/Using-VertexPositionTexture-on-Windows-Phone.html

(and if your game just silently stops without notice in the emulator, read the comment on debugging tips - this happened to me. Luckily I found this page quite early)

Buggy

I figured Xcode was buggy but I actually think Visual Studio takes the price… Today I’ve had three or four random hangs, including one blue screen, several times when the emulator randomly doesn’t start and a few occasions where I can’t write anything. Don’t know if it’s an Mac/Boot camp issue, but it’s a totally clean install.

Wohoo! It may not look like much but it’s the first scene from Blobster loaded and displayed on WP7. Time to start on those transforms…

Wohoo! It may not look like much but it’s the first scene from Blobster loaded and displayed on WP7. Time to start on those transforms…

Impressions so far

I have been working for a few weeks now with WP7, unfortunately mostly in bursts between other projects. With the short amount of time I’ve had at my disposal, I’ve managed to do all the asset management, load all our material from the Blobster iPhone version without conversion, integrated the physics engine and gotten a basic display engine working. I’m really close to actually loading and displaying a scene now! 

So far it’s been surprisingly smooth sailing. The documentation works fine and there’s a lot of example code available. If you are used to Cocoa, it’s easy to find and work with the bread and butter stuff like arrays, dictionaries and string manipulations. Other stuff is obviously harder to find and works somewhat differently (like working with threads) but no real showstoppers so far.

Coming from C/Objective C, C# feels a bit like a toy language. No pointers? No retain/release? Malloc? Locks? (These may actually be needed, not sure about that yet…) Of course this is one of the reasons why it’s so easy to pick up. However, being a control freak it’s sometimes hard to just trust the system to do the right thing.

The biggest frustration has been my general awkwardness with the Windows platform, especially the text editing but I semi-solved that. Another frustration has been the different API:s and knowing what works when. But all in all, everything has been easier than expected.

My biggest future concern is still that of performance, we had a hard time with some of the levels in the iPhone version, and I’m far from convinced that you can get the same speed without dropping into C. I’m counting on the fact that the WP7 phones we’re targeting are a few generations ahead when it comes to hardware and hopefully it will compensate. Time will tell.

Text editing revisited

After struggling to learn the key commands in Windows I finally gave up and installed SharpKeys http://www.randyrants.com/2006/07/sharpkeys_211.html

I assigned the cmd key to the ctrl key (and didn’t bother with the “Windows”-key, who uses that?) Also, I switched the left and right alt keys, since I always use the left alt key to type {}[]. No more Start menu popping up every time I want to move the cursor by a word. My coding speed just went up by about six kazillion percent.

Although I guess it’s better to just bite the bullet if you’re supposed to switch full time my problem is that most of my coding is still done on the Mac and this was driving me crazy.

Reading text files

As a beginner, it’s really hard to figure out if stuff you find when searching is applicable for the technology I’m using - C#/XNA for WP7. This differs slightly - not enough for an untrained eye to see - from stuff that works for standard C#, C# for Windows, Silverlight… The end result is that you try a lot of simple things and they don’t work, even though you copy and paste source code directly from a web page.

I imagine it’s much the same as seeing the difference between Cocoa and Cocoa Touch.

That was what happened when I tried a seemingly very simple thing: Reading a bundled text file. Should be a piece of cake, but took me two hours to actually find something that worked.

This page describes exactly how to do it in XNA, and it works for me.

Reading plists, continued

Still working on reading plists properly. Earlier I had a solution by converting them to standard XML with XSLT. Then realized that there are more than a hundred plists included in our game. Having to convert all of them, and keep converting them for every change we make, didn’t seem feasible.

After further research, I found some libraries that were supposed to read plists directly and convert them into something sensible. Most didn’t work with WP7, but then I found CodeTitans who has a library for just that purpose. I’m going to test this and report progress.

And for the absolute beginner: To add a library (dll) into your project:

- In your project, right-click the project icon. Select “Add reference…”

- Select “Browse” in the popup window. Locate your dll, in this case “CodeTitans.Phone.Core.dll”. Done.

Utter madness…

Today I wanted to download something to expand .rar files with. I got an insight into a completely mad world. First, I got to a download page with a few free options, guaranteed “virus free”. Just one problem; in order to download anything from the site I needed to first download and install a “download enhancer”… No thanks. After some additional searching I settled for WinZip, since it’s something I at least have heard about. Downloaded and installed it. During the installation I got the offer of no less than three extra things that I didn’t ask for. A browser toolbar. A security check something. A speed scan software. All were selected to install by default.

And this is for an evaluation version of a software that I’m supposed to pay for! If this is some kind of measure on how software on Windows works, this platform is in trouble. Every single computer must be absolutely crammed with various crapware. 

Good news and a tough decision…

The good news is that Cocos2D is now being ported to WP7!

So, what to do? Blobster uses a custom display engine. I’m about a quarter done porting the asset manager and display manager of that engine to WP7, but there is a lot left to do and frankly I don’t really know what I’m doing. Our first game, Eveningstar, uses Cocos2D for iPhone so I’m at least somewhat familiar with it.

On one hand; use the custom display engine with full control, good knowledge of the source code and close parity to the original Blobster. Not having to use a library that isn’t done yet, with probably many hard to find bugs and a lot of features I don’t need.

On the other hand; A quarter of the porting will be done in an instant and the platform will be optimised by people that (hopefully) know a lot more of WP7 than I do. If we’re doing a future port to Android, chances are pretty good that we’ll use Cocos2D for it.

I’m actually leaning towards the first alternative since I’m somewhat of a control freak and want to do code my way. It’s much more easy to optimise a small custom engine to my needs. Also, it’s a very good way of learning WP7. The only thing that really makes me think about the second alternative is the thought of using Cocos2D X for iPhone/Android and Cocos2D XNA for WP7 - this would give us an easily maintainable cross platform code base. Hmmmm….