awt - Java Intersection Error -


i have code dologic method. , i'm trying intersection between shots , obstacles can't think of nothing.. cause both different objects.. tried didn't detect @ all.

for(int i=0; i<shots.length; i++) {     if(shots[i] != null)     {         shots[i].moveshot(shotspeed);         if(shots[i].getxpos() > 1280)         {             shots[i] = null;         }     } } for(int i=0; i<obstacles.length; i++) {     if(obstacles[i] == null)      {          obstacles[i] = generateobstacle();          break;     }      if(obstacles[i] != null)     {         obstacles[i].moveobstacle();          if(obstacles[i].getxpos() < 10)          {              obstacles[i] = null;          }         else if(obstacles[i].intersects(player1.character))         {             obstacles[i] = null;             gamesounds.hit("/resources/8bit_bomb_explosion.wav");             lives--;         }     } } 

can guys give me example or @ least advice how intersection between obstacle , shot?

do these classes implement shape? if not, should. see answer collision detection complex shapes sscce.

..and should implement rectangle in obstacle , oval in shot?

that seems logical me, description of both objects.

..i type implements shape?

i tend use rectangle2d or rectangle2d.double obstacle & ellipse2d or ellipse2d.double shot. rather extend them, hold them instance variable.

give go & let know how go. if stuck, post sscce of best attempt.
might need hot-link some small images.

.. ..


Comments