surface_copy

This function simply takes the image from one surface and copies it onto another one at the specified local position within that surface (where the (0, 0) position is the top left corner of the destination surface). If the destination surface already has information this will be overwritten by the copy, and the function does not change the source surface in any way.

NOTE When working with surfaces there is the possibility that they can cease to exist at any time due to them being stored in texture memory. You should ALWAYS check that a surface exists using surface_exists before referencing them directly.

 

Syntax:

surface_copy(destination, x, y, source);

ArgumentTypeDescription
destinationSurfaceThe surface to copy the other surface to.
xRealThe x position to copy to.
yRealThe y position to copy to.
sourceSurfaceThe surface to be copied.

 

Returns:

N/A

 

Example:

if (view_current == 0)
{
    surface_copy(surf, 0, 0, temp_surf);
}
else
{
    draw_surface(surf, 0, 0);
}

The above code checks the current view being drawn. If it is view[0] it copies the surface stored in the variable temp_surf onto the surface in the variable surf. If the current view is anything other than view[0] the surface surf is drawn to the screen.