title: GLut in C - Collision isn't working all the time
body: <p>I'm currently working on a side scroller, my player can shoot, as do the enemies. If I hit an enemy,it should disappear. Unfortunately, it doesn't work all the time. Sometime it does, sometime not. Sometimes, it work perfectly like here :</p>
  <pre><code>Ennemi 30 =eX:37 - eY:51 
  Shot 12=sX:37 - sY:52
  ====
  BOUM
  </code></pre>
  <p>and for some reasons, it happens that my shot go trough the enemy like it doesn't exist.</p>
  <p>Here's how I detect collision :</p>
  <pre><code> void checkCollisionShot(ListShot* list,ListEnnemy* listE){
      if (list == NULL || listE == NULL){
          exit(EXIT_FAILURE);
      }
      Shot *getSh=list-&gt;first;
      Ennemy *getEn=listE-&gt;first;
      if (list-&gt;first!= NULL &amp;&amp; listE-&gt;first!=NULL)
      {   
          int i,j;
  
          for(i=0;i&lt;list-&gt;nbr;i++){
              int sX=getSh-&gt;obj.posi.x;
              int sY=getSh-&gt;obj.posi.y;
              for(j=0;i&lt;listE-&gt;nbr;i++){
                  int eX=getEn-&gt;obj.posi.x;
                  int eY=getEn-&gt;obj.posi.y;
                  if(getEn-&gt;obj.friend!=getSh-&gt;obj.friend){
                      if(sX&lt;eX+3 &amp;&amp; sX&gt;=eX){
                          if(sY&lt;eY+3 &amp;&amp; sY&gt;=eY){
                              printf(&quot;Boum\n&quot;);
                              deleteEnnemy(listE,eX,eY);
                              deleteShot(list,sX,sY);
                          }
                      }
                  }
                  getEn=getEn-&gt;next;
              }
              getSh=getSh-&gt;next;
          }
      }
  }
  </code></pre>
  <p>I'm working with simple linked list : One for the shots, another one for the enemies. I'm browsing each element, one by one, and compare each element from a list with the position of the other list.</p>
  <p>Is the mistake coming from this function, or does it come from one of the GLut function (-like- the refresh function) ?</p>