#!/usr/bin/perl use strict; my $breite; my $y = -1; my $ye = 0; my (%h, %v, %x, %t, %V); my @a; my @as; my $pari = 1; my @formstart = ("a","e","i","m"); my $misc_items_pattern = '[/\\\]'; print << "---;"; #include "rasende.inc" ---; sub rr_int{ $_[0]eq"rot" && return 0; $_[0]eq"gruen" && return 1; $_[0]eq"blau" && return 2; $_[0]eq"gelb" && return 3; } while (<>) { chomp; if (!defined($breite)) { $breite = (length($_) - 1) / 2; print "#declare breite = $breite;\n"; print "felder()\n"; } my $zende = length($_); @a[$ye+$y+1] = [ substr($_, 2*$breite+1, $zende) ] ; # later use? @as = split(" ",substr($_, 2*$breite+1, $zende)) ; # for now only one line. if ($pari ^= 1) { $ye ++ ; for (my $x = 0; $x <= $breite; $x++) { if (substr($_, 2*$x, 1) eq "|") { $v{"$x,$y"} = 1; } my $c = substr($_, 2*$x + 1, 1); if ( $c =~ /$misc_items_pattern/ ) { my $itemarg= &rr_int( shift @as ); print "thing(" . ord($c). " ,$itemarg ,$x,$y)\n"; } else { if ($c eq "V") { $V{"$x,$y"} = 1; } else { if ($c eq "#") { $x{"$x,$y"} = 1; } else { my $fo = 0; foreach my $i (@formstart) { my $fa = ord($c) - ord($i); if ($fa >= 0 && $fa <= 3) { $t{"$x,$y"} = "$fo,$fa"; } $fo++; } } } } } } else { $y++; for (my $x = 0; $x < $breite; $x++) { if (substr($_, 2*$x + 1, 1) eq "-") { $h{"$x,$y"} = 1; } } } } for (my $x = 0; $x <= $breite; $x++) { for (my $y = 0; $y <= $breite; $y++) { my $x0 = $x - 1; my $y0 = $y - 1; if ($x{"$x0,$y"} + $x{"$x,$y"} == 1) { $v{"$x,$y"} = 1; } if ($x{"$x,$y0"} + $x{"$x,$y"} == 1) { $h{"$x,$y"} = 1; } } } # items that need argument (color): # \ / (mirrors) # + ° * · (items) # # walls that need argument: # = ¦ (coloured walls) # for (my $x = 0; $x <= $breite; $x++) { for (my $y = 0; $y <= $breite; $y++) { print "iks($x, $y)\n" if ($x{"$x,$y"}); print "vortex($x, $y)\n" if ($V{"$x,$y"}); print "trgt($x, $y, $t{qq($x,$y)})\n" if ($t{"$x,$y"}); print "h_wand($x, $y)\n" if ($h{"$x,$y"}); print "v_wand($x, $y)\n" if ($v{"$x,$y"}); #sowas hier?? #print "item_one_arg($m{"$x,$y"}, getarg(a{"$x"}), $x, $y)\n" if ($m{"$x,$y"}); # # povray and utf8? #print andere dinge? my $x0 = $x - 1; my $y0 = $y - 1; my $anz_h = $h{"$x0,$y"} + $h{"$x,$y"}; my $anz_v = $v{"$x,$y0"} + $v{"$x,$y"}; if ($anz_h == 1 && $anz_v == 1) { # Ecke print "pfosten($x, $y)\n"; } } } print << "---;"; #include "playground.inc" ---;