checkCollisionH (r:rs) origX p@(Player _ (dx,dy) a i)
    | r `collides` (x .~ origX $ p^.bounding) = if r^.x - origX > 0
        then if (p^.bounding.x + p^.velocity._1) < (r^.x - p^.bounding.width - 1) then ((bounding.x .~ (r^.x - p^.bounding.width - 1)) $ p) else p
        else if (p^.bounding.x + p^.velocity._1) > (r^.x - p^.bounding.width - 1) then ((bounding.x .~ (r^.x + r^.width + 1)) $ p) else p
    | p^.velocity._1 == 0 = p
    | p^.velocity._1 > 0 = if r `collides` ((x .~ origX) . (width .~ (p^.bounding.x - origX + p^.bounding.width)) $ p^.bounding)
        then bounding.x .~ (r^.x - p^.bounding.width - 1) $ p
        else checkCollisionH rs origX p
    | otherwise = if r `collides` (width .~ (origX - p^.bounding.x) $ p^.bounding)
        then (bounding.x .~ r^.x + r^.width + 1) $ p
        else checkCollisionH rs origX p
checkCollisionH (r:rs) origX p@(Player _ (dx,dy) a i)
    | r `collides` (x .~ origX $ p^.bounding) = if r^.x - origX > 0
        then if (p^.bounding.x + p^.velocity._1) < (r^.x - p^.bounding.width - 1) then ((bounding.x .~ (r^.x - p^.bounding.width - 1)) $ p) else p
        else if (p^.bounding.x + p^.velocity._1) > (r^.x - p^.bounding.width - 1) then ((bounding.x .~ (r^.x + r^.width + 1)) $ p) else p
    | p^.velocity._1 == 0 = p
    | p^.velocity._1 > 0 = if r `collides` ((x .~ origX) . (width .~ (p^.bounding.x - origX + p^.bounding.width)) $ p^.bounding)
        then bounding.x .~ (r^.x - p^.bounding.width - 1) $ p
        else checkCollisionH rs origX p
    | otherwise = if r `collides` (width .~ (origX - p^.bounding.x) $ p^.bounding)
        then (bounding.x .~ r^.x + r^.width + 1) $ p
        else checkCollisionH rs origX p
checkCollisionH (r:rs) origX p@(Player _ (dx,dy) a i)
    | r `collides` (x .~ origX $ p^.bounding) = if r^.x - origX > 0
        then if (p^.bounding.x + p^.velocity._1) < (r^.x - p^.bounding.width - 1) then ((bounding.x .~ (r^.x - p^.bounding.width - 1)) $ p) else p
        else if (p^.bounding.x + p^.velocity._1) > (r^.x - p^.bounding.width - 1) then ((bounding.x .~ (r^.x + r^.width + 1)) $ p) else p
    | p^.velocity._1 == 0 = p
    | p^.velocity._1 > 0 = if r `collides` ((x .~ origX) . (width .~ (p^.bounding.x - origX + p^.bounding.width)) $ p^.bounding)
        then bounding.x .~ (r^.x - p^.bounding.width - 1) $ p
        else checkCollisionH rs origX p
    | otherwise = if r `collides` (width .~ (origX - p^.bounding.x) $ p^.bounding)
        then (bounding.x .~ r^.x + r^.width + 1) $ p
        else checkCollisionH rs origX p