erkyrath/glkote — pull request #1 by eevee (2014-09-20 01:47:00+00:00)
Title: Implement graphics and sound.

There are some quixe pieces, too, and I'm also sending a pull for those.

I basically took what was there and ran with it. :) I had to expose DOM objects directly to glkote; otherwise `glk_image_get_info` can't work and sound won't play instantly as the spec demands. So this isn't going to work too well with RemGlk, but offhand I'm not sure how it could.

Lingering problems:

* There's no deletion of images — by which I mean `` elements. If a story does lots of fancy image drawing, the images will just keep stacking up on top of each other, and the browser will probably start to get sad. Solving this is a tricky problem, since I'm working with discrete images rather than blitting onto a surface. I think the only options are to keep track of the position of every image and remove older images once I know they've been completely drawn over, _or_ give up on this approach and just blit to a ``.

* Resizing doesn't clip/extend as the spec demands; it just throws away the entire contents of the graphics window. Again, this would be a massive pain to implement with a pile of ``s, but pretty easy with a ``.

* Floated images inside blockquotes don't quite work correctly, because the image itself isn't styled as a blockquote. But really, the blockquote style should be "hoisted" up to the entire paragraph, since it doesn't make sense to blockquote only part of a line.

* Occasionally, it seems that an image's height and width are reported as zero, and I'm not sure why. It only happens when playing over the web, and is always fixed by refreshing. I assume something's trying to read the size of the image before it's been fully decoded by the browser, but that decoding should start while the game itself is being compiled, and should only take a moment. Yet I've had issues even when many minutes pass before the game tries to show an image.

* I'm pretty sure there are some poor interactions between pausing and looping a finite number of times.

* Vorbis isn't supported; there's native browser support for it (well, not in IE or Safari), but the decoding API is asynchronous, and I haven't yet figured out how to easily make the loading screen wait on it to finish.

* MOD isn't supported at all. There are some (impressive!) JavaScript libraries that can play MOD

* Sound event notification isn't implemented.

But, you know, other than all that...!

Demo with `sensory.gblorb` here: http://stuff.veekun.com/quixe-demo/play-test.html

(I wrote that stylesheet on a whim; it's not included in the quixe PR (yet?), but one nice thing about it is that I split up the "do not touch" structural styles from the customizable ones.)