Here is a screenshot of it so far:

just so you know, the doughnut looking things attract the grid, everything else repels it slightly.

The way I have attempted to simulate this grid is by defining the vertexes where two lines on the grid cross, and storing their x and y coordinates in two different arrays, gridx, and gridy. I also store their momentum in two other arrays called gox and goy. This is all done in the create event, shown here:

for(i=0;i<ceil(room_width/size)+3;i+=1) // the +3 is just so that you cannot see the edge of the grid for(n=0;n<ceil(room_height/size)+3;n+=1) // size is the distance between each point { gridx[i,n]=size*i gridy[i,n]=size*n gox[i,n]=0 goy[i,n]=0 }To render this grid I simply draw a line in between these vertexes. I also draw and the average between vertexes the same way so that the grid can appear smaller without wasting cpu power. This is all done in the draw event code, shown here:

for(i=0;i<ceil(room_width/size)+3;i+=1) //drawing the vertical lines for(n=0;n<ceil(room_height/size-1)+3;n+=1) { draw_line(gridx[i,n],gridy[i,n],gridx[i,n+1],gridy[i,n+1]) if(i<ceil(room_width/size)+2 ) //checking to make sure that there is a line after this to average with draw_line((gridx[i,n]+gridx[i+1,n])/2,(gridy[i,n]+gridy[i+1,n])/2,(gridx[i,n+1]+gridx[i+1,n+1])/2,(gridy[i,n+1]+gridy[i+1,n+1])/2) //drawing the average line } for(i=0;i<ceil(room_width/size)+2;i+=1) for(n=0;n<ceil(room_height/size)+2;n+=1) { draw_line(gridx[i,n],gridy[i,n],gridx[i+1,n],gridy[i+1,n]) if(n<ceil(room_height/size)+2) //checking to make sure that there is a line after this to average with draw_line((gridx[i,n]+gridx[i,n+1])/2,(gridy[i,n]+gridy[i,n+1])/2,(gridx[i+1,n]+gridx[i+1,n+1])/2,(gridy[i+1,n]+gridy[i+1,n+1])/2) //drawing the average line }

I do not think that I have any code here so far that could be improved, I just included it just in case I missed something. This is what I really need help with, my step event where I simulate the grid.

Here it is:

for(i=1;i<ceil(room_width/size)+2;i+=1) for(n=1;n<ceil(room_height/size)+2;n+=1) { gox[i,n]=gox[i,n]/fric //Friction on the momentum, fric is a variable I define elsewhere so that I can tweak it. goy[i,n]=goy[i,n]/fric spring(0,-1) //Spring is a code that I have also posted below, it adds the force of a spring in between each point to gox and goy spring(0,1) spring(-1,0) spring(1,0) } for(z=0;z<instance_count;z+=1) //this is where I go around to each instance, and check how it affects the grid if(instance_exists(instance_id[z])) { xx=round(instance_id[z].x/size) xxx=instance_id[z].x yy=round(instance_id[z].y/size) yyy=instance_id[z].y frce=instance_id[z].force //each object has a force, which is the amount of force it puts on the grid rng=instance_id[z].range // each instance has a range, which is the radius of its effect on the grid for(i=xx-rng/size;i<xx+rng/size;i+=1) for(n=yy-rng/size;n<yy+rng/size;n+=1) //I go to each point on the grid within the range of the instance, and affect it accordingly { if(i>0 && i<ceil(room_width/size)+2 && n>0 && n<ceil(room_height/size)+2) //making sure that the point im affecting is actually on the grid { eff=rng-point_distance(xxx,yyy,gridx[i,n],gridy[i,n]) if(eff>0) { dir=point_direction(xxx,yyy,gridx[i,n],gridy[i,n]) gox[i,n]+=cos(dir/180*pi)*eff*frce goy[i,n]-=sin(dir/180*pi)*eff*frce } } } } for(i=1;i<ceil(room_width/size)+2;i+=1) for(n=1;n<ceil(room_height/size)+2;n+=1) //adding the movement that has been calculated to each point { gridx[i,n]+=gox[i,n] gridy[i,n]+=goy[i,n] }

finally I have the spring code, which i use in the step event.

dist=point_distance(gridx[i,n],gridy[i,n],gridx[i+argument0,n+argument1],gridy[i+argument0,n+argument1])-size dir=point_direction(gridx[i,n],gridy[i,n],gridx[i+argument0,n+argument1],gridy[i+argument0,n+argument1]) gox[i,n]+=cos(dir/180*pi)*-springforce*dist goy[i,n]-=sin(dir/180*pi)*-springforce*dist

I would post my entire project, but I have GM for mac, so not many people would be able to see it. if anyone with a mac wants me to post it I will though.

I would appreciate any help, and if anything is unclear then just ask. THANKS!!!

**Edited by lolmister, 22 February 2012 - 05:46 AM.**