Ejemplo n.º 1
0
 private FishState drawFish() {
   FishState fishUnderMouse = null;
   for (FishState fs : state.getFish()) {
     if (fs.isAlive()) {
       Vector pos = fs.getPosition();
       // Draw tail and outline according to speed
       int tailBrightness = (int) ((double) fs.getSpeed() / Rules.MAX_SPEED * 255);
       bufferGraphics.setColor(Color.BLACK);
       bufferGraphics.drawLine(
           (int) pos.x,
           (int) pos.y,
           (int) (pos.x - fs.getRudderVector().x * fs.getRadius() * 2),
           (int) (pos.y - fs.getRudderVector().y * fs.getRadius() * 2));
       bufferGraphics.fillOval(
           (int) pos.x - fs.getRadius(),
           (int) pos.y - fs.getRadius(),
           2 * fs.getRadius(),
           2 * fs.getRadius());
       bufferGraphics.setColor(fishtank.getColor(fs.fish_id));
       bufferGraphics.fillOval(
           (int) pos.x - fs.getRadius() + 1,
           (int) pos.y - fs.getRadius() + 1,
           2 * fs.getRadius() - 2,
           2 * fs.getRadius() - 2);
     }
     if (fs.getPosition().minus(mousePosition).length() < fs.getRadius()) {
       fishUnderMouse = fs;
     }
   }
   return fishUnderMouse;
 }