Not sure I got your question.
You have several options:
1) You can change the frame-rate of your sketch, but that would cause ALL drawings to change speed.
2) You act on one of your images only ever x-th frame, so that the value of x slows the movement.
3) The "speed" (the offset) you are moving your image with each redraw is different for your objects.
Sketch 1: 2 balls moving left-right with same speed. Pressing +/- changes the framerate.
Quote:PVector Pos1;
PVector Pos2;
void setup()
{
size(600,100);
stroke(255);
strokeWeight(10);
Pos1 = new PVector(20,30); // just a starting position
Pos2 = new PVector(20,80); // just a starting position
}
void draw()
{
background(0);
point(Pos1.x,Pos1.y);
point(Pos2.x,Pos2.y);
Pos1.x+=5; // shift position 5 pixels to the right by adding 5
Pos2.x+=5; // shift position 5 pixels to the right by adding 5
if (Pos1.x>=width) Pos1.x-=width; // warp at right boarder
if (Pos2.x>=width) Pos2.x-=width; // warp at right boarder
}
void keyPressed()
{
if (key=='+') frameRate(min(30,frameRate+5));
if (key=='-') frameRate(max(1,frameRate-5));
}
Seketch 2: Two balls at different speed by adding different "velocity"
Quote:PVector Pos1;
PVector Pos2;
void setup()
{
size(600,100);
stroke(255);
strokeWeight(10);
Pos1 = new PVector(20,30); // just a starting position
Pos2 = new PVector(20,80); // just a starting position
}
void draw()
{
background(0);
point(Pos1.x,Pos1.y);
point(Pos2.x,Pos2.y);
Pos1.x+=5; // shift position 5 pixels to the right by adding 5
Pos2.x+=1; // shift position 1 pixel to the right by adding 1
if (Pos1.x>=width) Pos1.x-=width; // warp at right boarder
if (Pos2.x>=width) Pos2.x-=width; // warp at right boarder
}
void keyPressed()
{
if (key=='+') frameRate(min(30,frameRate+5));
if (key=='-') frameRate(max(1,frameRate-5));
}
Sketch 3: Different speed by acting every 5th frame only.
Quote:PVector Pos1;
PVector Pos2;
void setup()
{
size(600,100);
stroke(255);
strokeWeight(10);
Pos1 = new PVector(20,30); // just a starting position
Pos2 = new PVector(20,80); // just a starting position
}
void draw()
{
background(0);
point(Pos1.x,Pos1.y);
point(Pos2.x,Pos2.y);
Pos1.x+=5; // shift position 5 pixels to the right by adding 5
if (frameCount%5==0) Pos2.x+=5; // shift every 5th update only
if (Pos1.x>=width) Pos1.x-=width; // warp at right boarder
if (Pos2.x>=width) Pos2.x-=width; // warp at right boarder
}
void keyPressed()
{
if (key=='+') frameRate(min(30,frameRate+5));
if (key=='-') frameRate(max(1,frameRate-5));
}