Guys pls help I don’t know why this code runs really slow.
//SEQUENCES OF MOVING CIRCLES
float xPosition = 0;
float yPosition;
float aPosition = 0;
float bPosition;
float onePosition = 0;
float twoPosition;
float threePosition = 0;
float fourPosition;
float fivePosition = 0;
float sixPosition;
float sevenPosition = 0;
float eightPosition;
float ninePosition = 0;
float tenPosition;
float elevenPosition = 0;
float twelvePosition;
float thirteenPosition = 0;
float fourteenPosition;
float fifteenPosition = 0;
float sixteenPosition;
float seventeenPosition = 0;
float eighteenPosition;
float nineteenPosition = 0;
float tweentyPosition;
float tweentyonePosition = 0;
float tweentytwoPosition;
//ANIMATED GIF
PImage[] gifone = new PImage[67];
int gifoneX = -100, gifoneY = 0;
void setup () {
fullScreen (P3D);
frameRate(50);
smooth();
noStroke ();
//sequences of moving circles
bPosition = 100;
yPosition = 150;
twoPosition = 200;
fourPosition = 250;
sixPosition = 300;
eightPosition = 350;
tenPosition = 400;
twelvePosition = 450;
fourteenPosition = 500;
eighteenPosition = 550;
tweentyPosition = 600;
tweentytwoPosition = 650;
gifone[0] = loadImage( “0.gif” );
gifone[1] = loadImage( “1.gif” );
gifone[2] = loadImage( “2.gif” );
gifone[3] = loadImage( “3.gif” );
gifone[4] = loadImage( “4.gif” );
gifone[5] = loadImage( “5.gif” );
gifone[6] = loadImage( “6.gif” );
gifone[7] = loadImage( “7.gif” );
gifone[8] = loadImage( “8.gif” );
gifone[9] = loadImage( “9.gif” );
gifone[10] = loadImage( “10.gif” );
gifone[11] = loadImage( “11.gif” );
gifone[12] = loadImage( “12.gif” );
gifone[13] = loadImage( “13.gif” );
gifone[14] = loadImage( “14.gif” );
gifone[15] = loadImage( “15.gif” );
gifone[16] = loadImage( “16.gif” );
gifone[17] = loadImage( “17.gif” );
gifone[18] = loadImage( “18.gif” );
gifone[19] = loadImage( “19.gif” );
gifone[20] = loadImage( “20.gif” );
gifone[21] = loadImage( “21.gif” );
gifone[22] = loadImage( “22.gif” );
gifone[23] = loadImage( “23.gif” );
gifone[24] = loadImage( “24.gif” );
gifone[25] = loadImage( “25.gif” );
gifone[26] = loadImage( “26.gif” );
gifone[27] = loadImage( “27.gif” );
gifone[28] = loadImage( “28.gif” );
gifone[29] = loadImage( “29.gif” );
gifone[30] = loadImage( “30.gif” );
gifone[31] = loadImage( “31.gif” );
gifone[32] = loadImage( “32.gif” );
gifone[33] = loadImage( “33.gif” );
gifone[34] = loadImage( “34.gif” );
gifone[35] = loadImage( “35.gif” );
gifone[36] = loadImage( “36.gif” );
gifone[37] = loadImage( “37.gif” );
gifone[38] = loadImage( “38.gif” );
gifone[39] = loadImage( “39.gif” );
gifone[40] = loadImage( “40.gif” );
gifone[41] = loadImage( “41.gif” );
gifone[42] = loadImage( “42.gif” );
gifone[43] = loadImage( “43.gif” );
gifone[44] = loadImage( “44.gif” );
gifone[45] = loadImage( “45.gif” );
gifone[46] = loadImage( “46.gif” );
gifone[47] = loadImage( “47.gif” );
gifone[48] = loadImage( “48.gif” );
gifone[49] = loadImage( “49.gif” );
gifone[50] = loadImage( “50.gif” );
gifone[51] = loadImage( “51.gif” );
gifone[52] = loadImage( “52.gif” );
gifone[53] = loadImage( “53.gif” );
gifone[54] = loadImage( “54.gif” );
gifone[55] = loadImage( “55.gif” );
gifone[56] = loadImage( “56.gif” );
gifone[57] = loadImage( “57.gif” );
gifone[58] = loadImage( “58.gif” );
gifone[59] = loadImage( “59.gif” );
gifone[60] = loadImage( “60.gif” );
gifone[61] = loadImage( “61.gif” );
gifone[62] = loadImage( “62.gif” );
gifone[63] = loadImage( “63.gif” );
gifone[64] = loadImage( “64.gif” );
gifone[65] = loadImage( “65.gif” );
gifone[66] = loadImage( “66.gif” );
}
void mousePressed () {
noLoop ();
}
void mouseReleased () {
loop ();
}
void draw () {
background(255);
//animated gif
image( gifone[frameCount%67], gifoneX, gifoneY);
gifoneX = gifoneX + 5;
if ( gifoneX > width + 10) {
gifoneX = -250;
}
loop();
//sequences of circles
//ab
fill (0, 20, 220);
ellipse(aPosition, bPosition, 50, 50);
aPosition +=10;
//xy
fill (0, 20, 220);
ellipse(xPosition, yPosition, 50, 50);
xPosition +=20;
//12
fill (0, 20, 220);
ellipse(onePosition, twoPosition, 50, 50);
onePosition +=30;
//34
fill (0, 20, 220);
ellipse(threePosition, fourPosition, 50, 50);
threePosition +=40;
//56
fill (0, 20, 220);
ellipse(fivePosition, sixPosition, 50, 50);
fivePosition +=50;
//78
fill (0, 20, 220);
ellipse(sevenPosition, eightPosition, 50, 50);
sevenPosition +=60;
//910
fill (0, 20, 220);
ellipse(ninePosition, tenPosition, 50, 50);
ninePosition +=70;
//1112
fill (0, 20, 220);
ellipse(elevenPosition, twelvePosition, 50, 50);
elevenPosition +=70;
//1314
fill (0, 20, 220);
ellipse(thirteenPosition, fourteenPosition, 50, 50);
thirteenPosition +=80;
//1516
fill (0, 20, 220);
ellipse(fifteenPosition, sixteenPosition, 50, 50);
fifteenPosition +=90;
//1718
fill (0, 20, 220);
ellipse(seventeenPosition, eighteenPosition, 50, 50);
seventeenPosition +=100;
//1920
fill (0, 20, 220);
ellipse(nineteenPosition, tweentyPosition, 50, 50);
nineteenPosition +=110;
//2122
fill (0, 20, 220);
ellipse(tweentyonePosition, tweentytwoPosition, 50, 50);
tweentyonePosition +=120;
loop ();
//interactive spheres
//sphere1
translate(150, height/2, 0);
rotateX(mouseY * 0.05);
rotateY(mouseX * 0.05);
fill(mouseX * 2, 0, 160);
sphereDetail(mouseX / 1);
sphere(30);
noStroke();
directionalLight(250, 230, 255, -1, 0, 0);
//sphere 2
translate(200, height/2, 0);
rotateX(mouseY * 0.05);
rotateY(mouseX * 0.05);
fill(mouseX * 2, 0, 160);
sphereDetail(mouseX / 4);
sphere(20);
noStroke();
directionalLight(250, 230, 255, -1, 0, 0);
//sphere 3
translate(300, height/2, 0);
rotateX(mouseY * 0.05);
rotateY(mouseX * 0.05);
fill(mouseX * 2, 0, 160);
sphereDetail(mouseX / 4);
sphere(30);
noStroke();
directionalLight(250, 230, 255, -1, 0, 0);
//sphere 4
translate(400, height/2, 0);
rotateX(mouseY * 0.05);
rotateY(mouseX * 0.05);
fill(mouseX * 2, 0, 160);
sphereDetail(mouseX / 4);
sphere(40);
noStroke();
directionalLight(250, 230, 255, -1, 0, 0);
//sphere 5
translate(500, height/2, 0);
rotateX(mouseY * 0.05);
rotateY(mouseX * 0.05);
fill(mouseX * 2, 0, 160);
sphereDetail(mouseX / 4);
sphere(50);
noStroke();
directionalLight(250, 230, 255, -1, 0, 0);
//sphere 6
translate(600, height/2, 0);
rotateX(mouseY * 0.05);
rotateY(mouseX * 0.05);
fill(mouseX * 2, 0, 160);
sphereDetail(mouseX / 4);
sphere(60);
noStroke();
directionalLight(250, 230, 255, -1, 0, 0);
//sphere 7
translate(700, height/2, 0);
rotateX(mouseY * 0.05);
rotateY(mouseX * 0.05);
fill(mouseX * 2, 0, 160);
sphereDetail(mouseX / 4);
sphere(70);
noStroke();
directionalLight(250, 230, 255, -1, 0, 0);
}