Skip to content

Commit

Permalink
Minor cleanup using parallel assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
benlangfeld committed Nov 13, 2011
1 parent 4477eab commit 2cae6d7
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions sokoban.rb
Expand Up @@ -143,27 +143,15 @@ def object_at(x, y)
end

def move(command)
case command
x1, y1, x2, y2 = case command
when 'w'
x1 = @x - 1
y1 = @y
x2 = @x - 2
y2 = @y
[@x - 1, @y, @x - 2, @y]
when 's'
x1 = @x + 1
y1 = @y
x2 = @x + 2
y2 = @y
[@x + 1, @y, @x + 2, @y]
when 'a'
x1 = @x
y1 = @y - 1
x2 = @x
y2 = @y - 2
[@x, @y - 1, @x, @y - 2]
when 'd'
x1 = @x
y1 = @y + 1
x2 = @x
y2 = @y + 2
[@x, @y + 1, @x, @y + 2]
when 'q'
throw :quit
else
Expand Down

0 comments on commit 2cae6d7

Please sign in to comment.