GMS Scripts

[important]:if a script has a variable (zmd) refer to first script in week 3

week 1

///scr_draw_circle_outline(x,y,radius,thickness,resolution,rotation,colour)
var i=0;
draw_primitive_begin(pr_trianglestrip);
for(i=0;i<argument[4];i++)
{
    draw_vertex_colour(
        argument[0]+lengthdir_x(argument[2],360/argument[4]*i+argument[5]),
        argument[1]+lengthdir_y(argument[2],360/argument[4]*i+argument[5]),
        argument[6],1
    )
    draw_vertex_colour(
        argument[0]+lengthdir_x(argument[2]+argument[3],360/argument[4]*i+argument[5]),
        argument[1]+lengthdir_y(argument[2]+argument[3],360/argument[4]*i+argument[5]),
        argument[6],1
    )
}
draw_vertex_colour(
    argument[0]+lengthdir_x(argument[2],argument[5]),
    argument[1]+lengthdir_y(argument[2],argument[5]),
    argument[6],1
)
draw_vertex_colour(
    argument[0]+lengthdir_x(argument[2]+argument[3],argument[5]),
    argument[1]+lengthdir_y(argument[2]+argument[3],argument[5]),
    argument[6],1
)
draw_primitive_end();

///scr_draw_circle(x,y,radius,resolution,rotation,colour,filled)
var i=0;
draw_primitive_begin(pr_trianglefan);
if argument[6] == true{
    draw_vertex_colour(argument[0],argument[1],argument[5],1)
}
for(i=0;i<argument[3];i++)
{
    if argument[6] == true{
        
        draw_vertex_colour(
        argument[0]+lengthdir_x(argument[2],360/argument[3]*i+argument[4]),
        argument[1]+lengthdir_y(argument[2],360/argument[3]*i+argument[4]),
        argument[5],1
        )
        
    } else {
    draw_line_colour(
        argument[0]-1+lengthdir_x(argument[2],360/argument[3]*(i+1)+argument[4]),
        argument[1]-1+lengthdir_y(argument[2],360/argument[3]*(i+1)+argument[4]),
        argument[0]-1+lengthdir_x(argument[2],360/argument[3]*i+argument[4]),
        argument[1]-1+lengthdir_y(argument[2],360/argument[3]*i+argument[4]),
        argument[5],argument[5])
    }
}
if argument[6] == true{
    draw_vertex_colour(
        argument[0]+lengthdir_x(argument[2],argument[4]),
        argument[1]+lengthdir_y(argument[2],argument[4]),
        argument[5],1
        )
}
draw_primitive_end();

week 2

///scr_draw_ants_line(x1,y1,x2,y2,antlength,spacing,width,speed,color)

var pdist=point_distance(argument0,argument1,argument2,argument3);
var pdir=point_direction(argument0,argument1,argument2,argument3);
var antlength=argument4;
var spacing=argument5;
var color=argument8;
var lenspa=(antlength+spacing);
var mcheck=(lenspa-spacing)*.5
var acheck=(lenspa+spacing)*.5
var timelength=(current_time * argument7) mod lenspa;
var tlx=lengthdir_x(timelength,pdir);
var tly=lengthdir_y(timelength,pdir);
var lespx=lengthdir_x(lenspa,pdir);
var lespy=lengthdir_y(lenspa,pdir);
var lex=lengthdir_x(antlength,pdir);
var ley=lengthdir_y(antlength,pdir);

var i;
for (i=0;i<(pdist/(lenspa)-1);i++){        
    if (timelengthacheck){
        draw_line_width_colour(
            argument0+lespx*i,
            argument1+lespy*i,
            argument0+lespx*i+tlx+lex*.5-lespx,
            argument1+lespy*i+tly+ley*.5-lespy,
            argument6,color,color
        )
        draw_line_width_colour(
            argument0+lespx*i+tlx-lex*.5,
            argument1+lespy*i+tly-ley*.5,
            argument0+lespx*i+lespx,
            argument1+lespy*i+lespy,
            argument6,color,color
        )
    } else {
        draw_line_width_colour(
            argument0+lespx*i+tlx-lex*.5,
            argument1+lespy*i+tly-ley*.5,
            argument0+lespx*i+lex+tlx-lex*.5,
            argument1+lespy*i+ley+tly-ley*.5,
            argument6,color,color
        )
    }
}

week 3

//throw this in a control object's create event
globalvar va, zmd;

//throw this in your control object's step event
if (view_angle[0]>0)
then va=view_angle[0] mod 360;
else va=360+view_angle[0] mod 360;
zmd=-va+90;

///scr_view_center(view_index)
//returns an array
//keep in mind view_xview and view_yview don't change when view is rotated ㋛
mv[0] = view_xview[argument0]+view_wview[0]/2;
mv[1] = view_yview[argument0]+view_hview[0]/2;
return mv;

///scr_xplane(sprite_index, image_index, xo, yo, zo, lr)
var ldirx = lengthdir_x(argument4, zmd);
var ldiry = lengthdir_y(argument4, zmd);
var sgw = sprite_get_width(argument0);
var sgh = sprite_get_height(argument0);
var ldirxsprheight = lengthdir_x(sgh, zmd);
var ldirysprheight = lengthdir_y(sgh, zmd);
var xa = x + argument2;
var ya = y + argument3;

var x1 = xa + ldirx;
var y1 = ya + ldiry;
var x2 = xa + ldirx;
var y2 = ya + ldiry + sgw;
var x3 = xa + ldirx - ldirxsprheight;
var y3 = ya + ldiry - ldirysprheight + sgw;
var x4 = xa + ldirx - ldirxsprheight;
var y4 = ya + ldiry - ldirysprheight;

if argument5 == "r" and (va >= 0 and va < 180)
then draw_sprite_pos(argument0, argument1, x1, y1, x2, y2, x3, y3, x4, y4, 1);
else if argument5 == "l" and (va = 180)
then draw_sprite_pos(argument0, argument1, x2, y2, x1, y1, x4, y4, x3, y3, 1);
else if argument5 == "b"
then draw_sprite_pos(argument0, argument1, x1, y1, x2, y2, x3, y3, x4, y4, 1);

///scr_yplane(sprite_index, image_index, xo, yo, zo, ud)
var ldirx = lengthdir_x(argument4, zmd);
var ldiry = lengthdir_y(argument4, zmd);
var sgw = sprite_get_width(argument0);
var sgh = sprite_get_height(argument0);
var ldirxsprheight = lengthdir_x(sgh, zmd);
var ldirysprheight = lengthdir_y(sgh, zmd);
var xa = x + argument2;
var ya = y + argument3;

var x1 = xa + ldirx;
var y1 = ya + ldiry;
var x2 = xa + ldirx + sgw;
var y2 = ya + ldiry;
var x3 = xa + ldirx - ldirxsprheight + sgw;
var y3 = ya + ldiry - ldirysprheight;
var x4 = xa + ldirx - ldirxsprheight;
var y4 = ya + ldiry - ldirysprheight;

if argument5 == "u" and (va >= 90 and va = 270 or va < 90)
then draw_sprite_pos(argument0, argument1, x1, y1, x2, y2, x3, y3, x4, y4, 1);
else if argument5 == "b"
then draw_sprite_pos(argument0, argument1, x1, y1, x2, y2, x3, y3, x4, y4, 1);

///scr_zplane(sprite_index, image_index, xo, yo, zo)
var ldirx = lengthdir_x(argument4, zmd);
var ldiry = lengthdir_y(argument4, zmd);
var xa = x + argument2;
var ya = y + argument3;
var sgw = sprite_get_width(argument0)
var sgh = sprite_get_height(argument0)

var x1 = xa + ldirx;
var y1 = ya + ldiry;
var x2 = xa + sgw + ldirx;
var y2 = ya + ldiry;
var x3 = xa + sgw + ldirx;
var y3 = ya + sgh + ldiry;
var x4 = xa + ldirx;
var y4 = ya + sgh + ldiry;

draw_sprite_pos(argument0, argument1, x1, y1, x2, y2, x3, y3, x4, y4, 1);

week 4

///scr_circ_sprite(sprite_index,image_index,x,y,z)

var sgh=sprite_get_height(argument0);
var sgw=sprite_get_width(argument0);

var i;
for (i=0;i=(360-abs(zmd+90)) and (zmd<-90))
    {
        draw_sprite_general(
            argument0,argument1,
            i,0,1,sgh,
            argument2+lengthdir_x((argument4+sgh*2)*viewStretch/2,zmd)+
            lengthdir_x(sgw/(pi*2),360/sgw*i),
            argument3+lengthdir_y((argument4+sgh*2)*viewStretch/2,zmd)+
            lengthdir_y(sgw/(pi*2),360/sgw*i),
            1,viewStretch,zmd-90,
            c_white,c_white,c_white,c_white,1
        );
    }
}

///scr_draw_box(topsprite,sideSprite)
//script requires scr_xplane, scr_yplane, scr_zplane
var height = sprite_get_height(argument1)
var width = sprite_get_width(argument0)

scr_xplane(argument1,0,width/2,-width/2,height,"l")
scr_xplane(argument1,0,-width/2,-width/2,height,"r")
scr_yplane(argument1,0,-width/2,-width/2,height,"u")
scr_yplane(argument1,0,-width/2,width/2,height,"d")
scr_zplane(argument0,0,-width/2,-width/2,height)

week 5

///scr_draw_ellipse(x,y,z,width,height,resolution,rotation,colour,filled)
//                  0 1 2 3     4      5          6        7      8
var ldx=lengthdir_x(argument[2],zmd);
var ldy=lengthdir_y(argument[2],zmd);

var i=0;
draw_primitive_begin(pr_trianglefan);
if argument[8] == true{
    draw_vertex_colour(argument[0],argument[1],argument[7],1);
}
for(i=0;i<=argument[5];i++)
{
    var sx=sin(((2*pi)/argument[5])*i)*argument[3];
    var cy=cos(((2*pi)/argument[5])*i)*argument[4];
    var pdist=point_distance(0,0,sx,cy);
    if argument[8] == true{
        draw_vertex_colour(
        argument[0]+ldx+sin(arctan2(sx,cy)+degtorad(argument[6]))*pdist,
        argument[1]+ldy+cos(arctan2(sx,cy)+degtorad(argument[6]))*pdist,
        argument[7],1
        );
        
    } else {
        var sxi=sin(((2*pi)/argument[5])*(i+1))*argument[3];
        var cyi=cos(((2*pi)/argument[5])*(i+1))*argument[4];
        var pdisti=point_distance(0,0,sxi,cyi);
        draw_line_colour(
            argument[0]+ldx+sin(arctan2(sxi,cyi)+degtorad(argument[6]))*pdisti,
            argument[1]+ldy+cos(arctan2(sxi,cyi)+degtorad(argument[6]))*pdisti,
            argument[0]+ldx+sin(arctan2(sx,cy)+degtorad(argument[6]))*pdist,
            argument[1]+ldy+cos(arctan2(sx,cy)+degtorad(argument[6]))*pdist,
            argument[7],argument[7]
        );
    }
}
draw_primitive_end();

week 6

///scr_sphere_sprite(sprite_index,image_index,x,y,z,direction,resx,resy,scale)
//                   0            1           2 3 4 5         6    7    8
//may require scr_draw_ellipse() (totally optional)
argument6=round(argument6)
argument7=round(argument7)
var sgw=sprite_get_width(argument0);
var sgh=sprite_get_height(argument0)*argument8;
var zldx=lengthdir_x(argument4,zmd)
var zldy=lengthdir_y(argument4,zmd)
var topx=lengthdir_x(sgh/4,zmd)
var topy=lengthdir_y(sgh/4,zmd)

//draw outline
scr_draw_ellipse(
    argument2,argument3,argument4*viewStretch,
    (sgw/(pi*2)+2)*argument8,
    (sgw/(pi*2)+2)*argument8*viewStretch,
    32,zmd+90,c_black,true
)

var i;
var j;
draw_set_colour(c_white);
var tex = sprite_get_texture(argument0,argument1);

for (j=argument7;j>=0;j-=1){
    draw_primitive_begin_texture(pr_trianglestrip, tex);
    for (i=0;i<=argument6;i++){
        //var zsepx=lengthdir_x(,zmd+180)
        //var multrad=sin(degtorad((360/argument7)*j)/2)
        var radius=(sgw/(pi*2))*sin(degtorad((360/argument7)*j-j*.3)/2)*argument8
        var radius2=(sgw/(pi*2))*sin(degtorad((360/argument7)*(j+1)-8)/2)*argument8
        var dtr=degtorad(360/argument6*i)
        var dtr2=degtorad(360/argument6*(i)+10)
        draw_vertex_texture(
            argument2+zldx+topx+sin(dtr)*radius+lengthdir_x((sgh*.65)/argument7*j,zmd+180)*viewStretch*.5,
            argument3+zldy+topy+cos(dtr)*radius+lengthdir_y((sgh*.65)/argument7*j,zmd+180)*viewStretch*.5,
            1/argument6*i+1/360*argument5,1/argument7*j
        );
        draw_vertex_texture(
            argument2+zldx+topx+sin(dtr2)*radius2+lengthdir_x((sgh*.65)/argument7*(j+1),zmd+180)*viewStretch*.5,
            argument3+zldy+topy+cos(dtr2)*radius2+lengthdir_y((sgh*.65)/argument7*(j+1),zmd+180)*viewStretch*.5,
            1/argument6*i+1/360*argument5,1/argument7*j
        );
    }
    draw_primitive_end();
}

used here: https://gamejolt.com/games/apoceclipse/287590


week 7

///scr_draw_arc(x,y,radius,rot,res,deg,width,color,alpha)
//              0 1 2      3   4   5   6     7     8
var i, xx, yy;
draw_primitive_begin(pr_trianglestrip);

for(i = 0; i <= argument4; i += 1){
    xx[i]=argument0+lengthdir_x(argument2,argument3+argument5*i/argument4)+1
    yy[i]=argument1+lengthdir_y(argument2,argument3+argument5*i/argument4)+1
    draw_vertex_colour(
        xx[i]+lengthdir_x(argument6/2,argument3+argument5*i/argument4),
        yy[i]+lengthdir_y(argument6/2,argument3+argument5*i/argument4),
        argument7,argument8
    )
    draw_vertex_colour(
        xx[i]-lengthdir_x(argument6/2,argument3+argument5*i/argument4),
        yy[i]-lengthdir_y(argument6/2,argument3+argument5*i/argument4),
        argument7,argument8
    )
}
draw_primitive_end();

week 8

///scr_draw_ring(x,y,iradius,oradius,resolution,rotation,colour,alpha)
//               0 1 2       3       4          5        6      7
draw_primitive_begin(pr_trianglestrip);
for(var i=0;i<=argument[4];i++)
{
    draw_vertex_colour(
        argument[0]+lengthdir_x(argument[2],360/argument[4]*i+argument[5]),
        argument[1]+lengthdir_y(argument[2],360/argument[4]*i+argument[5]),
        argument[6],argument[7]
    )
    draw_vertex_colour(
        argument[0]+lengthdir_x(argument[3],360/argument[4]*i+argument[5]),
        argument[1]+lengthdir_y(argument[3],360/argument[4]*i+argument[5]),
        argument[6],argument[7]
    )
}
draw_primitive_end();

///scr_draw_gear(x,y,teeth,iRadius,mRadius,oRadius,toothBaseDeg,toothTopDeg,rot,res,color,alpha)
//               0 1 2     3       4       5       6            7           8   9   10    11
//requires scr_draw_ring()

//draw inner ring
scr_draw_ring(
    argument[0],argument[1],
    argument[3],argument[4],
    argument[9],argument[8],
    argument[10],argument[11]
)
//draw teeth
for(var i=0;i<argument[2];i++){
    draw_primitive_begin(pr_trianglestrip);
        draw_vertex_colour(//point 1 (middleRadius and +bottomland)
            argument[0]+lengthdir_x(argument[4],(360/argument[2])*i+argument[6]*.5+argument[8]),
            argument[1]+lengthdir_y(argument[4],(360/argument[2])*i+argument[6]*.5+argument[8]),
            argument[10],
            argument[11]
        )
        draw_vertex_colour(//point 2 (outerRadius and +topland)
            argument[0]+lengthdir_x(argument[5],(360/argument[2])*i+argument[7]*.5+argument[8]),
            argument[1]+lengthdir_y(argument[5],(360/argument[2])*i+argument[7]*.5+argument[8]),
            argument[10],
            argument[11]
        )
        draw_vertex_colour(//point 1 (middleRadius and -bottomland)
            argument[0]+lengthdir_x(argument[4],(360/argument[2])*i-argument[6]*.5+argument[8]),
            argument[1]+lengthdir_y(argument[4],(360/argument[2])*i-argument[6]*.5+argument[8]),
            argument[10],
            argument[11]
        )
        draw_vertex_colour(//point 2 (outerRadius and -topland)
            argument[0]+lengthdir_x(argument[5],(360/argument[2])*i-argument[7]*.5+argument[8]),
            argument[1]+lengthdir_y(argument[5],(360/argument[2])*i-argument[7]*.5+argument[8]),
            argument[10],
            argument[11]
        )
    draw_primitive_end();
}

week 9

///scr_closepoint_circle_line(x1,y1,x2,y2,h,k)
// [0],[1] return tangent on segment
// [2],[3] return tangent on line
var u,LAB,isect,xx,yy;
LAB=point_distance(argument0,argument1,argument2,argument3);
u=(
    (argument4-argument0)*(argument2-argument0)+
    (argument5-argument1)*(argument3-argument1)
    )/(power(LAB,2));
    
xx=argument0+u*(argument2-argument0);//x
yy=argument1+u*(argument3-argument1);//y

if xx>=min(argument0,argument2) and xx=min(argument1,argument3) and yy<=max(argument1,argument3)
{
    isect[0]=xx;
    isect[1]=yy;
} else {
    if min(
        point_distance(xx,yy,argument0,argument1),
        point_distance(xx,yy,argument2,argument3))==
        point_distance(xx,yy,argument0,argument1)
    {
        isect[0]=argument0;
        isect[1]=argument1;
    } else{
        isect[0]=argument2;
        isect[1]=argument3;
    }
}
isect[2]=xx;
isect[3]=yy;
return isect;

///scr_circle_intersection(circ1x,circ1y,circ2x,circ2y,radius1,radius2,intersector1or2,noIntersectReturn,overlapReturn)
//                         0      1      2      3      4       5       6               7                 8
//returns an array (x,y) of intersection

pdist=point_distance(argument0,argument1,argument2,argument3)
pdir=point_direction(argument0,argument1,argument2,argument3)
var intersections;
var overlap;
var noInt;
//overlap return
if (argument0==argument2 and argument1==argument3) and argument4==argument5
{
    if argument8==0
    {
        overlap[0]=argument0+lengthdir_x(pdist,pdir)//argument8;
        overlap[1]=argument1+lengthdir_y(pdist,pdir)//argument8;
        return overlap;
    }
}
//no intersection
if point_distance(argument0,argument1,argument2,argument3)>(argument4+argument5)
{
    if argument7==0
    {
        noInt[0]=argument0+lengthdir_x(pdist/2,pdir)//argument7;
        noInt[1]=argument1+lengthdir_y(pdist/2,pdir)//argument7;
        return noInt;
    }
}

//circle intersection calculations
var a=(sqr(argument4)-sqr(argument5)+sqr(pdist))/(pdist*2);
if (sqr(argument4)-sqr(a))>0
then var h=sqrt(sqr(argument4)-sqr(a))
else var h=0;
var p2x=argument0+a*(argument2-argument0)/pdist;//lengthdir_x(a,pdir);
var p2y=argument1+a*(argument3-argument1)/pdist;//lengthdir_y(a,pdir);
var p3x=p2x+h*(argument3-argument1)/pdist;
var p3y=p2y-h*(argument2-argument0)/pdist;
var p4x=p2x-h*(argument3-argument1)/pdist;
var p4y=p2y+h*(argument2-argument0)/pdist;
if argument6==2 //return intersection 1
{
    intersections[0]=p3x;
    intersections[1]=p3y;
    return intersections;
}
if argument6==1 //return intersection 2
{
    intersections[0]=p4x;
    intersections[1]=p4y;
    return intersections;
}

week 10

///scr_draw_RectWithHole_gradient(ox1,oy1,ox2,oy2,ix1,iy1,ix2,iy2,c1,c2,c3,c4)
//                                0   1   2   3   4   5   6   7   8  9  10 11
/*
ox1,oy1 c1                    c2
+-----------------------------+
|top panel  ix1,iy1           |
+-----------+-------+---------+ < ylerp1=the lerp of iy1 between oy1 and oy2
|a  left   c| empty |e right g| merge ag colour to get c and e
|b  panel  d| space |f panel h| merge bh colour to get d and f
+-----------+-------+---------+ < ylerp2=the lerp of iy2 between oy1 and oy2
|bottom panel       ix2,iy2   |
+-----------------------------+ ox2,oy2 c3
c4          ^       ^
         xlerp1  xlerp2
*/
var alpha=draw_get_alpha();
//set lerps
var xblerp=(argument[2]-argument[0]);
var yblerp=(argument[3]-argument[1]);
var xlerp1=(argument[4]-argument[0])/xblerp;
var xlerp2=(argument[6]-argument[0])/xblerp;
var ylerp1=(argument[5]-argument[1])/yblerp;
var ylerp2=(argument[7]-argument[1])/yblerp;
//set left panel vertex colours ab
var a=merge_colour(argument[8],argument[11],ylerp1);
var b=merge_colour(argument[8],argument[11],ylerp2);
//set right panel vertex colours gh
var g=merge_colour(argument[9],argument[10],ylerp1);
var h=merge_colour(argument[9],argument[10],ylerp2);
//set vertex colours near empty space by merging agbh
var c=merge_colour(a,g,xlerp1);
var d=merge_colour(b,h,xlerp1);
var e=merge_colour(a,g,xlerp2);
var f=merge_colour(b,h,xlerp2);
//draw top panel
draw_primitive_begin(pr_trianglestrip);
draw_vertex_colour(argument[0],argument[1],argument[8],alpha);
draw_vertex_colour(argument[0],argument[5],a,alpha);
draw_vertex_colour(argument[2],argument[1],argument[9],alpha);
draw_vertex_colour(argument[2],argument[5],g,alpha);
draw_primitive_end();
//draw left panel
draw_primitive_begin(pr_trianglestrip);
draw_vertex_colour(argument[0],argument[5],a,alpha);
draw_vertex_colour(argument[0],argument[7],b,alpha);
draw_vertex_colour(argument[4],argument[5],c,alpha);
draw_vertex_colour(argument[4],argument[7],d,alpha);
draw_primitive_end();
//draw right panel
draw_primitive_begin(pr_trianglestrip);
draw_vertex_colour(argument[6],argument[5],e,alpha);
draw_vertex_colour(argument[6],argument[7],f,alpha);
draw_vertex_colour(argument[2],argument[5],g,alpha);
draw_vertex_colour(argument[2],argument[7],h,alpha);
draw_primitive_end();
//draw bottom panel
draw_primitive_begin(pr_trianglestrip);
draw_vertex_colour(argument[0],argument[7],b,alpha);
draw_vertex_colour(argument[0],argument[3],argument[11],alpha);
draw_vertex_colour(argument[2],argument[7],h,alpha);
draw_vertex_colour(argument[2],argument[3],argument[10],alpha);
draw_primitive_end();

more

///scr_obj_line(x1,y1,x2,y2,object,snapx,snapy)
//              0  1  2  3  4      5     6
//specify object as undefined if you want a list returned.
//otherwise it creates objects specified in argument4.
//list contains arrays (xy[0] -> x, xy[1] -> y)
var dx,dy,d,slopegt1,iny,ie,ine,tmp,sx,sy;
var dsxy, returnlist;
returnlist=argument4!=undefined;
if (returnlist) then dsxy=ds_list_create();
x1=round(argument0/argument5)*argument5;
y1=round(argument1/argument6)*argument6;
x2=round(argument2/argument5)*argument5;
y2=round(argument3/argument6)*argument6;
sx=argument5;
sy=argument6;
slopegt1=0;
dx=abs(x2-x1);
dy=abs(y2-y1);
//NE to NW and SW to SE (dy>dx)
//but take into account new slope
//for when snaps are different
var tpdir=point_direction(x1,y1,x2,y2)
if (tpdir>=45 and tpdir=dx/sx){
    
    //mirror diagonally
    tmp=x1;//swap x1 with y1
    x1=y1;
    y1=tmp;
    tmp=x2;//swap x2 with y2
    x2=y2;
    y2=tmp;
    tmp=dx;//swap dx with dy
    dx=dy;
    dy=tmp;
    slopegt1=1;
    sx=argument6;
    sy=argument5;
}
if (x1>x2){
//mirror horizontally/vertically
tmp=x1;//swap x1 with x2
x1=x2;
x2=tmp;
tmp=y1;//swap y1 with y2
y1=y2;
y2=tmp;
}
if (y1>y2){
    iy=-sy;
} else {
    iy=sy;
}
d=(2*dy/sy-dx/sx);
ie=2*dy/sy;
ine=2*(dy/sy-dx/sx);
while(x1<x2){
        if(d<=0){
            d+=ie;
        } else {
            d+=ine;
            y1+=iy;
        }
        x1+=sx;
    if(slopegt1){
        if (returnlist){
            instance_create(y1,x1,argument4);
        } else {
            var xy=0;
            xy[1]=x1;
            xy[0]=y1;
            ds_list_add(dsxy,xy);
        }
    } else {
        if (returnlist){
            instance_create(x1,y1,argument4);
        } else {
            var xy=0;
            xy[1]=y1;
            xy[0]=x1;
            ds_list_add(dsxy,xy);
        }
    }
}
if (returnlist) then return dsxy;