I want to make this square move back and forth (so that it looks like it’s vibrating or shaking) for several seconds before making it go upwards. How would I go about doing that? Thanks!
<
int y;
int yPos=350; // controls where it starts
Thanks! Can you please explain me to though how I would add that to the ellipses I already have and then make it move upwards? I tried implementing some of the code but it just goes upwards. I must be adding certain things in the incorrect order.
hi
this how to stop vibrate while moving if you want vibrate before moving there is other methods to do that as @Chrisir said you can use timer and you can use random instead of noise
float y;
int yPos=400; // controls where it starts
float vibrate = 0.0;
float noise = 8;
void setup(){
size(400,400);
}
void draw(){
background(0,0,200);
vibrate +=0.9;
float x = noise(vibrate)* noise ;
ellipse(100+x, yPos,40, 40);
yPos=yPos-1; // controls the speed
if (yPos>= height||yPos <= 350 ) {
vibrate =0;
}
{
//yPos=20;
}
}
fill(0, 10); // the 10 is supposed to control the speed of the blinks but doesn’t work
rect(0, 0, 0, width, height);
fill(255);
noStroke();
ellipse(random(width), random(height), 3, 3);
//rocket movement and vibration
vibrate +=10.0;
float x = noise(vibrate)* noise;
image(ship, 100+x, yPos, 100, 200);
yPos=yPos-2; // controls the speed
if (yPos>= height||yPos <= 350 ) {
vibrate =0;
}
{