Snake_regrets
I should have used a Struct to translate between pixel positions and the grid.
Point = Struct.new(:x, :y) {
def screen = ( [x*8, y*8] )
def self.screen(x, y) = ( [x*8, y*8] )
def grid = ( [x/8, y/8] )
def self.grid(x, y) = ( [x/8, y/8] )
def grid_diff = ( [(x/8*8) - x, (y/8*8) - y] )
def self.grid_diff(x, y) = ( [(x/8*8) - x, (y/8*8) - y] )
}
or maybe this is better..
Point = Struct.new(:x, :y) {
def screen = ( self.x, self.y = x*8, y*8 )
def grid = ( self.x, self.y = x/8, y/8 )
}