The amazing Toon-o-Matic

OK. Here we go. What we do is recurse down through the panel structure (so we're following our panels in a time-like fashion), collecting drawing objects as we go. Characters and sound effects will be completely specified as drawing primitives; text will be generated into graphic files using _maketext, and each and every object in the lot will be fully specified during this phase.
%characters = ();
@visible = ();
@visible_next = ();
$panelnumber = 0;
scan_layout ($cartoon);

sub scan_layout {
   my $panel = shift;
   See Scanning a panel for layout items
See Miscellaneous functions for doing layout
Let's define the instantiate_character subroutine:
See Instantiating a visible character
So now, just for documentation and debugging, we write our final XML out to stdout. There will (later) be a follow-on step which will generate map HTML so we can include links in our cartoons, but that'll come later.
open O, ">layout.xml";
xml_write (O, $cartoon);
print O "\n";
close O;

This code and documentation are released under the terms of the GNU license. They are additionally copyright (c) 2001, Vivtek. All rights reserved except those explicitly granted under the terms of the GNU license. This presentation prepared using LPML. Try literate programming. You'll like it.