module Bitmapped::Commands::CommandsHelper

Public Instance Methods

coordinates_to_array_indexes(bitmap, x, y) click to toggle source
# File lib/bitmapped/commands/commands_helper.rb, line 14
def coordinates_to_array_indexes(bitmap, x, y)
  x = x.to_i - 1
  y = y.to_i - 1
  if valid_cooridinates(bitmap, x, y)
    [x, y]
  else
    raise InvalidCoordinatesError
  end
end
valid_cooridinates(bitmap, x, y) click to toggle source
# File lib/bitmapped/commands/commands_helper.rb, line 6
def valid_cooridinates(bitmap, x, y)
  if (0 <= x && x <= bitmap.columns) && (0 <= y && y <= bitmap.rows)
    true
  else
    false
  end
end