objects/oTarget/step.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.
oTarget's step event, 40 lines of GML.
if (dying){ if (life > 0) life -= 1; else { life = 20; dying = false; }}else{ if (dir == UP) { if (hard) y -= 2; else y -= 1; moveOff += 1; if (y <= 64 or moveOff > 64) { dir = DOWN; moveOff = 0; } } else if (dir == DOWN) { if (hard) y += 2; else y += 1; moveOff += 1; if (y >= 160 or moveOff > 64) { dir = UP; moveOff = 0; } } if (oMoonRoom.timer <= 30) { x = 240 - abs(sin(xDiff)*64); xDiff += 0.01; }}