Sledgenet.co.uk Banner

iPhone Dev Is All The RAGE

So the iPhone 4 RAGE demo from QuakeCon has been doing the rounds this week, looking a bit like-a-this:

 

While the static nature of the scene’s lighting suggests the referenced radiosity is baked, that seems like a pretty good way to employ megatexture technology (what with a megatexture being streamed, pre-rendered data). Similarly, ‘blob’ shadows may disappoint the nerds but, to my eye, they’re often more aesthetically pleasing than their more technologically advanced counterparts (can you imagine Resident Evil 4 with stencil shadows? Horrid!)

If there’s a point of concern it has to be that constantly streaming texture-data is going to hammer the battery life of mobile devices and, when you consider the size of the iPhone/iPod Touch’s screen, it may be doing so to very little discernable effect. Are you really going to notice that every surface is uniquely textured on a display that small when, arguably, a straightforward light-map already lends that appearance to non-unique textures convincingly enough?

 

So RAGE may be a better fit for the iPad, where its superior graphical fidelity will be obvious enough to outweigh any effect it has on battery life (and where battery life is arguably less of an issue anyway given that the iPad is, by virtue of its size, less mobile than its wee brethren). The main point of interest for me, though, will be exactly what id does with the tech, because it can’t be gearing up for yet another FPS… can it?!

BinGo!

What better way to give Windows Live Writer a whirl than a post about Microsoft’s aspiring search engine which, frankly, I can’t see failing. I mean, how could you possibly resist this…

Bingo Screenie

Your turn Google!

XXL?!

I consider myself bisexual, as I like to tell anyone too polite (or drunk) to escape my wit in the pub, because I’ll merrily sleep with both straight and gay women. Hence, as a paragon of sexual tolerance, you’ll believe me when I say things have simply gone too far. And I speak, of course, of the metrosexualisation of men’s sizes.

The signs were there with stores like Officers Club, which seems to want to restrict its clientèle to lithe under-twenties, drug addicts and people with wasting diseases. As a burly (yet enlightened, lesbo-shagging) bloke I would struggle to find anything in there that I could fasten without ripping sounds, and I began to suspect that they had different definitions of “extra” and “large” to the ones I was so intimately familiar with. And, y’know, that would’ve been fine — let the youthful, stick-like fops have their scene and their shops — only now the phenomenon seems to be spreading to the mainstream and, frankly, it couldn’t have come at a worse time.

Honestly, it’s like they’ve done it on purpose: Months of only having the occasional steak bake, of cutting down to a mere three or four sugary coffees a day, of setting aside at least five minutes a week for some actual exercise… my health kick had been going so well (just come with me on that point) and then the retail fraternity had to go and pull the rug out from under my efforts, doubtless with a lot of effected huffing and puffing on their part, by shuffling us all up a notch. YOU’RE NOT FOOLING ANYONE, RETAIL FRATERNITY!

To be fair they aren’t really trying to fool anyone, on the contrary they’re rakishly upfront about it. For example the last time I was in Debs (the store not the lesbian) they had signs up to the effect of  “Don’t worry, you’ve not put weight on. We’ve just had a meeting and redefined what obese means. You (sur)prize porker.” Matalan were (even) less kind, the “XL” shirt I picked up being decidedly L-ish yet remaining the largest they stocked, presumably because, whoooeee, who would need XXL, eh? Nobody’s that big!

And that’s why this madness clearly has to stop. Because, left unchecked, the process will eventually see me and my burly blokey brethren unable to find any clothes that fit and having to streak to work five days a week, which nobody wants. You might say it’s an XXL problem, at least until you spot the one part of my anatomy that really is metrosexually sized…

While I’m not a journalist pesky integrity compels me to point out that, despite their sign, my new Debenhams XL shirt feels as big as ever, although that’d be consistent with my weight loss I suppose. Also, Matalan carry inconsistently sized product ranges and some of the stuff I didn’t want to buy was marked XXL, although a fat lot of good that is.

XNA Coding Redux

“Why are you only writing games for iPhone and not for Xbox too?”

It’s a good question that my friend asked me recently and I really didn’t have a similarly good answer, so having recently got my bearings with C++ I thought it’d be worth skipping swiftly onto C#. And while I’m only a coupla days into my faffery with XNA, I’ve noticed some interesting things about how, lately, my coding style has… well, regressed!

For example, a year or so ago I would’ve told you that lists are The Answer. Coming from a Blitz background I naturally tended towards solving everything that possibly could be solved with doubly-linked lists with the lovely lil’ buggers. The thing is, once you move into the mobile realm, object persistence becomes really important because instantiation is so costly. On iPhone you’ve also got to contend with the fact that garbage collection is half-arsed (the worst kind of arsed) so that, as well as taking time, object creation and deletion is FRAUGHT WITH DANGER. The sensible developer, therefore, soon realises that creating a pool of objects at start-up and leaving it the hell alone until the application terminates allows one to avoid a whole minefield of performance issues.

Of course this begs the question “If you’re not going to take advantage of the flexibility of linked lists, and given that modern arrays can contain objects, why not just use arrays. Like in the eighties?” And while the issue is kinda moot under Cocoa Touch (because arrays and lists are conceptually merged into the NSMutableArray) it is a consideration that I have brought back with me to the desktop: The particle system in Vaders, for example, eschews dynamic object creation/destruction in favour of a persistent linked list with newly assigned particles being split to the back of the list — this could well be a memory-management nightmare for STL under the hood and therefore wholly inappropriate for mobile devices, but it was hella simple to code! Porting the game to XNA I’ve gone back to arrays completely, with each entry maintaining a reference to the next and the element considered “first” traversing the circle as each particle is activated. It was a bit more work than list-splitting, but offers a pretty much ideal combination of persistence and utility.

And sometimes I just sit, look at my code and go: “Fixed size arrays? In 2010? Really?!”

But yes, don’t be embarrassed. If it works, it’s right. We really don’t have to use swanky language features if they aren’t necessary and carry unwanted baggage (which the Xbox garbage collector kinda does). This is a philosophy which I have resigned myself to wholesale where the particle system is concerned. Leaving the specific collection class aside, I had actually planned to write The Mother Of All Particle Systems for VadersXNA because, on the surface, this seems like an ideal area to apply modern language features like inheritance and generics.

Only it’s not. Not necessarily.

The thing is, explosions aren’t fire and fires aren’t smoke and smoke isn’t fireworks. Not remotely. While you might think a particle is a particle is a particle, the members and therefore parameters required by different kinds of efficient particle vary wildly. So much, in fact, that expressing them in terms of an extended common class, to a generics noob, is far from trivial compared to simply duplicating an existing class and editing it to taste. So, each kind of particle in VadersXNA is its own distinct class and, yes, that is something that will have OOP aficionados clutching at their chests in horror… but y’know what? It’s performant, fast to implement, easy to maintain and it works.

As a kid I remember an L-Cars comic strip where one of the characters had constructed a massive, warehouse-filling machine. He sat casually in front of the behemoth, fag in mouth (hey, different times!), tapped a foot-pedal and — click! — it lit his cigarette. Sometimes, with modern programming languages, we create complex solutions for problems that really aren’t worthy of them. Here’s to matches!

Vaders ‘Vadin

Daft lil’ Space Invaders-alike that I wrote while trying to wrap my noggin around C++ (I’m proudly at the “It’s C with classes!” level at the moment and I think I’ll be here a while.) Check it out in The ComPile.

This week I have been mostly…

…learning C++! Of course when I say “learning C++” what I really mean is “learning to express the OOP principles I’m already familiar with in C++’s parlance”, so it’s not like I’ve gone from zero to a working knowledge in seven wee evenings. We’re also talking games development, which essentially amounts to defining object classes and populating linked-lists with them (and not much else), and having such a narrow remit certainly helps. In fact the hardest thing, by far, was getting a working development environment up and running in the first place: Visual Studio is superlative, but I wanted C++ not C++.net; DevC++ throws a wobbler if you have a prior MinGW installation (which I do, for compiling BlitzMax modules) and there are an overwhelming selection of DevPaks for SDL and Allegro (because I wasn’t going to learn C++ writing console apps); Code::Blocks looks lovely but its project wizards are confused by just about every library you direct them towards, never being able to locate the required files. It’s a good job I don’t have any hair!

So, for the similarly inclined, I’m going to quickly outline what I went with because trawling through the available options ended up being a couple of grim days’ work. Here we go:

www.cprogramming.com: For actually learning the language, this place is pretty good with straightforward, easy to follow examples. Again, this is from the perspective of learning the lingo rather than the concepts — personally I wouldn’t actually want to try to grasp OOP via C++ (I’d opt for something higher-level, like BlitzMax) but YMMV.

iMiniB3D: It was the example source code that comes with iMiniB3D that gave me an idea of what clean, sensible C++ looks like. Even if you’re not interested in iPhone development, it’s worth a squiz.

Code::Blocks: Sure, the project wizards for SDL, Ogre and whatnot are squiffy, but as I wound up going with a different media library with a manual setup (see below) it ended up not mattering. It’s a really sweet editor.

SFML: Simple and Fast Multimedia Library is an SDL/Allegro-alike that is just exceedingly clean. You’ll notice I’ve linked directly to the Code::Blocks/MinGW setup tutorial — take the fact that it needs a particular version of MinGW seriously because, from (bitter, bitter) experience, it won’t work otherwise. I would recommend using Search Directories for library installation rather than copying files (in fact your Code::Blocks directory won’t even resemble the one in the tutorial).

irrKlang: Cleaner than BASS and supporting more formats than SFML’s equivalent, irrKlang is a thoroughly decent choice for audio. It will load files from MoleBox packages (which I couldn’t get BASS to handle) and the license allows you to compress the dll (which will UPX to about 200k).

The above should be all you need to get going and write, say, an example little game such as, ooooooh, some sort of Space Invaders clone?


I’ll upload that to the ComPile once I’ve finished writing a lil’ tunelet for it (EDIT: Voila!), but we’re not quite done with the links yet! One of the nice things about SFML is that your window is already an OpenGL context, so it’s an excellent springboard for leaning raw OpenGL (indeed you can even go mySFMLImage.Bind() to bind a texture, and that’s on top of the delight of having SFML’s image laoders). Now there’s a school of thought that says you should no longer learn fixed-function OpenGL but, as I’m specifically interested in OpenGL ES (and therefore iPhone) compatible code, I didn’t pay that advice any heed. Bearing that in mind, I found the following places useful:

Zeus CMD: Nice set of tutorials specifically aimed at OpenGL ES. You’ll have to amend the code a bit to get things running under SFML (‘glOrthof’ becomes ‘glOrtho’, for example, and there is no ‘gluLookAtf’ out of the box) but that’s half the fun, right? RIGHT?!

The Game Programming Wiki: A comprehensive set of tutorials (and links to other sites) with some very useful 2D framework code.

Have fun!

The King Is Dead!

New scene demo from yours truly. Details here. (If you fancy getting into scene coding then you could do worse than pop over to Dark Bit Factory & Gravity — it’s ultra noob friendly.)

Unity iPhone Quickstart: Mesh Pick

While being able to set up a user interface with GUI Textures is all well and good, there are times when you’ll want regular on-screen objects to respond to the tender caresses of your users. Determining which 3D mesh falls under a particular screen co-ordinate is known as “picking” and Unity has a set of commands specifically to help you out here. Hold on, though, ‘cos things are about to get interesting!

Continue reading →

Unity iPhone Quickstart: Button Tap

There are a wealth of resources for Unity iPhone but, when starting out, I would really have appreciated a bunch of step-by-step tutorials showing how to achieve some of the fundamental things that games developers typically need to do. Being able set up an FPS controller in a couple of mouse-clicks is all well and good (in fact it’s awesome) but not much use if you don’t actually want to make an FPS, hence this set of several short tutorials showing how to do some very specific, simple things with Unity iPhone. For anyone approaching Unity from a similar perspective to myself (ie being familiar with the iPhone and other development solutions but only casually acquainted with the engine) this stuff should hopefully help you to hit the ground running.

So, with  regards to the iPhone the three questions I wanted immediate answers to were “How do I make a button that will respond to being tapped?”, “How do I pick meshes?” and “What’s the deal with serialisation?” In this tutorial we’ll deal with the first of those:

Continue reading →

DeleD to Unity via Cheetah3D (phew!)

I’ve been trying to gear up for some Unity usage, which has meant concocting an asset pipeline from my (newly!) preferred level geometry editor, DeleD. The process isn’t quite as trivial as would be ideal hence I’m going to relay it here in the hope that mine is the only sanity lost on this endeavour. Bibble! Continue reading →