void setup/void draw problem
in
Programming Questions
•
1 year ago
Hello,
I'm new to Processing and this is my first post on this forum. I'm working on a simple animation project for a class and I've hit a snag. For the animation, I'm trying to get a couple of rectangles to move across the screen using the Wrap Around technique. I also have mouse input- a small dot that follows the arrow around the screen. The code I've created is below. The void draw seems to be controlling the speed at which the dot follows the arrow, but the rectangles aren't moving. I have a feeling that a simple change is all that's needed, but the changes I've tried haven't made a difference. What am I missing?
int center=40;
float x= -center;
float speed=30;
void setup(){
frameRate(30);// Thirty frames each second
size(640,480);// size of window
background(51);
smooth();
strokeWeight(2);
rectMode(CENTER);
}
void draw(){
background(51);
x+=speed;// Increase the value of x
if(x>width+center){ //If the shape is off the screen,
x= -center;// move to the left edge
}
ellipse(mouseX,mouseY,9,9);
fill(153);
rect(100,150,160,20);
fill(153);
rect(500,150,20,5);
fill(247,149,42);
ellipse(278,500,400,400);
fill(56,108,83);
ellipse(120,40,110,110);
fill(0,255,0);
ellipse(412,60,18,18);
}
1