public void moveRight() { if (lives > 0) { bucket = bucket.moveRight(); if (bucket.getLocation().getX() > WIDTH + Bucket.WIDTH / 2) bucket = bucket.moveTo(-Bucket.WIDTH / 2, (int) bucket.getLocation().getY()); } }
public void draw(Graphics g) { g.setColor(Color.BLACK); g.drawString("Points: " + points, 10, 20); g.drawString("Lives: " + lives, 10, 30); if (lives <= 0) { g.setColor(Color.RED); g.drawString("You Lose", WIDTH / 2 - 20, HEIGHT / 2); } for (int i = 0; i < balls.size(); i++) balls.get(i).draw(g); bucket.draw(g); }
public void testBallCatch() { for (int i = 0; i < balls.size(); i++) { if (bucket.contains(balls.get(i))) { if (balls.get(i).isGood()) points++; else lives--; balls.remove(i); i--; } else if (balls.get(i).getLocation().getY() >= HEIGHT + Ball.RADIUS) { if (balls.get(i).isGood()) lives--; balls.remove(i); i--; } } }