# Bubble shooting game

**URL:** https://discourse.processing.org/t/bubble-shooting-game/10919
**Category:** Libraries
**Tags:** homework
**Created:** [May 4, 2019, 8:59pm UTC](https://discourse.processing.org/t/bubble-shooting-game/10919 "2019-05-04T20:59:10Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![yoyo18](https://avatars.discourse-cdn.com/v4/letter/y/a183cd/32.png) [@yoyo18](https://discourse.processing.org/u/yoyo18)
#### Post date: [May 4, 2019, 8:59pm UTC](https://discourse.processing.org/t/bubble-shooting-game/10919/1 "2019-05-04T20:59:10Z")

</div>

hello i start to make code for a game the rules was in 3lines we shoot bubles blue or red and when they meet they dead  
i need help for the meet code(a friend try to do something in my code as you can see and to do a random player i try something it can’t work for the red bubles to play alone with the coomputer sorry for my english i was french i need it in 3days

````auto
PImage terrain;//image fond
float temps;
float ligne;
float val = 500;
float antispam1 = -1000;
float antispam2 = -1000;
ArrayList uniteA = new ArrayList(); // Tableau des unités alliés
ArrayList uniteE = new ArrayList(); // Tableau des unités ennemies
float compA=-1;//Variable de comparaison
float compA2=-1;//Variable de comparaison
float compE=-1;//Variable de comparaison
float compE2=-1;//Variable de comparaison

void setup()
{
 smooth();
 size(1400,600);//taille fenêtre
 terrain=loadImage("terrain.jpg");//image fond
 terrain.resize(1400,600);//remise a la bonne taille
}

void draw() 
{
 background(terrain);
 creationEnnemis();
  for (int i = 0; i < uniteA.size(); i++) {
    bleu ball = (bleu) uniteA.get(i);
    ball.deplacementA();
    ball.display();
}
  for (int i = 0; i < uniteE.size(); i++) {
    rouge ball = (rouge) uniteE.get(i);
    ball.deplacementE();
    ball.display();
  }
  
if(compA>compE && compA2==compE2 ){print("test");}//intéraction entre les unités
if(compA==1400){clear();stop();textSize(40);
text("Victoire Bleue", 600, 300); }
if(compE==0){clear();stop();textSize(40);
text("Victoire Rouge", 600, 300); }
}

class bleu{ // On crée une classe (ou un objet) unité allié qui aura tous ces paramètres
  //Déclaration des paramètres de base de la balle
  float x;
  float y;
  float comp;
  color couleur;
  float deplacement;

  //Constructeur de l'unité
  bleu (float nouvX, float nouvY, float nouvComp, color nouvCouleur) { //Pos x, Pos y, vérification, Couleur (Pour chaque unité créer il faudra lui donner en parametre une posx, une pos y ... (exemple : new unite(50,100,1,color(30,144,255)) 
 
    this.x = nouvX; //position X
    this.y = nouvY; //position Y
    this.comp = nouvComp; //variable de vérification de l'unité
    this.couleur = nouvCouleur; //couleur de l'unité
  }
  
 void deplacementA(){
    deplacement++;
    for (int i = 0; i < uniteA.size(); i++) {
    bleu ball = (bleu) uniteA.get(i);
    ball.display();
   }
  }
     void display() {
    fill(couleur);
    ellipse(comp=deplacement*2,compA2= y, 40, 40);
    compA=comp;
  }}

class rouge{ // On crée une classe (ou un objet) unité allié qui aura tous ces paramètres
  //Déclaration des paramètres de base de la balle
  float x;
  float y;
  color couleur;
  float deplacement;
  float comp;

  //Constructeur de l'unité
  rouge (float nouvX, float nouvY, float nouvComp, color nouvCouleur) { //Pos x, Pos y, Couleur (Pour chaque unité créer il faudra lui donner en parametre une posx, une pos y ... (exemple : new unite(50,100,color(30,144,255)) 
 
    this.x = nouvX; //position X
    this.y = nouvY; //position Y
    this.couleur = nouvCouleur; //couleur de l'unité
    this.comp = nouvComp;
  }
  
 void deplacementE(){
    deplacement++;
    for (int i = 0; i < uniteE.size(); i++) {
    rouge ball = (rouge) uniteE.get(i);
    ball.display();
   }
  }
     void display() {
    fill(couleur);
    ellipse(comp=1350-deplacement*2,compE2= y, 40, 40);
    compE=comp;
  }}

void keyReleased(){
    
    temps = millis(); // la fonction millis() donne le temps depuis que le programme a démarré (en millisecondes)
        ligne=random(1,3); // on créer une variable temps qui va etre = à sa
    
 for(int i=0; i<temps;i++) { //antispam... est déclaré au debut et est égal à -1000 (-1000 car comme sa on peut cliquer des que le programme se lance)
                                                              // car quand on lance le programme "temps" sera égal à 0 et quelques et ducoup sa sera bien, >= à (-1000 +1000 donc 0)
      if (key == 'a'&& temps >= antispam1 +val){
        uniteA.add( new bleu(50,200,1,color(30,144,255)));
         // On cree une unité qui s'ajoute dans le tableau "uniteJ" avec une posX, posY, une variable de comparaison et une couleur     
      }
       if (key == 'q'&& temps >= antispam1 +val){
        uniteA.add( new bleu(50,300,1,color(30,144,255))); // On cree une unité qui s'ajoute dans le tableau "uniteJ" avec une posX, posY, une variable de comparaison et une couleur     
      }
       if (key == 'w'&& temps >= antispam1 +val){
        uniteA.add( new bleu(50,400,1,color(30,144,255))); // On cree une unité qui s'ajoute dans le tableau "uniteJ" avec une posX, posY, une variable de comparaison et une couleur     
      }
      
      antispam1 = temps;
      
      //touches ennemies
      if (key == 'p'&& temps >= antispam2 +val){
        uniteE.add( new rouge(1350,200,1, color(237,0,0))); // On cree une unité qui s'ajoute dans le tableau "uniteJ" avec une posX, posY, une variable de comparaison et une couleur     
      }//key == 'p'
      if (key == 'm'&& temps >= antispam2 +val){
        uniteE.add( new rouge(1350,300,1, color(237,0,0))); // On cree une unité qui s'ajoute dans le tableau "uniteJ" avec une posX, posY, une variable de comparaison et une couleur     
      }
      if (key == '!'&& temps >= antispam2 +val){
        uniteE.add( new rouge(1350,400,1,color(237,0,0))); // On cree une unité qui s'ajoute dans le tableau "uniteJ" avec une posX, posY, une variable de comparaison et une couleur     
      }
     
      antispam2 = temps;
 }}

void creationEnnemis() {
  temps = millis();
  temps= random(2400);
 ligne=random(1,3);

while(compE==0 & compA==1400){
if (ligne == 1){
        ellipse(1350,200,1, color(237,0,0)); // On cree une unité qui s'ajoute dans le tableau "uniteJ" avec une posX, posY, une variable de comparaison et une couleur     
      }
      if (ligne == 2){
         ellipse(1350,300,1, color(237,0,0)); // On cree une unité qui s'ajoute dans le tableau "uniteJ" avec une posX, posY, une variable de comparaison et une couleur     
      }
      if (ligne == 3){
        ellipse(1350,400,1,color(237,0,0)); // On cree une unité qui s'ajoute dans le tableau "uniteJ" avec une posX, posY, une variable de comparaison et une couleur     
      }
      
}}
```thanks
````

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [May 5, 2019, 5:12am UTC](https://discourse.processing.org/t/bubble-shooting-game/10919/2 "2019-05-05T05:12:44Z")

</div>

> [@yoyo18](#):
>
> in 3lines we shoot bubles blue or red and when they meet they dead

Are you trying to do that in 3 lines of code …?

> [@yoyo18](#):
>
> i need it in 3days

Is this homework?

---

<div class="post-metadata">

### Author: ![yoyo18](https://avatars.discourse-cdn.com/v4/letter/y/a183cd/32.png) [@yoyo18](https://discourse.processing.org/u/yoyo18)
#### Post date: [May 5, 2019, 8:39am UTC](https://discourse.processing.org/t/bubble-shooting-game/10919/3 "2019-05-05T08:39:02Z")

</div>

thats a projet i make for school and my teacher would like to see it but when i answer my question i dont no how to help me

for colision i try to do 🙂`if(compA>compE && compA2==compE2 ){print("test");}` but its always the last bubble and its in every lines not in 1 so a bublle in the 1lines dead when she meet a bubble in the 2lines

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [May 5, 2019, 5:50pm UTC](https://discourse.processing.org/t/bubble-shooting-game/10919/4 "2019-05-05T17:50:22Z")

</div>

> [@yoyo18](#):
>
> a bubble in the 2lines

I still don’t understand this. I don’t know what “3lines” or “2lines” is. Is it code line number 2? Is it the upper or lower line of bubbles?

Maybe just try writing your question in French?

> [@yoyo18](#):
>
> i try something it can’t work for the red bubles to play alone with the coomputer

What are you trying to fix, specifically? Make the computer play? Make the bubbles do something when they touch? Explain A) what it does now, and B) what you want to change, specifically.

---

<div class="post-metadata">

### Author: ![yoyo18](https://avatars.discourse-cdn.com/v4/letter/y/a183cd/32.png) [@yoyo18](https://discourse.processing.org/u/yoyo18)
#### Post date: [May 5, 2019, 5:55pm UTC](https://discourse.processing.org/t/bubble-shooting-game/10919/5 "2019-05-05T17:55:10Z")

</div>

3lines and 2lines is the three place who we can send bubbles  
i try to make the computeru play and i try to make a action when bubbles touch like erase the bubbles who touch  
thanks

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [May 5, 2019, 8:13pm UTC](https://discourse.processing.org/t/bubble-shooting-game/10919/6 "2019-05-05T20:13:19Z")

</div>

idea for the game

I had to remove some stuff…

- antispam1 & antispam1

- compA & compE

```auto

// https://discourse.processing.org/t/need-help-for-a-game/10919
PImage terrain;//image fond
float temps;
float ligne;
float val = 500;
float antispam1 = -1000;
float antispam2 = -1000;

ArrayList uniteA = new ArrayList(); // Tableau des unités alliés
ArrayList uniteE = new ArrayList(); // Tableau des unités ennemies

float compA=-1;//Variable de comparaison
float compA2=-1;//Variable de comparaison
float compE=-1;//Variable de comparaison
float compE2=-1;//Variable de comparaison

void setup()
{
  // smooth();
  size(1400, 600);//taille fenêtre
  terrain=loadImage("terrain.jpg");//image fond
  //terrain.resize(1400, 600);//remise a la bonne taille

  // creationEnnemis();
}

void draw() 
{
  // background(terrain);
  background(122);

  for (int i = 0; i < uniteA.size(); i++) {
    bleu ball = (bleu) uniteA.get(i);
    //ball.deplacementA();
    ball.display();
  }
  for (int i = 0; i < uniteE.size(); i++) {
    rouge ball = (rouge) uniteE.get(i);
    //ball.deplacementE();
    ball.display();
  }

  // -------------------------------------

  for (int i = 0; i < uniteA.size(); i++) {
    bleu ball1 = (bleu) uniteA.get(i);
    if (ball1.isAlive) {
      for (int i1 = 0; i1 < uniteE.size(); i1++) {
        rouge ball2 = (rouge) uniteE.get(i1);
        if (ball2.isAlive&&dist(ball1.x, ball1.y, ball2.x, ball2.y) < 7) {
          text("hit", ball1.x, ball1.y);
          ball1.isAlive=false;
          ball2.isAlive=false;
          print("HIT");
        }//if
      }//for
    }//if
  }//for 

  // -------------------------------------

  if (compA>compE && compA2==compE2 ) {
    // print("test");
  }//intéraction entre les unités

  if (compA==1400) {
    clear();
    stop();
    textSize(40);
    text("Victoire Bleue", 600, 300);
  }
  if (compE==0) {
    clear();
    stop();
    textSize(40);
    text("Victoire Rouge", 600, 300);
  }
}

// ------------------------------------------------------------------------

void keyReleased() {

  // la fonction millis() donne le temps depuis que le programme a démarré (en millisecondes)
  temps = millis();                                     

  // on créer une variable temps qui va etre = à sa
  ligne = random(1, 3);                                                

  // for (int i=0; i<temps; i++) {   
  //antispam... est déclaré au debut et est égal à -1000 (-1000 car comme sa on peut cliquer des que le programme se lance)
  // car quand on lance le programme "temps" sera égal à 0 et quelques et ducoup sa sera bien, >= à (-1000 +1000 donc 0)
  if (key == 'a') {
    uniteA.add( new bleu(50, 200, 1, color(30, 144, 255)));
    // On cree une unité qui s'ajoute dans le tableau "uniteJ" avec une posX, posY, une variable de comparaison et une couleur
  } else if (key == 'q') {
    uniteA.add( new bleu(50, 300, 1, color(30, 144, 255))); // On cree une unité qui s'ajoute dans le tableau "uniteJ" avec une posX, posY, une variable de comparaison et une couleur
  } else if (key == 'w') {
    uniteA.add( new bleu(50, 400, 1, color(30, 144, 255))); // On cree une unité qui s'ajoute dans le tableau "uniteJ" avec une posX, posY, une variable de comparaison et une couleur
  }

  //antispam1 = temps;

  //touches ennemies
  if (key == 'p') {
    uniteE.add( new rouge(1350, 200, 1, color(237, 0, 0))); // On cree une unité qui s'ajoute dans le tableau "uniteJ" avec une posX, posY, une variable de comparaison et une couleur
  }//key == 'p'
  else if (key == 'm') {
    uniteE.add( new rouge(1350, 300, 1, color(237, 0, 0))); // On cree une unité qui s'ajoute dans le tableau "uniteJ" avec une posX, posY, une variable de comparaison et une couleur
  } else if (key == '!') {
    uniteE.add( new rouge(1350, 400, 1, color(237, 0, 0))); // On cree une unité qui s'ajoute dans le tableau "uniteJ" avec une posX, posY, une variable de comparaison et une couleur
  }

  //antispam2 = temps;
  // }
}

void creationEnnemis22222222222222222222222222() {
  temps = millis();
  temps= random(2400);
  ligne=random(1, 3);

  while (compE==0 & compA==1400) {
    if (ligne == 1) {
      ellipse(1350, 200, 1, color(237, 0, 0)); // On cree une unité qui s'ajoute dans le tableau "uniteJ" avec une posX, posY, une variable de comparaison et une couleur
    } else if (ligne == 2) {
      ellipse(1350, 300, 1, color(237, 0, 0)); // On cree une unité qui s'ajoute dans le tableau "uniteJ" avec une posX, posY, une variable de comparaison et une couleur
    } else if (ligne == 3) {
      ellipse(1350, 400, 1, color(237, 0, 0)); // On cree une unité qui s'ajoute dans le tableau "uniteJ" avec une posX, posY, une variable de comparaison et une couleur
    } else {
    }
  }
}

// ========================================================================================

class bleu {              
  // On crée une classe (ou un objet) unité allié qui aura tous ces paramètres
  //Déclaration des paramètres de base de la balle
  float x;
  float y;
  float comp;
  color couleur;
  float deplacement;
  boolean isAlive=true; 

  //Constructeur de l'unité
  bleu (float nouvX, float nouvY, 
    float nouvComp, 
    color nouvCouleur) {  
    //Pos x, Pos y, vérification, Couleur 
    //(Pour chaque unité créer il faudra lui donner en parametre une posx, une pos y ... (exemple : new unite(50,100,1,color(30,144,255)) 

    this.x = nouvX; //position X
    this.y = nouvY; //position Y
    this.comp = nouvComp; //variable de vérification de l'unité
    this.couleur = nouvCouleur; //couleur de l'unité
  }

  // void deplacementA() {
  // deplacement++;
  // for (int i = 0; i < uniteA.size(); i++) {
  // bleu ball = (bleu) uniteA.get(i);
  // ball.display();
  // }
  // }
  void display() {
    if (!isAlive)
      return; 
    deplacement++;
    fill(couleur);
    ellipse(x=deplacement*2, y, 40, 40);
    compA=comp;
  }
}

// ========================================================================================

class rouge {  
  // On crée une classe (ou un objet) unité allié qui aura tous ces paramètres
  //Déclaration des paramètres de base de la balle
  float x;
  float y;
  color couleur;
  float deplacement;
  float comp;
  boolean isAlive=true; 

  //Constructeur de l'unité
  rouge (float nouvX, float nouvY, 
    float nouvComp, 
    color nouvCouleur) {    
    //Pos x, Pos y, Couleur (Pour chaque unité créer il faudra lui donner en parametre une posx, une pos y ... (exemple : new unite(50,100,color(30,144,255)) 

    this.x = nouvX; //position X
    this.y = nouvY; //position Y
    this.couleur = nouvCouleur; //couleur de l'unité
    this.comp = nouvComp;
  }

  //void deplacementE() {
  // deplacement++;
  // for (int i = 0; i < uniteE.size(); i++) {
  // rouge ball = (rouge) uniteE.get(i);
  // ball.display();
  // }
  //}
  void display() {
    if (!isAlive)
      return; 
    deplacement++;
    fill(couleur);
    ellipse(x=1350-deplacement*2, y, 40, 40);
    compE=comp;
  }
}
// ========================================================================================
//

```

---

<div class="post-metadata">

### Author: ![yoyo18](https://avatars.discourse-cdn.com/v4/letter/y/a183cd/32.png) [@yoyo18](https://discourse.processing.org/u/yoyo18)
#### Post date: [May 6, 2019, 8:02am UTC](https://discourse.processing.org/t/bubble-shooting-game/10919/7 "2019-05-06T08:02:10Z")

</div>

Thanks you so much I have to try this  
And do you have some idea to make a computer player for red bubbles wich send bubbles randomly in different lines

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [May 6, 2019, 8:27am UTC](https://discourse.processing.org/t/bubble-shooting-game/10919/8 "2019-05-06T08:27:37Z")

</div>

> do you have some idea to make a computer player for red bubbles wich send bubbles randomly in different lines

in the function creationEnnemis: Here you check ligne, that is good

For the rest proceed like in keyreleased and add things to the arraylist

(And remove dead ones from the arraylist)

**Here is an example for the computer shooting**

call creationEnnemis() from draw() please

```auto
void creationEnnemis() {

  // computer move

  // temps = millis();
  temps= random(100);
  ligne=int(random(1, 4));

  if (temps>2) // in most cases 
    return; // we leave here

  int yValue=0; 

  if (ligne == 1) {
    yValue=200;
  } else if (ligne == 2) {
    yValue=300;
  } else if (ligne == 3) {
    yValue=400;
  } else {
    //
  }

  uniteE.add( new rouge(1350, yValue, 1, color(237, 0, 0))); // On cree une unité qui s'ajoute dans le tableau "uniteJ" avec une posX, posY, une variable de comparaison et une couleur
}

```

---

<div class="post-metadata">

### Author: ![yoyo18](https://avatars.discourse-cdn.com/v4/letter/y/a183cd/32.png) [@yoyo18](https://discourse.processing.org/u/yoyo18)
#### Post date: [May 6, 2019, 5:11pm UTC](https://discourse.processing.org/t/bubble-shooting-game/10919/9 "2019-05-06T17:11:17Z")

</div>

i try the creationEnnemis thats good but sometimes two bubbles can be one over the other i try to change that : temps= random(50,200); or with if (temps\>50) but it dont work

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [May 6, 2019, 5:21pm UTC](https://discourse.processing.org/t/bubble-shooting-game/10919/10 "2019-05-06T17:21:12Z")

</div>

please also remove the code section in your code. in keyReleased the part with p and m etc.

here is a new version

before setup() say `int timer1, timer2, timer3;`

```auto

void creationEnnemis() {

  // computer move

  // temps = millis();
  temps= random(100);
  ligne=int(random(1, 4));

  if (temps>3) 
    return; // we leave here in 97%

  int yValue=0; 

  if (ligne == 1) {
    if (millis()-timer1<650)
      return; // we leave here
    yValue=200;
    timer1=millis();
  } else if (ligne == 2) {
    if (millis()-timer2<650)
      return; // we leave here
    yValue=300;
    timer2=millis();
  } else if (ligne == 3) {
    if (millis()-timer3<650)
      return; // we leave here
    yValue=400;
    timer3=millis();
  } else {
    //
  }

  uniteE.add( new rouge(1350, yValue, 1, color(237, 0, 0))); // On cree une unité qui s'ajoute dans le tableau "uniteJ" avec une posX, posY, une variable de comparaison et une couleur
}

```

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [May 6, 2019, 5:32pm UTC](https://discourse.processing.org/t/bubble-shooting-game/10919/11 "2019-05-06T17:32:30Z")

</div>

you need something to count score or lives for both players

- because I think compA, compA2, compE, compE2 is dead

**Remove dead ones from the 2 lists**

you need this in draw() :

(only one creationEnnemis() of course)

```auto

  // -------------------------------------
  // remove dead ones 

  for (int i = uniteA.size()-1; i>=0; i--) {
    bleu ball = (bleu) uniteA.get(i);
    if (!ball.isAlive) 
      uniteA.remove(i);
  }

  for (int i = uniteE.size()-1; i>=0; i--) {
    rouge ball = (rouge) uniteE.get(i);
    if (!ball.isAlive) 
      uniteE.remove(i);
  }//for

  // -------------------------------------
  // computer move 
  creationEnnemis();

```

---

<div class="post-metadata">

### Author: ![yoyo18](https://avatars.discourse-cdn.com/v4/letter/y/a183cd/32.png) [@yoyo18](https://discourse.processing.org/u/yoyo18)
#### Post date: [May 7, 2019, 6:43pm UTC](https://discourse.processing.org/t/bubble-shooting-game/10919/12 "2019-05-07T18:43:48Z")

</div>

thanks i understand all what you do for the creationEnnemis but not the quote “if (temps\>3)  
return; // we leave here in 97%” it the time between lunch a bubbles in a second line?

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [May 7, 2019, 7:20pm UTC](https://discourse.processing.org/t/bubble-shooting-game/10919/13 "2019-05-07T19:20:10Z")

</div>

temps is a random value 0…100

When we say if (temps\>3) that’s almost always true (97%)

when it’s true, we leave the function (with return) and don’t spawn a new bullet

Chrisir

---

<div class="post-metadata">

### Author: ![yoyo18](https://avatars.discourse-cdn.com/v4/letter/y/a183cd/32.png) [@yoyo18](https://discourse.processing.org/u/yoyo18)
#### Post date: [May 7, 2019, 7:54pm UTC](https://discourse.processing.org/t/bubble-shooting-game/10919/14 "2019-05-07T19:54:39Z")

</div>

yes but when i write temps\>10 the bubbles go more often its the opposite because if the temps is\>10 the temps is between 10 and 100 so less quickly wif 2 who temps is between 2 and 100

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [May 7, 2019, 8:31pm UTC](https://discourse.processing.org/t/bubble-shooting-game/10919/15 "2019-05-07T20:31:51Z")

</div>

> when i write temps\>10 the bubbles go more often

exactly !

Look at these lines:

```auto
  if (temps>3) 
    return; // we leave here in 97%

```

(with \>10) we would leave only in 90%, so more spawning

The return leaves the function immediately, so a ball is NOT spawn (the spawning is later in the function)

**Besides**

Besides : additionally, each ligne has its own timer to avoid that 2 balls are directly after another in one ligne. The timers are called timer1, timer2, timer3

---

<div class="post-metadata">

### Author: ![yoyo18](https://avatars.discourse-cdn.com/v4/letter/y/a183cd/32.png) [@yoyo18](https://discourse.processing.org/u/yoyo18)
#### Post date: [May 7, 2019, 8:49pm UTC](https://discourse.processing.org/t/bubble-shooting-game/10919/16 "2019-05-07T20:49:42Z")

</div>

thanks i understand that thanks you so much

---

<div class="post-metadata">

### Author: ![Argonui](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/argonui/32/5071_2.png) [@Argonui](https://discourse.processing.org/u/Argonui)
#### Post date: [May 8, 2019, 11:49am UTC](https://discourse.processing.org/t/bubble-shooting-game/10919/17 "2019-05-08T11:49:05Z")

</div>

Hi.  
I’m the one whow is working on the collisions between the balls and i dropped your code in the draw() but the balls are not removed when they hit.

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [May 8, 2019, 12:00pm UTC](https://discourse.processing.org/t/bubble-shooting-game/10919/18 "2019-05-08T12:00:42Z")

</div>

> [@Chrisir](#):
>
> if (!ball.isAlive) uniteA.remove(i);

Are you referring to those lines?

Because they require that isAlive is set to false

---

<div class="post-metadata">

### Author: ![Argonui](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/argonui/32/5071_2.png) [@Argonui](https://discourse.processing.org/u/Argonui)
#### Post date: [May 8, 2019, 12:02pm UTC](https://discourse.processing.org/t/bubble-shooting-game/10919/19 "2019-05-08T12:02:21Z")

</div>

Yes i refer to that but the isAlive variable is never set to false

---

<div class="post-metadata">

### Author: ![Argonui](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/argonui/32/5071_2.png) [@Argonui](https://discourse.processing.org/u/Argonui)
#### Post date: [May 8, 2019, 12:05pm UTC](https://discourse.processing.org/t/bubble-shooting-game/10919/20 "2019-05-08T12:05:27Z")

</div>

```auto
for (int i = uniteB.size()-1; i >= 0; i--) {
    bleu ball1 = (bleu) uniteB.get(i);
    if (ball1.isAlive) {
      for (int i1 = uniteR.size()-1; i1 >= 0; i1--) {
        rouge ball2 = (rouge) uniteR.get(i1);
        if (ball2.isAlive && dist(ball1.x, ball1.y, ball2.x, ball2.y) < 7) {
          text("hit", ball1.x, ball1.y);
          ball1.isAlive=false;
          ball2.isAlive=false;
          print("HIT");
     }//if
    }//for
   }//if
  }//for
  for (int i = uniteB.size()-1; i>=0; i--) {
   bleu ball = (bleu) uniteB.get(i);
    if (!ball.isAlive) 
      uniteB.remove(i);
  }

  for (int i = uniteR.size()-1; i>=0; i--) {
    rouge ball = (rouge) uniteR.get(i);
    if (!ball.isAlive) 
      uniteR.remove(i);
  }//for
 }//if
}//void

```

[Next page](https://discourse.processing.org/t/bubble-shooting-game/10919.md?page=2)
