Better way to animate this liquid?

Well, sine waves are fairly simple, you change the given value as you want to increase or decrease the wave frequency, for example:

for(var i=0;i<32;i++){
var xx = i*10;
var yy = sin(i);
draw_point(x+xx,y+yy);

}

Notice how the variable i, the value we are getting the sine from, increases by 1 in each iteration of the drawing loop. This code will give you a wave with a barely noticeable amplitude (the height of the wave). You can increase it by multiplying the resulting value:

for(var i=0;i<32;i++){
var xx = i*10;
var yy = sin(i)*10;
draw_point(x+xx,y+yy);

}

By multiplying the result of the sin function by 10 the wave gains a much more noticeable amplitude. If you want to increase or reduce the length of the cycles all you have to do is change how much the value we are getting sine from changes. Since i has a fixed increment for the for loop, we'll use a new variable:

var c = 0; 

for(var i=0;i<32;i++){ var xx = i10; var yy = sin(c)10; c += 0.5; draw_point(x+xx,y+yy); }

A smaller increase will result in longer cycles, and a larger increase will result in shorter cycles. Do keep in mind that increases too large will end up skipping values in the sine wave.

If you want the sine wave to "move" you need to gradually change the initial value of sin in the drawing loop. Notice how in the previous code we used the local variable c to increase the value of sin in every iteration. By changing it to an instance variable, declared at the create event, and storing its value before the drawing loop, we can slowly change its value after the loop has finished.

temp_c = c; 

for(var i=0;i<32;i++){ var xx = i10; var yy = sin(c)10; c += 0.5; draw_point(x+xx,y+yy); } c = temp_c-0.05;

You can increase or decrease the speed of the wave by changing the amount by which the variable c increases or decreases after every loop.

That should be it for getting the wave, as for actually drawing it, if you want to use primitives you can check the Manual for all the little details, the quick and dirty is that first you must decide which type of primitive you want to use with draw_primitive_begin, then add the vertex points with the various draw_vertex functions, and finally actually draw the already defined primitive with draw_primitive_end.

For your particular need, I would use a triangle strip primitive, which draws a series of connected triangles, using the coordinates of the wave points we got from our previous code plus an extra vertex directly below said points:

temp_c = c;

draw_primitive_begin(pr_trianglestrip) for(var i=0;i<32;i++){ var xx = i10; var yy = sin(c)10; c += 0.5; draw_vertex(x+xx,y+yy) draw_vertex(x+xx,y+200) } draw_primitive_end() c = temp_c-0.05;

That should draw an approximation of your effect, as for clipping it, I would use either a surface or a shader, and it so happens that YellowAfterLife has a tutorial about clipping drawings that explains it much better than I would ever be able to, you can find it here: https://yal.cc/gamemaker-draw-clip/

/r/gamemaker Thread