From 9642939f992ddff40f3c7dc635889f396bd0ae04 Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Sat, 21 May 2011 15:51:21 +0700 Subject: [PATCH] introduce move_1_step and pass --- star.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/star.rb b/star.rb index dee272f..6d1f0fb 100644 --- a/star.rb +++ b/star.rb @@ -289,7 +289,16 @@ class Star end 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 def move( direction, objectToMove )