Wednesday, July 7, 2010

XNA progress

One of the good and bad things about Windows Phone 7 is that it has two development APIs to choose from -- Silverlight and XNA. This is good because it allows for flexibility to choose the right tool for the job, but bad because I know neither of them, and thus have to learn both of them to have the understanding of the platform that I want.

Silverlight frightens me, though, because it's heavily about layout, which I've never been good at. My blogs are only tolerable because they come with templates, and anything else I design hasn't a whiff of design, layout or interface. This is a problem I'm going to have to overcome, in time, but for now, I'm learning some XNA, which lets me ignore such things and just draw pretty graphics all over the screen -- art being something else I'm hopeless at, so will be using liberated assets from the internet and elsewhere.

To learn XNA, I've been reading the O'Reilly Learning XNA 3.0 book, wishing that there was a 4.0 version out already. There are a few blogs out there that are trying to help developers make the transition, and a few others that are trying to point out the Windows Phone-specific differences for XNA development. But for now, I'm going through the examples in the book as Windows Phone 7 targets and dealing with any discrepancies as I find them.

One of the first examples (that does anything interesting anyway) is putting an animated sprite on the screen, and then using various input devices to move it about. While they provide animation spritesheets with the downloadable content for the book, I have other assets that I prefer to use. After a little bit of customizing of the example code (which I've now noticed I'll be changing in the next chapter), I ended up with something that I'm pleased with.

Now really, this is not much of an accomplishment -- this is chapter 3 of the book, and all it lets you do is move the ogre (his colours look fine on my screen; I haven't figured out why FRAPS doesn't capture it properly) around with mouse and keyboard. Well, it would if it was a regular XNA app, but the XNA KeyboardState doesn't translate well to the phone emulator, and the mouse interaction on the phone requires your finger on the screen, thus clicking-and-holding the mouse button, instead of just moving it. But even though this is currently a trivial result, it definitely helps drive me to learn more, especially because seeing this with the alternate graphics helps to drive my other project as well.

Up next: collision detection. But instead of some spinning ball from the book, perhaps I need... fire!

No comments:

Post a Comment