GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2014-05-27 15:44:25

CatezeeY
Member
Registered: 2013-11-02
Posts: 6

draw_background_tiled_partial_ext

Expand/*
**  Usage:
**      draw_background_tiled_partial_ext(background,x,y,xscale,yscale,rot,color,alpha,index)
**
**  Arguments:
**      back    the background to be drawn.
**      x       the x position of the background.
**      y       the y position of the background.
**      xscale  the hor. scale of the background.
**      yscale  the ver. scale of the background.
**      rot     the angle of the background.
**      color   the color of the background.
**      alpha   the alpha transparency of the background.
**      index   to check if the background is tiled vertically.
**
**  Notes:
**      Don't change the value of the 'top' variable. That will make the background get drawn as many pixels the background has below the top background.
**
**  Returns:
**      Returns a drawn background depending if it's tiled horizontally i/o vertically.
**
**  Example:
**      draw_background_tiled_partial_ext(background_index[0],view_xview[0]/2,0,1,1,0,background_blend[0],background_alpha[0]);
**
**  GMLscripts.com
*/

var back, width, height, xx, yy, left, right, bottom, index, i, j;
back    = argument0;
xx      = argument1;
yy      = argument2;
xscale  = argument3;
yscale  = argument4;
rot     = argument5;
color   = argument6;
a_trans = argument7;
index   = argument8;
width   = background_get_width(back);
height  = background_get_height(back);
left    = -1;
right   = view_xview[view_current]/width+view_wview[view_current]/width+1;
top     = 1;
bottom  = view_yview[view_current]/height+view_hview[view_current]/height+1;

if (view_enabled) {
    if (background_vtiled[index] == false) {
        for (i=left; i<right; i+=1) {
            draw_background_ext(back,xx mod width+width*i,yy,xscale, yscale, rot, color, a_trans);
        }
    }
    else {
        for (i=left; i<right; i+=1) {
            draw_background_ext(back,xx mod width+width*i,yy,xscale, yscale, rot, color, a_trans);
        }
        for (i=left; i<right; i+=1)
        for (j=top; j<bottom; j+=1) {
            draw_background_ext(back,xx mod width+width*i,yy mod height+height*j,xscale, yscale, rot, color, a_trans);
        }
    }
}
else {
    if (background_vtiled[index] == false) {
        for (i=-1; i<right; i+=1) {
            draw_background_ext(back,xx mod width+width*i,yy,xscale, yscale, rot, color, a_trans);
        }
    }
    else {
        for (i=-1; i<right; i+=1) {
            draw_background_ext(back,xx mod width+width*i,yy,xscale, yscale, rot, color, a_trans);
        }
        for (i=-1; i<right; i+=1)
        for (j=1; j<bottom; j+=1) {
            draw_background_ext(back,xx mod width+width*i,yy mod height+height*j,xscale, yscale, rot, color, a_trans);
        }
    }
}

If anyone has trouble with this script, let me know.

Last edited by CatezeeY (2014-05-28 01:23:29)

Offline

#2 2014-05-27 22:37:10

xot
Administrator
Registered: 2007-08-18
Posts: 1,240

Re: draw_background_tiled_partial_ext

Can you provide a description of what this does and perhaps an example how one would use it?


Abusing forum power since 1986.

Offline

#3 2014-05-28 01:26:43

CatezeeY
Member
Registered: 2013-11-02
Posts: 6

Re: draw_background_tiled_partial_ext

xot wrote:

Can you provide a description of what this does and perhaps an example how one would use it?

Added a few things on the description of the script.

Offline

Board footer

Powered by FluxBB