@Override public void mousePressed(MouseEvent event) { x1Clicked = event.getX(); y1Clicked = event.getY(); x2Clicked = event.getX(); y2Clicked = event.getY(); // Conditions to update the score depending on speed and size of shapes if (yin1.getBounds().contains(x1Clicked, y1Clicked)) { if (yin1.getWidth() > 250) { if (deltaX1 < 2) { points += 1; } else if (deltaX1 < 3) { points += 3; } else if (deltaX1 < 6) { points += 5; } else { points += 7; } } else if (yin1.getWidth() > 150) { if (deltaX1 < 2) { points += 15; } else if (deltaX1 < 3) { points += 35; } else if (deltaX1 < 6) { points += 55; } else { points += 75; } } else { if (deltaX1 < 2) { points += 125; } else if (deltaX1 < 3) { points += 225; } else if (deltaX1 < 6) { points += 325; } else { points += 425; } } } else if (yin2.getBounds().contains(x2Clicked, y2Clicked)) { if (yin2.getWidth() > 250) { if (deltaX2 < 2) { points += 1; } else if (deltaX2 < 3) { points += 3; } else if (deltaX2 < 6) { points += 5; } else { points += 7; } } else if (yin2.getWidth() > 150) { if (deltaX2 < 2) { points += 15; } else if (deltaX2 < 3) { points += 35; } else if (deltaX2 < 6) { points += 55; } else { points += 75; } } else { if (deltaX2 < 2) { points += 125; } else if (deltaX2 < 3) { points += 225; } else if (deltaX2 < 6) { points += 325; } else { points += 425; } } } else { misses--; } }
public boolean hasCollided(MyYinYang y1) { // Checks to see if the bounds of the first yinYang intersect anywhere within // the bounds of the second yinYang return y1.getBounds().intersects(yin2X, yin2Y, yin2Width, yin2Height); }