Oh, I forgot to mention one last fundamental difference between subroutines, functions, and tasks. Functions are the ONLY ones that can return values. For example:
function GetDistance(x1, y1, x2, y2){
return ((x1-x2)^2+(y1-y2)^2)^0.5;
}
Then, you can do let distanceToPlayer = GetDistance(GetX, GetY, GetPlayerX, GetPlayerY); and the variable will now hold the value that was returned. Of course you can also do stuff like this:
function ObjShot_Create(x, y, speed, angle, graphic, delay){
let obj = Obj_Create(OBJ_SHOT);
Obj_SetPosition(obj, x, y);
Obj_SetSpeed(obj, speed);
Obj_SetAngle(obj, angle);
ObjShot_SetGraphic(obj, graphic);
ObjShot_SetDelay(obj, delay);
return obj;
}
And then you can go let obj = ObjShot_Create(GetX, GetY, 3, GetAngleToPlayer, RED01, 10); so that you don't have to type out the individual Obj_SetStuff functions every time.