rendered paste body
var wave_x, texture_y, texture_step;
// Get start position of the water in level
start_y = max(global.water_height-view_yview, 0);
// Check if the water is visible
if (global.water && (start_y-8<=view_hview) && !global.capture)
{
//texture_set_interpolation(true);
// If the user wants detailed water....
if (global.detail_level == 2)
{
// Draw the screen as a distorted surface
texture_step = 1/view_hview;
angle_x = (current_angle_x) + wave_pitch_x*start_y;
angle_y = (current_angle_y) + wave_pitch_x*(start_y+view_yview);
texture_y = texture_step * start_y;
draw_primitive_begin_texture(pr_trianglestrip, surface_get_texture(screen_surface));
for (y=start_y; y<=(view_hview+steps); y+=steps)
{
wave_x = view_xview + sin(angle_x)*wave_offset_x-wave_offset_x;
texture_y = max(min(y + sin(angle_y)*wave_offset_y, view_hview),0)/view_hview;
draw_vertex_texture_color(wave_x, view_yview+y, 0, texture_y, merge_color(global.water_top_color, global.water_bottom_color, texture_y), 1);
draw_vertex_texture_color(view_xview+view_wview+(wave_offset_x), view_yview+y, 1, texture_y, merge_color(global.water_top_color, global.water_bottom_color, texture_y), 1);
angle_x += wave_pitch_x*steps;
angle_y += wave_pitch_y*steps;
}
draw_primitive_end();
}
else if (global.detail_level == 1)
{
// Draw the screen as a distorted surface
texture_step = 1/view_hview;
angle_x = (current_angle_x) + wave_pitch_x*start_y;
texture_y = texture_step * start_y;
draw_primitive_begin_texture(pr_trianglestrip, surface_get_texture(screen_surface));
for (y=start_y; y<=(view_hview+steps); y+=steps)
{
wave_x = view_xview + sin(angle_x)*wave_offset_x-wave_offset_x;
draw_vertex_texture_color(wave_x, view_yview+y, 0, texture_y, merge_color(global.water_top_color, global.water_bottom_color, texture_y), 1);
draw_vertex_texture_color(view_xview+view_wview+(wave_offset_x), view_yview+y, 1, texture_y, merge_color(global.water_top_color, global.water_bottom_color, texture_y), 1);
angle_x += wave_pitch_x*steps;
angle_y += wave_pitch_y*steps;
texture_y += texture_step*steps;
}
draw_primitive_end();
}
else
{
// Draw just a semi-transparent gradient
draw_set_blend_mode_ext(bm_dest_color, bm_src_alpha_sat);
draw_rectangle_color(view_xview, view_yview+start_y, view_xview+view_wview, view_yview+view_hview,
merge_color(global.water_top_color, global.water_bottom_color, start_y/view_hview), merge_color(global.water_top_color, global.water_bottom_color, start_y/view_hview), global.water_bottom_color, global.water_bottom_color, false);
draw_set_blend_mode(bm_normal);
}
// Draw water horizon
draw_sprite_tiled_horizontal(sprWaterHorizon, current_time div 100, view_xview, global.water_height-8);
}