lib/rectangle.rb
# Returns 0 if no collision, or (X,Y) where collision will occur
Returns 0 if no collision, or (X,Y) where collision will occur
Returns 0 if no collision or ( X Y ) where collision will occur
def horizontalCollision?(bx, by, dx, dy)
      sx = dx - bx   
      sy = dy - by   
      coor = intersection(@x, @y, 0, @height, bx, by, sx, sy)
      return coor if coor.is_a?(Array)
      return intersection(@x+@width, @y, 0, @height, bx, by, sx, sy)
    end
def horizontalCollision? ( bx , by , dx , dy ) sx = dx - bx sy = dy - by coor = intersection ( @x , @y , 0 , @height , bx , by , sx , sy ) return coor if coor . is_a? ( Array ) return intersection ( @x + @width , @y , 0 , @height , bx , by , sx , sy ) end
Returns 0 if no collision, or (X,Y) where collision will occur
Returns 0 if no collision or ( X Y ) where collision will occur
#p4.x - p3.x #p4.y - p3.y #left #right
bx
by
dx
dy