Sledgenet.co.uk Banner

OOP With “Ook!”

This week saw the release of Monkey, a new programming language from BRL which lets you code in a very BlitzMax-like dialect and then spits out projects for a variety of targets such as HTML5, Flash, iOS and XNA etc. I’m a big fan of BlitzMax’s syntax — it’s an impressively elegant, high-level way to access just enough object oriented functionality — so the opportunity to adopt it for iPhone development is just marvellous.

While the language itself is more accessible than, say, Objective-C, it’s undeniable that Monkey gives you more of a blank canvas than something like the Cocos2D library. Out of the box there’s no 2D physics solution, no meaningful support for localisation nor any equivalent to Cocos’ “scenes” — whether one sees this a threadbare feature-set or a glorious freedom from prescribed constraints is down to the individual but, even in its beta phase, Monkey was capable of turning out solid, complete  games.

Personally I couldn’t be happier — coding for mobile platforms just got as pleasurable as coding for the desktop! If you’ve even half an eye on this sort of stuff then why not give the demo a try? You’d be bananas not to. Yes I went there.

RAGE, iPod Review

So RAGE has finally graced my doddering 2nd Gen iPod Touch and, bless id, it is a shooter, viewed in the first-person no less. Rather than a free-roaming FPS, however, what we have here is an on-rails run ‘n’ gunner in the vein of Virtua Cop. In fact imagine Sega’s seminal light-gun game draped in the skin of Smash TV and you pretty much have RAGE in a nutshell. So job done, review over.

Well okay, there’s more to say than that: It looks lush, for example, id’s megatexture technology apparently freeing its artists to marry impressive levels of variation and detail (yes yes, noticeable even on the iPod’s diminutive screen, I admit!) Note, though, that the presence of geometric and textural variation does not guarantee thematic variety – RAGE is visually samey throughout its meagre three (yes, you read that right) episodes and that there are only a handful of enemy types will almost certainly disappoint. At least initially…

The interesting thing is, play RAGE for a little while and it soon becomes apparent that its threadbare components have been balanced with intricate care: Standard mutants (hey, at least they aren’t frigging zombies) range from quick-and-stabby to sloooow-and-wallopy, the central gameplay conceit being to prioritise the greatest threat based on where each type emerges in relation to the others. Things are spiced up by the need to reload in a timely fashion and deftly avoid any attacks that a mutant might survive long enough to make – particularly true of the stationary, distant and all-important brick throwers.

Ah yes, the brick throwers! Pelting you from afar, these guys absolutely necessitate the use of the dodge button. You could dispatch them as a priority, of course, but by keeping ‘em (or, rather, one of ‘em) alive savvy players can force the game to wait until they’re good and ready to progress, taking the time they need to collect any ammo, cash or health that may be in the area and reload their heaviest weaponry. RAGE is on-rails alright, but reactive enough to give you a measure of control over your fate… if you can avoid getting your head stoved-in in the process.

Unfortunately control is also an area where the game fumbles the ball somewhat. Sweep the view right, as you must on occasion, and you inevitably end up with your fingers obscuring the view; do likewise left and it’s not uncommon to simply run out of screen. Missing a juicy pick-up or taking a blade to the face in such circumstances is particularly galling, and it’s hard not to concede that the level design demands too wide a viewing arc in places. Add to this the unfortunate fact that the pause screen is easily triggered by accident and you’ve a game that is regularly frustrating to interact with.

But y’know what? RAGE never falls so low as to give unimaginative reviewers an excuse to use its name against it (“RAGE? It’ll certainly put you in one da-dum-tishhh” etc) and, as a hack critic, I’m disappointed at that. Or at least I would be if I weren’t too busy trying to headshot mutant scum. “Rage hard/Into the light”, as Franke Goes To Hollywood so succinctly put it, “Doing it mostly right/Doing it mostly right” [Er, did you check those lyrics? -Ed]

For the good of my Alf…

Added a big fat ‘SATIRE’ tag to the XXL?! entry as it occurred to me that that satirical targets don’t always fathom that they’re being critiqued (which was always the problem with Alf Garnett — bigots cheered him on rather than being embarrassed by their similarity to him) and because observational humour is left-field for the site. Mostly prompted by a few recent things: KATG‘s Chemda reporting that she regularly gets heckled when out with her girlfriend in Noo Yoik; the Sian Massey nonsense (don’t women have better peripheral vision than men? Shouldn’t all linesmen wear knickers?); and Helmer-the-belmer (who, admitedly, probably has turned a few women’s sexuality, just not from gay to straight) — the less support retrograde thinkers realise they have, the better, frankly.

Also, fuck you Ben Sherman. No way should my ‘XL’ guitar tee not fit.

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.)