count distance. not moves

This commit is contained in:
Gwenhael Le Moine 2011-07-06 16:32:11 +02:00
parent 250752603a
commit df26d55ad4

View file

@ -265,7 +265,7 @@ class Star
} }
@counters = { @counters = {
:gifts => 0, :gifts => 0,
:moves => 0, :distance => 0,
} }
@level = { @level = {
:width => 16, :width => 16,
@ -335,7 +335,7 @@ class Star
@positions[ objectToMove][ :y ] = newpos[ :y ] @positions[ objectToMove][ :y ] = newpos[ :y ]
@board[ @positions[ objectToMove][ :y ] ][ @positions[ objectToMove][ :x ] ] = objectToMove == :ball ? 'B' : 'C' @board[ @positions[ objectToMove][ :y ] ][ @positions[ objectToMove][ :x ] ] = objectToMove == :ball ? 'B' : 'C'
@counters[ :moves ] = @counters[ :moves ] + 1 @counters[ :distance ] = @counters[ :distance ] + 1
end end
end end
@ -382,7 +382,7 @@ class Star
s = @elements[ 'G' ][ :text ] + ":" + @counters[ :gifts ].to_s + " " s = @elements[ 'G' ][ :text ] + ":" + @counters[ :gifts ].to_s + " "
s = s + @elements[ 'B' ][ :text ] + ":(" + @positions[ :ball ][ :x ].to_s + "," + @positions[ :ball ][ :y ].to_s + ") " s = s + @elements[ 'B' ][ :text ] + ":(" + @positions[ :ball ][ :x ].to_s + "," + @positions[ :ball ][ :y ].to_s + ") "
s = s + @elements[ 'C' ][ :text ] + ":(" + @positions[ :cube ][ :x ].to_s + "," + @positions[ :cube ][ :y ].to_s + ") " s = s + @elements[ 'C' ][ :text ] + ":(" + @positions[ :cube ][ :x ].to_s + "," + @positions[ :cube ][ :y ].to_s + ") "
s = s + "m:" + @counters[ :moves ].to_s + "\n" s = s + "m:" + @counters[ :distance ].to_s + "\n"
@level[ :height ].times do @level[ :height ].times do
|y| |y|
@level[ :width ].times do @level[ :width ].times do