I'm trying to make the background constantly sliding from right to left without using
background() in
draw()...
Quote:// init
Test my_test;
Vector stack;
void setup ()
{
size (800, 600);
framerate (30);
background (255);
//
my_test = new Test (width/2, height/2);
stack = new Vector ();
//
stack.add (my_test);
}
void draw ()
{
AbstractTest current = (AbstractTest) stack.get(0);
// translate (-current._x+width/2, 0);
current.main ();
//
copy (0,0, width,height, -1,0, width-1,height);
}
class Test extends AbstractTest
{
// constr
Test (float x, float y)
{
a = -1;
_x = oldx = x;
_y = oldy = y;
}
// methods
void main ()
{
ceta = 1.6 * sin (a);
_x += 4 * cos (ceta);
_y += 4 * sin (ceta);
a += PI/180 * 1.6;
//
stroke (0, 255);
line (_x, _y, oldx, oldy);
//
oldx = _x;
oldy = _y;
}
}
class AbstractTest
{
// properties
float _x, _y, oldx, oldy;
float ceta, a;
AbstractTest (){}
// callbacks
void main (){}
}
I'm actually making a copy of the stage then paste it 1 pixel further to the left every frame but once _x position of the drawing reaches
width, there's no way to copy what's actually drawn outside the stage and i'm stuck on a (stupid?) problem that should be solvable by a combination of
translate () and
copy ()...
If anyone has already done that or knows about another way of doing it, any help very welcome ^^