2048: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: refactor a bit, style tweaks) |
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: some more refactoring, DRY) |
||
Line 1,805:
multi sub squash ('left', @c) {
my @
@tiles.push: '' while @tiles < 4;▼
@
}
multi sub squash ('right', @c) {
my @
@tiles.unshift: '' while @tiles < 4;▼
@
reverse @t;
}
Line 1,819 ⟶ 1,823:
multi sub move('up') {
▲ combine(@col[$x], @col[$x+1]) if @col[$x] && @col[$x+1] == @col[$x]
▲ @board[*]»[$y] = squash left, @col;
▲ }
}
multi sub move('down') {
▲ @board[*]»[$y] = squash right, @col;
}
multi sub move('left') {
▲ my @row = squash left, flat @board[$y]»[*];
▲ combine(@row[$x], @row[$x+1]) if @row[$x] && @row[$x+1] == @row[$x]
@board[$y] = squash left, @row;▼
}
multi sub move('right') {
}
|