You are not logged in.
Pages: 1
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.
/*
** 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.
I finally managed to fix the bug. but I had to use another script. I'll add it to let everyone use it.
Like I said, I added background_vtiled on the script for those backgrounds that doesn't have alpha transparency, Like the one at the image below.
And the 8 on the draw event is a typo, it's supposed to be 7. My fault
Hmmm. Kind of confusing.
It looks like you have set-up automatic background drawing for your room making this code sort of redundant. If you have background_vtiled[] set to false on these backgrounds, I think that's going to invoke a bug: height will be set to 0 and I don't think anything will be drawn. Your intentions aren't clear there. Perhaps nothing is being drawn and you are only seeing the automatic background drawing.
Some of the backgrounds I use have alpha transparency on certain areas.
I just want to make all the active backgrounds move along with the view.
background_x[i] = view_xview[i]/bgfx[i]
Hello, I used the draw_background_tiled_area_ext script from this site on a engine I'm working on.
/*
** Usage:
** draw_background_tiled_area_ext(background,x,y,x1,y2,x2,y2,color,alpha,index)
**
** Arguments:
** background the background to be drawn
** x,y the offset of the tiled area, as defined by a point
** the background will/would be drawn
** x1,y1 top left corner of the rectangle defining the area
** x2,y2 bottom right corner of the area
** color the color mask that you want to blend the background with
** alpha the alpha value to draw it at
**
** Notes:
** x1 MUST be less than x2, and y1 less than y2
** (x,y) doesn't have to be in the area, but if it is, then some
** drawn background will have it's origin at this point
**
** GMLscripts.com
*/
{
var bg,xx,yy,x1,y1,x2,y2;
bg = argument0;
xx = argument1;
yy = argument2;
x1 = argument3;
y1 = argument4;
x2 = argument5;
y2 = argument6;
index = argument9;
var bw,bh,i,j,jj,left,top,width,height,X,Y;
bw = background_get_width(bg);
bh = background_get_height(bg);
i = x1-((x1 mod bw) - (xx mod bw)) - bw*((x1 mod bw)<(xx mod bw));
j = y1-((y1 mod bh) - (yy mod bh)) - bh*((y1 mod bh)<(yy mod bh));
jj = j;
for(i=i; i<=x2; i+=bw) {
for(j=j; j<=y2; j+=bh) {
if(i <= x1) left = x1-i;
else left = 0;
X = i+left;
if(j <= y1) top = y1-j;
else top = 0;
Y = j+top;
if(x2 <= i+bw) width = ((bw)-(i+bw-x2)+1)-left;
else width = bw-left;
if (background_vtiled[index] == true) {
if(y2 <= j+bh) height = ((bh)-(j+bh-y2)+1)-top;
else height = bh-top;
}
else height = 0;
draw_background_part_ext(bg,left,top,width,height,X,Y,1,1,argument7,argument8);
}
j = jj;
}
}
NOTE: This is a modified version of the script. the original one can be found Here
I want to make the background move along with the view but everytime I test it. The backgrounds stay on the start position.
I'll provide the code of the object that draws the backgrounds.
Create Event:
for (i=0; i<7; i+=1) {
bgindex[i] = background_index[i];
bgyy[i] = background_y[i];
//Sets the background hspeed...
bghsp[i] = background_hspeed[i];
}
bgfx[0] = 1
bgfx[1] = 1.2
bgfx[2] = 1.4
bgfx[3] = 1.6
bgfx[4] = 1.8
bgfx[5] = 2.0
bgfx[6] = 2.2
bgfx[7] = 2.4
if (instance_number(obj_parallax) > 1)
instance_destroy();
Draw Event:
for (i=0; i<8; i+=1) {
if (background_index[i] == -1)
exit;
draw_background_tiled_area_ext(bgindex[i],view_xview[0]/bgfx[i]+bghsp[i],bgyy[i],0,0,room_width,room_height,background_blend[i],background_alpha[i],i);
}
I'm doing anything wrong?
Pages: 1