Cathode Tan - Games, Media and Geek Stuff
logo design by man bytes blog

Tuesday, July 25, 2006

Canvas Tag Speed Run

This is probably largely a confession on how much more likely I am to toy with technology than actually utilize. In playing with the Torque Game Builder this afternoon, I was compelled to play with the HTML canvas tag ... which will sound to most as a kind of folly. And indeed, it probably is. TGB is mature code based on production worthy C++ and the canvas tag was mostly designed for web widgets and graphs.

But to paraphrase Crow T. Robot, I did all the calculations and decided to go with it anyway. My biggest concern with using a browser is performance. I've long bemoaned plugin tech as a reasonable game platform because it's inefficent in terms of speed - you have an engine within an engine within a platform. Compare that to your average native game which at least tries to set aside most of it's resources to your goal and you can guess the difference. My only defense is that I'm hoping a structured tag within a browser beats that back a few layers.

Does it work? Well, this is a quick initial test with a dynamic number of objects running at a dynamic speed (with no other physics, collision or other game related code running, obviously). Of note is: 1) the browser will set aside space for an initial max number. This is currently 150. So if you hit 151, you'll notice a quick slowdown. But this is fixed by raising the initial number. 2) In Safari at least, event handling itself will proceed the entire performance of the canvas tag. Each button click is a pause.

Part of this is certainly a part of me just drawn to what I know. I know web tech. Really, really well. Can you make a decent couch-coop arcade game with it?

Honestly, I don't really know.

EDIT: Oh right, you'll need recent versions of FireFox or Safari to make this work. I'm going to test Opera in a bit, in a hope against hope that the DS will become a gaming browser of sorts. Internet Explorer? Look, Microsoft is at least a generation behind at this point. Trust me when I say that IE7 can't come fast enough for you lot loyal to browser. It's way past due.

And: Opera's not pretty. Doesn't like to add new objects. It's pretty much OK with the brief beta of the card-based fiction I've got running though, and I was mostly hoping that would work with the DS anyway. If I can do arcade in Safari/Firefox and IF in DS Opera ... I'll be happy.

tagged: ,


Greg Tannahill said...

That seems to work alright in Firefox. (Something that tells me I suck if it sees me using IE would be nice, though - took me a minute to work out my browser woes). While we're on the subject, by the way, why does Cathode Tan take about three times as long to load as every other blog I visit? Is it a slow self-hosted server or some other idiosyncracy?

Josh said...

Yeah, it's constantly trying to load the canvas element, so I'd imagine it might be kinda brutal to IE. If I got anything closer to "production", I would keep that in mind.

Speedwise - CT is probably hindered by the various hosting it uses. Blogspot, zoomclouds, feedburner, etc. All shared hosting, mind you.

I've never carefully examined the stock template I've been bastardizing all this time, mind you, I could poke it at for some efficiencies.

Josh said...

It's pokey on my G4 at work, though not on the average-box Dell.