introduce move_1_step and pass

This commit is contained in:
Gwenhael Le Moine 2011-05-21 15:51:21 +07:00
parent a9eba6657c
commit 9642939f99

View file

@ -289,7 +289,16 @@ class Star
end end
def move_1_step( direction, objectToMove) def move_1_step( direction, objectToMove)
d = { :h => 0, :v => 0 }
d[ :h ] = -1 if direction == :left
d[ :h ] = 1 if direction == :right
d[ :v ] = -1 if direction == :up
d[ :v ] = 1 if direction == :down
new_x = @positions[ objectToMove ][ :x ] + d[ :h ]
new_y = @positions[ objectToMove ][ :y ] + d[ :v ]
@positions[ objectToMove ][ :x ] = new_x
@positions[ objectToMove ][ :y ] = new_y
end end
def move( direction, objectToMove ) def move( direction, objectToMove )