/// fd_rectangle_shift(instance id, dx,dy, buffer_surf)
/*
used fd_rectangle_assure_surfaces_exist as a base;
shift the surfaces by dx,dy.
dx and dy are percentages /uyv type values (-1-0-1) since the surfaces may not all be the same size, a ratio allows shifting them all equally
example: //shift by the speed of an object pixel motion converted using the view size
fd_rectangle_shift(instance id, -vspeed/view_wview,-hspeed/view_hview)
buffer_surf is a pre-allocated surface whose size is large enough to handle all the system surfaces, this allows reusing the
buffer surface for a more efficient method. You must create that surface and ensure it's still valid
*/
with (argument0) {
var dx = argument1,
dy = argument2,
buffer = argument3;
var sw,sh,surf,dx_pix,dy_pix;
if (surface_exists(sf_pressure))
{
surf = sf_pressure;
sw = surface_get_width(surf);
sh = surface_get_height(surf);
dx_pix = dx*sw;
dy_pix = dy*sh;
surface_set_target(buffer);
{
draw_clear_alpha($000000, 0);
draw_surface(surf,0,0);
}
surface_reset_target();
surface_set_target(surf);
{
//re-init the surface as when it was done initially
//draw_clear_alpha($000000, 0);
//shift
draw_surface_part(buffer,dx_pix,dy_pix,sw,sh,0,0);
}
surface_reset_target();
//original code in cloned script
//sf_pressure = surface_create(sf_pressure_width, sf_pressure_height);
//surface_set_target(sf_pressure);
//draw_clear_alpha($000000, 0);
//surface_reset_target();
}
if (surface_exists(sf_pressure_temporary))
{
surf = sf_pressure_temporary;
sw = surface_get_width(surf);
sh = surface_get_height(surf);
dx_pix = dx*sw;
dy_pix = dy*sh;
surface_set_target(buffer);
{
draw_clear_alpha($000000, 0);
draw_surface(surf,0,0);
}
surface_reset_target();
surface_set_target(surf);
{
//re-init the surface as when it was done initially
//draw_clear_alpha($000000, 0);
//shift
draw_surface_part(buffer,dx_pix,dy_pix,sw,sh,0,0);
}
surface_reset_target();
//original code in cloned script
//sf_pressure_temporary = surface_create(sf_pressure_width, sf_pressure_height);
}
if (surface_exists(sf_velocity))
{
surf = sf_velocity;
sw = surface_get_width(surf);
sh = surface_get_height(surf);
dx_pix = dx*sw;
dy_pix = dy*sh;
surface_set_target(buffer);
{
draw_clear_alpha($000000, 0);
draw_surface(surf,0,0);
}
surface_reset_target();
surface_set_target(surf);
{
//re-init the surface as when it was done initially
draw_clear_alpha($008080, 0);
//shift
draw_surface_part(buffer,dx_pix,dy_pix,sw,sh,0,0);
}
surface_reset_target();
//original code in cloned script
//sf_velocity = surface_create(sf_velocity_width, sf_velocity_height);
//surface_set_target(sf_velocity);
//draw_clear_alpha($008080, 0);
//surface_reset_target();
}
if (surface_exists(sf_velocity_temporary))
{
surf = sf_velocity_temporary;
sw = surface_get_width(surf);
sh = surface_get_height(surf);
dx_pix = dx*sw;
dy_pix = dy*sh;
surface_set_target(buffer);
{
draw_clear_alpha($000000, 0);
draw_surface(surf,0,0);
}
surface_reset_target();
surface_set_target(surf);
{
//re-init the surface as when it was done initially
//draw_clear_alpha($000000, 0);
//shift
draw_surface_part(buffer,dx_pix,dy_pix,sw,sh,0,0);
}
surface_reset_target();
//original code in cloned script
//sf_velocity_temporary = surface_create(sf_velocity_width, sf_velocity_height);
}
if (surface_exists(sf_material_0))
{
surf = sf_material_0;
sw = surface_get_width(surf);
sh = surface_get_height(surf);
dx_pix = dx*sw;
dy_pix = dy*sh;
surface_set_target(buffer);
{
draw_clear_alpha($000000, 0);
draw_surface(surf,0,0);
}
surface_reset_target();
surface_set_target(surf);
{
//re-init the surface as when it was done initially
//draw_clear_alpha($000000, 0);
//shift
draw_surface_part(buffer,dx_pix,dy_pix,sw,sh,0,0);
}
surface_reset_target();
//original code in cloned script
//sf_material_0 = surface_create(sf_material_width, sf_material_height);
//surface_set_target(sf_material_0);
//draw_clear_alpha($000000, 0);
//surface_reset_target();
//material_surface_was_created = true;
}
if (surface_exists(sf_material_0_temporary))
{
surf = sf_material_0_temporary;
sw = surface_get_width(surf);
sh = surface_get_height(surf);
dx_pix = dx*sw;
dy_pix = dy*sh;
surface_set_target(buffer);
{
draw_clear_alpha($000000, 0);
draw_surface(surf,0,0);
}
surface_reset_target();
surface_set_target(surf);
{
//re-init the surface as when it was done initially
//draw_clear_alpha($000000, 0);
//shift
draw_surface_part(buffer,dx_pix,dy_pix,sw,sh,0,0);
}
surface_reset_target();
//original code in cloned script
//sf_material_0_temporary = surface_create(sf_material_width, sf_material_height);
}
if (surface_exists(sf_material_1))
{
surf = sf_material_1;
sw = surface_get_width(surf);
sh = surface_get_height(surf);
dx_pix = dx*sw;
dy_pix = dy*sh;
surface_set_target(buffer);
{
//draw_clear_alpha($000000, 0);
draw_surface(surf,0,0);
}
surface_reset_target();
surface_set_target(surf);
{
//re-init the surface as when it was done initially
draw_clear_alpha($000000, 0);
//shift
draw_surface_part(buffer,dx_pix,dy_pix,sw,sh,0,0);
}
surface_reset_target();
//original code in cloned script
//sf_material_1 = surface_create(sf_material_width, sf_material_height);
//surface_set_target(sf_material_1);
//draw_clear_alpha($000000, 0);
//surface_reset_target();
}
if (surface_exists(sf_material_1_temporary))
{
surf = sf_material_1_temporary;
sw = surface_get_width(surf);
sh = surface_get_height(surf);
dx_pix = dx*sw;
dy_pix = dy*sh;
surface_set_target(buffer);
{
draw_clear_alpha($000000, 0);
draw_surface(surf,0,0);
}
surface_reset_target();
surface_set_target(surf);
{
//re-init the surface as when it was done initially
draw_clear_alpha($000000, 0);
//shift
draw_surface_part(buffer,dx_pix,dy_pix,sw,sh,0,0);
}
surface_reset_target();
//original code in cloned script
//sf_material_1_temporary = surface_create(sf_material_width, sf_material_height);
}
if (surface_exists(sf_world))
{
surf = sf_world;
sw = surface_get_width(surf);
sh = surface_get_height(surf);
dx_pix = dx*sw;
dy_pix = dy*sh;
surface_set_target(buffer);
{
draw_clear_alpha($000000, 0);
draw_surface(surf,0,0);
}
surface_reset_target();
surface_set_target(surf);
{
//re-init the surface as when it was done initially
//draw_clear_alpha($00FFFF, 0)
//shift
draw_surface_part(buffer,dx_pix,dy_pix,sw,sh,0,0);
}
surface_reset_target();
}
//if (!surface_exists(sf_world)) sf_world_update = true;
//if (sf_world_update) {
// if (collision_mask_type == 0) {
// sf_world = surface_create(sprite_get_width(collision_mask_sprite_index), sprite_get_height(collision_mask_sprite_index));
// surface_set_target(sf_world);
// draw_clear_alpha($00FFFF, 0);
// draw_sprite(collision_mask_sprite_index, collision_mask_image_index, 0, 0);
// surface_reset_target();
// } else {
// var error_string = "Fluid Dynamics error. An invalid collision mask surface was provided for a fluid dynamics rectangle." + chr(13) + chr(10) + "It could be that the surface spontaneously ceased to exist (because " +
// "of surfaces' volatile behavior)" + chr(13) + chr(10) + "thereby making it invalid. When setting your own collision masks with fd_rectangle_set_collision_mask_surface," + chr(13) + chr(10) +
// "make sure to manually assure their existence each time before calling fd_rectangle_update." + chr(13) + chr(10);
// show_debug_message(error_string);
// show_error(error_string, false);
// }
// sf_world_update = false;
//}
}