1 |
function scr_sort_by_distancescr_sort_by_distancefunction scr_sort_by_distance(arg0, arg1, arg2, arg3)
{
var _array = arg2;
var _ascending = arg3;
var _array_length = array_length_1d(arg0);
var _distance_array;
for (i = 0; i < _array_length; i++)
_distance_array[i] = point_distance(arg0, arg1, _array[i].x, _array[i].y);
var _tempValue = 0;
var _loopAgain = true;
var _emergencyStop = 0;
while (_loopAgain == true && _emergencyStop < 100)
{
_loopAgain = false;
_emergencyStop++;
for (i = 1; i < _array_length; i++)
{
if (_distance_array[i] == _distance_array[i - 1])
{
continue;
}
else if (_ascending == (_distance_array[i] < _distance_array[i - 1]))
{
_loopAgain = true;
_tempValue = _distance_array[i - 1];
_distance_array[i - 1] = _distance_array[i];
_distance_array[i] = _tempValue;
_tempValue = _array[i - 1];
_array[i - 1] = _array[i];
_array[i] = _tempValue;
}
}
}
if (_emergencyStop >= 100)
scr_debug_print("");
return _array;
} (arg0, arg1, arg2, arg3) |
35 |
scr_debug_printscr_debug_printfunction scr_debug_print(arg0)
{
if (! scr_debug())
exit;
if (!instance_exists(obj_debug_gui))
{
instance_create(__view_get(e__VW.XView, 0) + 10, __view_get(e__VW.YView, 0) + 10, obj_debug_gui);
obj_debug_gui.depth = -9999;
}
obj_debug_gui.newtext = arg0;
with (obj_debug_gui)
{
message[messagecount] = newtext;
newtext = "";
timer[messagecount] = 90 - totaltimer;
totaltimer += timer[messagecount];
messagecount++;
debugmessage = message[0];
for (i = 1; i < messagecount; i++)
debugmessage += ("#" + message[i]);
}
}
enum e__VW
{
XView,
YView,
WView,
HView,
Angle,
HBorder,
VBorder,
HSpeed,
VSpeed,
Object,
Visible,
XPort,
YPort,
WPort,
HPort,
Camera,
SurfaceID
} (""); |