SpelunkyFan wiki

objects/oGhost/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.

oGhost's step event, 28 lines of GML.

if (hp < 1){    //global.bats += 1;    global.kills += 1;    instance_destroy();}dir = 0;dist = point_distance(x+8, y+8, oCharacter.x, oCharacter.y);if (status == IDLE){    // do nothing}else if (status == ATTACK){    dir = point_direction(x+8, y+8, oCharacter.x, oCharacter.y)    x += 1 * cos(degtorad(dir));    y += -1 * sin(degtorad(dir));    if (oCharacter.x < x+8)    {        if (sprite_index == sGhostRight) sprite_index = sGhostTurnLeft;    }    else    {        if (sprite_index == sGhostLeft) sprite_index = sGhostTurnRight;    }}