#-----------------------------------------------------------------------------
# Passable? method
# has been rebuilt for both collision maps and databse passability
#-----------------------------------------------------------------------------
def passable?(x, y, d = 0, self_event = nil)
# returns if coords are not on the map
return false if not valid?(x, y)
# if d is not 2, 4, 6 or 8
case d
when 0
return true
when 1
return (passable?(x, y, 2, self_event) and passable?(x, y, 4, self_event))
when 3
return (passable?(x, y, 2, self_event) and passable?(x, y, 6, self_event))
when 7
return (passable?(x, y, 8, self_event) and passable?(x, y, 4, self_event))
when 9
return (passable?(x, y, 8, self_event) and passable?(x, y, 6, self_event))
else
return false if not [2, 4, 6, 8].include?(d)
end
# loads size
if self_event == nil
x_size = y_size = 2
else
x_size = [self_event.size['x'], 2].max
y_size = [self_event.size['y'], 2].max
end
# checks pixel on collision map / in the database
counter = 0
case d
when 2
fix = y - 1
for i in (x - x_size / 2)..(x + x_size / 2 - 1)
counter += 1 if i%2 == 0 and self.pixel_passable?(i, fix, d, self_event)
end
return counter >= x_size / 2
when 4
fix = (x - x_size / 2)
for i in (y - y_size - 1)..(y - 1)
counter += 1 if i%2 == 0 and self.pixel_passable?(fix, i, d, self_event)
end
return counter >= y_size / 2
when 6
fix = (x + x_size / 2 - 1)
for i in (y - y_size - 1)..(y - 1)
counter += 1 if i%2 == 0 and self.pixel_passable?(fix, i, d, self_event)
end
return counter >= y_size / 2
when 8
fix = (y - y_size - 1)
for i in (x - x_size / 2)..(x + x_size / 2 - 1)
counter += 1 if i%2 == 0 and self.pixel_passable?(i, fix, d, self_event)
end
return counter >= x_size / 2
end