Important Announcement
Forum has been made read-only. Please click here for more information or here to return to The Spriters Resource.

The Revenge of Mit's Sprites
#3
(07-06-2014, 12:08 PM)Koh Wrote: Love the swimming animation! Question...I've always wanted to ask this from the programmers; what are you doing to get that water effect? Is it a shader, or a bunch of water objects cycling through the correct ripple tiles?

I actually am not 100% sure myself, since it's not my engine. lemme pull the code out of the water maker, though. you might be able to get something from that
[spoiler]
(create event)
nodewidth = waterwidth/16
nodes = floor(waterwidth/nodewidth)+1;
spring = 2;
fricdiv = 1.5;
for (i=0; i<nodes; i+=1;) {
yy[i] = y;
ysp[i] = 0;
frc[i] = ysp[i]/(room_speed/fricdiv);
}
swim = instance_create(x,y+4,obj_swim)
swim.image_xscale = waterwidth/16
swim.image_yscale = waterheight/16
(step event)
var drop;
for (i = 0; i < nodes; i += 1) {
if ((i-1 > -1) && (i+1 < nodes)) {
ysp[i] += ((((yy[i-1]-yy[i])+(yy[i+1]-yy[i]))+(ysp[i-1]+ysp[i+1])))/(room_speed*spring);
ysp[i] += (y-yy[i])/(room_speed*spring);
frc[i] = (ysp[i])/(room_speed/fricdiv);
ysp[i] -= frc[i];
drop = collision_circle(x+(i*nodewidth), yy[i], nodewidth/2, obj_physics, 0, 1);
if (drop) {
if (abs(drop.vspeed) > 0.5){
ysp[i] = divide(drop.vspeed/4, max(1, point_distance(drop.x, 0, x+(i*nodewidth), 0)/16));
}
}
//actually move the node
yy[i] += ysp[i];
}
}
(draw event)
draw_set_blend_mode(bm_add) {
draw_set_color(make_color_rgb(0,128,255));
draw_set_alpha(0.5);
draw_primitive_begin(pr_trianglestrip);
for (i = 0; i < nodes; i += 1)
{
draw_vertex(x+(i*nodewidth), yy[i]);
draw_vertex(x+(i*nodewidth), y+waterheight);
}

draw_primitive_end();
draw_set_alpha(1);
draw_set_color(c_white);


//draw the water's surface
var pth, wid, stp, stp_i, xt, xt_i, sgn, a, a_i, x1, y1, x2, y2, i, px, py, nx, ny, vert_count;

wid = 4; //half the width of water surface

px = x;
py = yy[0];

vert_count = 0;
draw_set_color(c_teal)
draw_primitive_begin_texture(pr_trianglestrip, sprite_get_texture(spr_watertop, 0));

for (i = 0; i < nodes; i += 1)
{

nx = x+(i*nodewidth);
ny = yy[i];

dir = point_direction(px, py, nx, ny);
dx = lengthdir_x(wid, dir+90);
dy = lengthdir_y(wid, dir+90);

xt = (i-1)/nodes;
draw_vertex_texture(px+dx, py+dy, xt, 0);
draw_vertex_texture(px-dx, py-dy, xt, 1);
px = nx;
py = ny;
}

draw_vertex_texture(px+dx, py+dy, xt, 0);
draw_vertex_texture(px-dx, py-dy, xt, 1);
draw_primitive_end();
}
draw_set_blend_mode(bm_normal)
[/spoiler]
Reply


Messages In This Thread
The Revenge of Mit's Sprites - by Mit - 07-06-2014, 11:33 AM
RE: The Revenge of Mit's Sprites - by Koh - 07-06-2014, 12:08 PM
RE: The Revenge of Mit's Sprites - by Mit - 07-06-2014, 12:17 PM
RE: The Revenge of Mit's Sprites - by -Ash- - 10-20-2014, 06:36 PM
RE: The Revenge of Mit's Sprites - by Mit - 10-26-2014, 06:37 PM
RE: The Revenge of Mit's Sprites - by Quotient - 07-08-2014, 03:10 PM
RE: The Revenge of Mit's Sprites - by Mit - 07-08-2014, 05:46 PM
RE: The Revenge of Mit's Sprites - by Quotient - 07-08-2014, 06:08 PM
RE: The Revenge of Mit's Sprites - by Rystar - 07-08-2014, 06:21 PM
RE: The Revenge of Mit's Sprites - by Mit - 07-08-2014, 06:55 PM
RE: The Revenge of Mit's Sprites - by Quotient - 07-08-2014, 07:20 PM
RE: The Revenge of Mit's Sprites - by Mit - 07-08-2014, 07:31 PM
RE: The Revenge of Mit's Sprites - by Mit - 07-09-2014, 11:43 PM
RE: The Revenge of Mit's Sprites - by Mit - 07-12-2014, 02:44 PM
RE: The Revenge of Mit's Sprites - by Kelvin - 07-14-2014, 07:31 AM
RE: The Revenge of Mit's Sprites - by Mit - 07-14-2014, 08:36 AM
RE: The Revenge of Mit's Sprites - by Kelvin - 07-14-2014, 09:50 AM
RE: The Revenge of Mit's Sprites - by Mit - 07-14-2014, 10:06 AM
RE: The Revenge of Mit's Sprites - by Kelvin - 07-14-2014, 11:09 AM
RE: The Revenge of Mit's Sprites - by Mit - 07-27-2014, 03:30 AM
RE: The Revenge of Mit's Sprites - by Mit - 07-27-2014, 02:49 PM
RE: The Revenge of Mit's Sprites - by Quotient - 07-27-2014, 04:04 PM
RE: The Revenge of Mit's Sprites - by Mit - 07-27-2014, 04:07 PM
RE: The Revenge of Mit's Sprites - by SmithyGCN - 07-27-2014, 09:42 PM
RE: The Revenge of Mit's Sprites - by Ton - 07-28-2014, 10:03 AM
RE: The Revenge of Mit's Sprites - by Mit - 07-28-2014, 11:05 AM
RE: The Revenge of Mit's Sprites - by Mit - 07-30-2014, 02:39 AM
RE: The Revenge of Mit's Sprites - by Ton - 07-30-2014, 07:49 AM
RE: The Revenge of Mit's Sprites - by Mit - 07-31-2014, 12:17 AM
RE: The Revenge of Mit's Sprites - by Mit - 08-07-2014, 01:14 AM
RE: The Revenge of Mit's Sprites - by Quotient - 08-08-2014, 07:13 PM
RE: The Revenge of Mit's Sprites - by Mit - 08-09-2014, 01:27 PM
RE: The Revenge of Mit's Sprites - by Mystie - 08-08-2014, 08:20 PM
RE: The Revenge of Mit's Sprites - by -Ash- - 08-10-2014, 04:15 AM
RE: The Revenge of Mit's Sprites - by Mit - 08-10-2014, 02:34 PM
RE: The Revenge of Mit's Sprites - by Ton - 08-10-2014, 04:59 PM
RE: The Revenge of Mit's Sprites - by Mit - 08-10-2014, 05:23 PM
RE: The Revenge of Mit's Sprites - by Mit - 08-22-2014, 08:15 PM
RE: The Revenge of Mit's Sprites - by Zadaben - 08-22-2014, 11:45 PM
RE: The Revenge of Mit's Sprites - by Mit - 08-23-2014, 12:02 AM
RE: The Revenge of Mit's Sprites - by Kitsu - 08-24-2014, 08:18 PM
RE: The Revenge of Mit's Sprites - by Mit - 08-24-2014, 09:18 PM
RE: The Revenge of Mit's Sprites - by Kitsu - 08-25-2014, 12:22 AM
RE: The Revenge of Mit's Sprites - by Mit - 08-26-2014, 12:41 AM
RE: The Revenge of Mit's Sprites - by Mit - 08-28-2014, 11:07 PM
RE: The Revenge of Mit's Sprites - by Ton - 08-29-2014, 08:19 AM
RE: The Revenge of Mit's Sprites - by Mit - 09-01-2014, 12:32 AM
RE: The Revenge of Mit's Sprites - by Omnikariz - 09-01-2014, 02:30 AM
RE: The Revenge of Mit's Sprites - by Mit - 09-01-2014, 03:25 AM
RE: The Revenge of Mit's Sprites - by Koh - 09-01-2014, 11:20 AM
RE: The Revenge of Mit's Sprites - by Mit - 09-01-2014, 05:56 PM
RE: The Revenge of Mit's Sprites - by Sevenstitch - 09-02-2014, 07:24 AM
RE: The Revenge of Mit's Sprites - by Mit - 09-02-2014, 01:44 PM
RE: The Revenge of Mit's Sprites - by Kitsu - 09-02-2014, 05:45 PM
RE: The Revenge of Mit's Sprites - by Ton - 09-03-2014, 09:23 AM
RE: The Revenge of Mit's Sprites - by Mit - 09-03-2014, 10:41 AM
RE: The Revenge of Mit's Sprites - by Kitsu - 09-03-2014, 12:46 PM
RE: The Revenge of Mit's Sprites - by Mit - 09-03-2014, 09:08 PM
RE: The Revenge of Mit's Sprites - by Mit - 09-04-2014, 09:49 PM
RE: The Revenge of Mit's Sprites - by Mystie - 09-04-2014, 10:10 PM
RE: The Revenge of Mit's Sprites - by Koh - 09-05-2014, 06:23 AM
RE: The Revenge of Mit's Sprites - by Mit - 09-05-2014, 08:58 AM
RE: The Revenge of Mit's Sprites - by Mit - 09-07-2014, 07:00 PM
RE: The Revenge of Mit's Sprites - by Ton - 09-08-2014, 07:47 AM
RE: The Revenge of Mit's Sprites - by Mit - 09-15-2014, 01:05 AM
RE: The Revenge of Mit's Sprites - by Koh - 09-15-2014, 06:45 AM
RE: The Revenge of Mit's Sprites - by Mit - 09-26-2014, 05:33 PM
RE: The Revenge of Mit's Sprites - by Quirby64 - 10-26-2014, 06:49 PM
RE: The Revenge of Mit's Sprites - by Mit - 11-01-2014, 07:07 PM
RE: The Revenge of Mit's Sprites - by Mit - 12-28-2014, 02:17 PM
RE: The Revenge of Mit's Sprites - by SupahSanti - 12-28-2014, 07:59 PM
RE: The Revenge of Mit's Sprites - by Mit - 01-07-2015, 02:08 AM
RE: The Revenge of Mit's Sprites - by Kelvin - 01-07-2015, 04:07 PM
RE: The Revenge of Mit's Sprites - by Mit - 01-08-2015, 03:36 PM
RE: The Revenge of Mit's Sprites - by Mit - 01-11-2015, 07:19 PM
RE: The Revenge of Mit's Sprites - by Key0808 - 01-12-2015, 02:43 AM
RE: The Revenge of Mit's Sprites - by Mit - 01-20-2015, 09:32 PM
RE: The Revenge of Mit's Sprites - by Mit - 03-30-2015, 02:13 PM
RE: The Revenge of Mit's Sprites - by Mit - 03-30-2015, 06:12 PM
RE: The Revenge of Mit's Sprites - by Iceman404 - 04-01-2015, 03:26 AM
RE: The Revenge of Mit's Sprites - by Mit - 04-03-2015, 10:31 PM
RE: The Revenge of Mit's Sprites - by Mit - 04-21-2015, 12:55 AM
RE: The Revenge of Mit's Sprites - by Koh - 04-22-2015, 05:33 PM
RE: The Revenge of Mit's Sprites - by Kelvin - 04-22-2015, 08:51 AM
RE: The Revenge of Mit's Sprites - by Mit - 04-22-2015, 09:24 PM
RE: The Revenge of Mit's Sprites - by Kelvin - 04-23-2015, 08:36 AM
RE: The Revenge of Mit's Sprites - by Mit - 04-23-2015, 09:20 AM
RE: The Revenge of Mit's Sprites - by Virt - 04-23-2015, 06:55 PM
RE: The Revenge of Mit's Sprites - by recme - 04-23-2015, 08:14 PM
RE: The Revenge of Mit's Sprites - by Virt - 04-23-2015, 08:54 PM
RE: The Revenge of Mit's Sprites - by Mit - 04-24-2015, 01:58 PM
RE: The Revenge of Mit's Sprites - by Virt - 04-24-2015, 06:14 PM
RE: The Revenge of Mit's Sprites - by Silversea - 04-24-2015, 09:34 PM
RE: The Revenge of Mit's Sprites - by Mit - 04-26-2015, 06:03 PM
RE: The Revenge of Mit's Sprites - by Mit - 09-14-2015, 12:47 AM
RE: The Revenge of Mit's Sprites - by The Phinx - 09-14-2015, 03:06 PM
RE: The Revenge of Mit's Sprites - by Koh - 09-14-2015, 07:38 PM
RE: The Revenge of Mit's Sprites - by Mit - 09-14-2015, 09:27 PM
RE: The Revenge of Mit's Sprites - by ~DrakoRero~ - 09-15-2015, 05:08 PM
RE: The Revenge of Mit's Sprites - by kidicarus29 - 09-17-2015, 03:33 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)