line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# SVG maze output |
2
|
|
|
|
|
|
|
# Performs transformation, cleanup, and printing of output of Games::Maze |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Games::Maze::SVG::RectHex; |
5
|
|
|
|
|
|
|
|
6
|
28
|
|
|
28
|
|
173
|
use base Games::Maze::SVG::HexCells; |
|
28
|
|
|
|
|
47
|
|
|
28
|
|
|
|
|
51026
|
|
7
|
|
|
|
|
|
|
|
8
|
28
|
|
|
28
|
|
398
|
use Carp; |
|
28
|
|
|
|
|
174
|
|
|
28
|
|
|
|
|
2781
|
|
9
|
28
|
|
|
28
|
|
162
|
use Games::Maze; |
|
28
|
|
|
|
|
66
|
|
|
28
|
|
|
|
|
624
|
|
10
|
28
|
|
|
28
|
|
148
|
use strict; |
|
28
|
|
|
|
|
48
|
|
|
28
|
|
|
|
|
1190
|
|
11
|
28
|
|
|
28
|
|
153
|
use warnings; |
|
28
|
|
|
|
|
208
|
|
|
28
|
|
|
|
|
13773
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Games::Maze::SVG::RectHex - Build rectangular mazes with hexagonal cells in SVG. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 VERSION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Version 0.80 |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = 0.80; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 SYNOPSIS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Games::Maze::SVG::RectHex uses the Games::Maze module to create mazes in SVG. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
use Games::Maze::SVG; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my $foo = Games::Maze::SVG->new( 'RectHex' ); |
32
|
|
|
|
|
|
|
... |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 FUNCTIONS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# ---------------------------------------------- |
39
|
|
|
|
|
|
|
# Subroutines |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=over 4 |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=item new |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Create a new Games::Maze::SVG object. Supports the following named parameters: |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Takes one positional parameter that is the maze type: Rect, RectHex, or Hex |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=over 4 |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=item wallform |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
String naming the wall format. Legal values are bevel, round, roundcorners, |
54
|
|
|
|
|
|
|
and straight. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item crumb |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
String describing the breadcrumb design. Legal values are dash, |
59
|
|
|
|
|
|
|
dot, line, and none |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=item dx |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
The size of the tiles in the X direction. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item dy |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
The size of the tiles in the Y direction. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item dir |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Directory in which to find the ecmascript for the maze interactivity. Should |
72
|
|
|
|
|
|
|
either be relative, or in URL form. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=back |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub new |
79
|
|
|
|
|
|
|
{ |
80
|
8
|
|
|
8
|
1
|
21
|
my $class = shift; |
81
|
|
|
|
|
|
|
|
82
|
8
|
|
|
|
|
91
|
my $obj = Games::Maze::SVG::HexCells->new( @_ ); |
83
|
7
|
|
|
|
|
85
|
$obj->{mazeparms}->{form} = 'Rectangle'; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# rebless into this class. |
86
|
7
|
|
|
|
|
43
|
return bless $obj, $class; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item is_hex |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Method returns true. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub is_hex |
97
|
|
|
|
|
|
|
{ |
98
|
1
|
|
|
1
|
1
|
2642
|
return 1; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item is_hex_shaped |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Method returns false. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub is_hex_shaped |
109
|
|
|
|
|
|
|
{ |
110
|
1
|
|
|
1
|
1
|
7
|
return; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item convert_sign_position |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Convert the supplied x and y coordinates into the appropriate real coordinates |
117
|
|
|
|
|
|
|
for a the position of the exit sign. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=over 4 |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item $x x coord from the maze |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item $y y coord from the maze |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=back |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
returns a two element list containing (x, y). |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub convert_sign_position |
132
|
|
|
|
|
|
|
{ |
133
|
4
|
|
|
4
|
1
|
3175
|
my $self = shift; |
134
|
4
|
|
|
|
|
9
|
my ($x, $y) = @_; |
135
|
|
|
|
|
|
|
|
136
|
4
|
|
|
|
|
20
|
$x *= $self->dx(); |
137
|
4
|
|
|
|
|
11
|
$y *= $self->dy(); |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# adjust bottom |
140
|
4
|
100
|
|
|
|
15
|
if($y > $self->{height}/2) |
141
|
|
|
|
|
|
|
{ |
142
|
2
|
|
|
|
|
10
|
$y += 2*$self->dy(); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
else |
145
|
|
|
|
|
|
|
{ |
146
|
2
|
|
|
|
|
7
|
$y -= $self->dy(); |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
4
|
|
|
|
|
13
|
return ($x, $y); |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=back |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 AUTHOR |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
G. Wade Johnson, C<< >> |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 BUGS |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
161
|
|
|
|
|
|
|
C, or through the web interface at |
162
|
|
|
|
|
|
|
L. |
163
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
164
|
|
|
|
|
|
|
your bug as I make changes. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Thanks go to Valen Johnson and Jason Wood for extensive test play of the |
169
|
|
|
|
|
|
|
mazes. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Copyright 2004-2006 G. Wade Johnson, all rights reserved. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
176
|
|
|
|
|
|
|
under the same terms as Perl itself. |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=cut |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
1; |