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