We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Basically I want the rotatingObject() to be with the movingObject() as it moves. Also I want that when you press the 's' key, the movingObject() "resets", it will appear at the top and move down again.
float xspeed = 5;
float yspeed= 3;
float x = 480;
float y = -100;
float theta;
void setup () {
background(255);
size(960, 640);
}
void draw () {
background(255);
rotatingObject();
movingObject();
}
void movingObject() {
noFill();
ellipse(x, y, 25, 25);
ellipse(x, y, 100, 300);
y=y+yspeed;
if (y >= height/2) {
yspeed =0;
x = x + xspeed;
if ((x > width - 105) || (x < 105)) {
xspeed = xspeed * -1;
}
}
}
void rotatingObject() {
noFill();
translate(width/2, height/2);
pushMatrix();
rotate(theta);
ellipse(0, 0, 25, 25);
rectMode(CENTER);
rect(0, 0, 100, 100);
theta += 0.02;
popMatrix();
strokeWeight(1);
translate(-480, -320);
}
Answers