objects/oArrowTrapRight/alarm_1.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.
oArrowTrapRight's alarm 1 event, 17 lines of GML.
if (not isRoom("rLevelEditor")){ // calculate how far to motion detect xAct = x+16; n = 100; while (not collision_point(xAct, y+8, oSolid, 0, 0) && n > 0) { if (xAct - x > 96) break; xAct += 1; n -= 1; } xAct -= (x+8); if (xAct < 32) { xAct = 32; } obj = instance_create(x+16, y, oArrowTrapTest); obj.image_xscale = ceil((xAct-16)/16); obj.trapID = id;}