xLinesUp = object1Left <= object2Right && object1Right >= object2Left
yLinesUp = object1Top <= object2Bottom && object1Bottom >= object2Top
objectsTouching = xLinesUp && yLinesUp
Use the arrow keys to move object 1. The objects will turn green when they touch.