// colliding retangles ax = rectangleA.X ay = rectangleA.Y aw = rectangleA.width ah = rectangleA.height bx = rectangleB.X by = rectangleB.Y bw = rectangleB.width bh = rectangleB.height xc = false yc = false if ( ax >= bx ){ if ( ax < bx+bw ){ xc = true } }else{ if (bx < ax+aw){ xc = true } } if (ay >= by){ if (ay < by+bh){ yc = true } }else{ if (by < ay+ah){ yc = true } } if (xc and yc){ colliding = true }else{ colliding = flase }