1#!/usr/bin/perl 2 3#Author: David Lawrence - philaw@ozemail.com.au 4#Merges the images together to make a composite image for the game XTux. 5#Usage: "merge_images.pl ENTITY DIRECTIONS" 6 7die "Usage $0: ENTITY_NAME DIRECTIONS" unless @ARGV == 2; 8 9$name = @ARGV[0]; 10$num = @ARGV[1]; 11 12@dir = ( "n", "ne", "e", "se", "s", "sw", "w", "nw" ); 13 14sub do_dir { 15 my $dir = @_[0]; 16 my @cmdline; 17 18 for( $i=0 ; $i < $num ; $i++ ) { 19 push @cmdline, sprintf "%s_%s_%d.xpm", $name, $dir, $i; 20 } 21 22 print "\"$dir\": [ @cmdline ]\n"; 23 system("convert +append @cmdline $dir"); 24 25} 26 27#Make files for each direction of all the frames stacked horizontally. 28foreach $d ( @dir ) { 29 do_dir( $d ); 30} 31 32#Join them all together into one big file. 33print "Appending @dir\n"; 34system("convert -append @dir $name.xpm"); 35 36