scripts/isCollisionRectangle.gml
From spelunky.gmk, Spelunky Classic 1.1's source, © 2008, 2009 Derek Yu and Mossmouth, LLC, shown whole under the Spelunky User License v1.1b. Extracted by spelunky.ai's tools, an unofficial fan project, one file per script or event; the // ==== lines are the extractor's, naming each action of the event. Some scripts are others' work that Derek Yu credits in the source's readme.txt: Martin Piecyk's platform engine, ChevyRay's view scaling scripts and tsg1zzn's Super Sound System.
The script isCollisionRectangle, 24 lines of GML.
/*Returns whether there is a collision with two rectangles.Note that the rectangles cannot have a negative width or height.0: x1 (of the first rectangle)1: y12: x23: y24: x1 (of the second rectangle)5: y16: x27: y2return whether there was a collision*/w1=argument2-argument0h1=argument3-argument1w2=argument6-argument4h2=argument7-argument5if(w2<=0 or h2<=0 or w1<=0 or h1<=0) return 0w2+=argument4h2+=argument5w1+=argument0h1+=argument1return (w2<argument4 or w2>argument0) and (h2<argument5 or h2>argument1) and (w1<argument0 or w1>argument4) and (h1<argument1 or h1>argument5)