void drawOffsetShiftBg() {
int hshift, vshift, shift;
int t = openborvariant("elapsed_time");
void logobg = glv("logobg");
int refresh_time = 2.2;
int width = 128, height = 128;
int vres = ov("vresolution");
int hres = ov("hresolution");
int i,i_s, i_d, x, y, z = 1; // i_s == i di sx e rispettivamente i_d i di destra
int t_fix = 2; // Soglia di aggiustamebto. Aggiunge un numero x di patterns
if ( logobg ) {
changedrawmethod(NULL(), "reset", 1);
changedrawmethod(NULL(), "enabled", 1);
//changedrawmethod(NULL(), "centerx", width/2); // ancoraggio
//changedrawmethod(NULL(), "centery", height/2);
// Dobbiamo scostare il pattern da hres a 0 e da vres a 0 ricordando che l'ancoraggio e offset(0,0)
// Poi dopo che si è oltre vres/hres ri ricomincia dacapo (ecco perchè il modulo)
// Facciamo ((hres/width)*width) e non semplicemente hres per cicominciare da capo nel giisto modo
// Ovvero non dobbiamo fare solo %hres ma dobbiamo considerare la lunghezza del pattern. cioè width finchè non ricopre la hres
hshift = (t/refresh_time)%((hres/width)*width);
vshift = (t/refresh_time)%((vres/height)*height);
x = hres-hshift; // posizione
y = vres-vshift;
//drawstring(160, 120,0,x);
/*
* Dobbiamo ricoprire l'intero schermo SEMPRE. Quindi quanti pattern disegnamo?
* Vediamo la riga horizzontale a sinistra dello sprite. Sappiamo che è alla coordinata x e che è lungo width.
* Quanti ne dobbiamo disegnare per coprire tutta la parte sinistra? Dobbiamo coprire una distanza x (da 0 a x).
* Quindi dobbiamo disegnarme x/width + qualche altro (forse 2 ) per coprire le mezze parti.
*/
//shift = 0;
// Occupiamoci di riempire la parte su (e poi sx/dx)
for (i = 0, i < (y/height)+t_fix; ++i) {
int new_y = y-(i*height);
drawsprite(logobg, x, new_y, z);
for (i_s = 0, i_s < (x/width)+t_fix; ++i_s) {
int new_x = x-(i_s*width);
drawsprite(logobg, new_x, new_y, z);
}
for (i_d = 0, i_d < ((hres-x)/width)+t_fix; ++i_d) {
int new_x = x+(i_d*width);
drawsprite(logobg, new_x, new_y, z);
}
}
// Occupiamoci di riempire la parte giù (e poi sx/dx)
for (i = 0, i < ((vres-y)/height)+t_fix; ++i) {
int new_y = y+(i*height);
drawsprite(logobg, x, new_y, z);
for (i_s = 0, i_s < (x/width)+t_fix; ++i_s) {
int new_x = x-(i_s*width);
drawsprite(logobg, new_x, new_y, z);
}
for (i_d = 0, i_d < ((hres-x)/width)+t_fix; ++i_d) {
int new_x = x+(i_d*width);
drawsprite(logobg, new_x, new_y, z);
}
}
changedrawmethod(NULL(), "reset", 1);
changedrawmethod(NULL(), "enabled", 0);
}
}