
Welcome to Processing
First Program

It allows to create an ellipse,
This center is on x=50 and y=50 and the diameter is 80.
​
Second Program

The ball follows the mouse and changes color when the mouse is pressed
Third Program

The last is automatic when the ball is thrown automatically and when it meets an edge it starts again in the other direction.
Final Program
int nombrederectangles = 10;
int x = 0;
int rad = 10;
int bull = 20;
int ball = 25;
float[] xpos,ypos;
int nbr =10;
float xspeed = 10.0;
float yspeed = 6.5;
int xposbouton,yposbouton;
int[] xdirection ;
int[] ydirection ;
int nombredetirsreussis =0;
void setup()
{
fullScreen();
// 4 tableaux de 10 cases chacun contiennent la position en x et en y du centre de chaque base et le sens de déplacement
xdirection = new int[10];
ydirection = new int[10];
xpos = new float[10];
ypos = new float[10];
xposbouton = width-120;
yposbouton=40;
noStroke();
frameRate(30);
ellipseMode(RADIUS);
for(int i=0; i<10;i++){
xpos[i] = random(25,350);
ypos[i] = random(25,350);
xdirection[i] = 1;
ydirection[i] = 1;
}
}
void draw()
{
background(20);
fill(255);
rect(xposbouton,yposbouton,100,100,7);
textSize(20);
fill(0);
text("Recharger",width-120,90);
fill(255);
if(width > 500 ){
textSize(30);
}
text("Your score is " + x, 15, 35);
if(nombredetirsreussis==10){
textSize(30);
text("you win !!! " + x, width/2-100,height/2);}
if(millis()<5000) {
textSize(20);
text("Press button to reload.", 15, 60);
}
for (int r = 0; r <nombrederectangles; r++) {
fill(255);
noStroke();
rect(width-50,height-170+15*r,40,10);
}
noFill();
for(int i=0; i<10;i++){
xpos[i] = xpos[i] + ( xspeed * xdirection[i] );
ypos[i] = ypos[i] + ( yspeed * ydirection[i] );
if(mousePressed){
if(nombrederectangles >0){
if(xpos[i]-ball<mouseX && ypos[i]-ball<mouseY && mouseX<xpos[i]+ball && mouseY<ypos[i]+ball){
xpos[i] = 100000;
xdirection[i] = 0;
ydirection[i] =0;
x= x+10;
nombredetirsreussis = nombredetirsreussis +1;
}
}
}
if(xpos[i] > width-rad || xpos[i] < rad){
xdirection[i]*=-1;
}
if(ypos[i] > height-rad || ypos[i] < rad){
ydirection[i]*=-1;
}
fill(213,220,245);
ellipse(xpos[i],ypos[i],ball,ball);
fill(103,136,250);
ellipse(xpos[i],ypos[i],bull,bull);
fill(0,56,252);
ellipse(xpos[i],ypos[i],rad,rad);
}
if(mousePressed){
stroke(255,255,0);
}else{
stroke(255,0,0);
}
noFill();
ellipse(mouseX , mouseY,30,30 );
strokeWeight(2.2);
line(mouseX-30,mouseY,mouseX+30,mouseY);
line(mouseX,mouseY-30,mouseX,mouseY+30);
noStroke();
}
void mousePressed(){
if (xposbouton<mouseX && xposbouton+100>mouseX && yposbouton<mouseY && yposbouton+100>mouseY) {
nombrederectangles = 10;
}else{
nombrederectangles = nombrederectangles - 1;
}
}