… | |
… | |
8 | |
8 | |
9 | =head1 DESCRIPTION |
9 | =head1 DESCRIPTION |
10 | |
10 | |
11 | I needed something like this quickly - if you need better docs, you have to ask. |
11 | I needed something like this quickly - if you need better docs, you have to ask. |
12 | |
12 | |
13 | Supports xsb (text), rle, sokevo and a small "binpack" format for input and |
13 | Supports xsb (text), rle, sokevo and a small "binpack" format for input |
14 | output. |
14 | and output and can normalise levels as well as calculate unique IDs. |
15 | |
15 | |
16 | =over 4 |
16 | =over 4 |
17 | |
17 | |
18 | =cut |
18 | =cut |
19 | |
19 | |
… | |
… | |
22 | use common::sense; |
22 | use common::sense; |
23 | |
23 | |
24 | use Carp (); |
24 | use Carp (); |
25 | use List::Util (); |
25 | use List::Util (); |
26 | |
26 | |
27 | our $VERSION = '0.01'; |
27 | our $VERSION = '0.02'; |
28 | |
28 | |
29 | =item $level = new Games::Sokoban [format => "text|binpack"], [data => "###..."] |
29 | =item $level = new Games::Sokoban [format => "text|rle|binpack"], [data => "###..."] |
30 | |
30 | |
31 | =cut |
31 | =cut |
32 | |
32 | |
33 | sub new { |
33 | sub new { |
34 | my ($class, %arg) = @_; |
34 | my ($class, %arg) = @_; |
… | |
… | |
205 | |
205 | |
206 | sub as_lines { |
206 | sub as_lines { |
207 | split /\n/, $_[0]{data} |
207 | split /\n/, $_[0]{data} |
208 | } |
208 | } |
209 | |
209 | |
210 | =item @lines = $level->as_rle |
210 | =item $line = $level->as_rle |
211 | |
211 | |
212 | http://www.sokobano.de/wiki/index.php?title=Level_format |
212 | http://www.sokobano.de/wiki/index.php?title=Level_format |
213 | |
213 | |
214 | =cut |
214 | =cut |
215 | |
215 | |
… | |
… | |
222 | |
222 | |
223 | $data |
223 | $data |
224 | } |
224 | } |
225 | |
225 | |
226 | =item ($x, $y) = $level->start |
226 | =item ($x, $y) = $level->start |
|
|
227 | |
|
|
228 | Returns (0-based) starting coordinate. |
227 | |
229 | |
228 | =cut |
230 | =cut |
229 | |
231 | |
230 | sub start { |
232 | sub start { |
231 | my ($self) = @_; |
233 | my ($self) = @_; |