… | |
… | |
163 | "$self->{data}\n" |
163 | "$self->{data}\n" |
164 | } |
164 | } |
165 | |
165 | |
166 | =item $binary = $level->as_binpack |
166 | =item $binary = $level->as_binpack |
167 | |
167 | |
|
|
168 | Binpack is a very compact binary format (usually 17% of the size of an xsb |
|
|
169 | file), that is still reasonably easy to encode/decode. |
|
|
170 | |
|
|
171 | It only tries to store simplified levels with full fidelity - other levels |
|
|
172 | can be slightly changed outside the playable area. |
|
|
173 | |
168 | =cut |
174 | =cut |
169 | |
175 | |
170 | sub as_binpack { |
176 | sub as_binpack { |
171 | my ($self) = @_; |
177 | my ($self) = @_; |
172 | |
178 | |
… | |
… | |
402 | while (<$fh>) { |
408 | while (<$fh>) { |
403 | $data .= $_; |
409 | $data .= $_; |
404 | last if /^$/; |
410 | last if /^$/; |
405 | } |
411 | } |
406 | |
412 | |
|
|
413 | # sokevo internally locks some cells |
|
|
414 | $data =~ y/^%:,;-=?/ #.$* +#/; |
|
|
415 | |
407 | push @levels, new Games::Sokoban data => $data; |
416 | push @levels, new Games::Sokoban data => $data; |
408 | } |
417 | } |
409 | } |
418 | } |
410 | |
419 | |
411 | \@levels |
420 | \@levels |