Beispiel #1
0
 /** Called on mouse drag to reshape the current rectangle */
 public void mouseDragged(MouseEvent e) {
   if (gobj != null) {
     gobj.move(e.getX() - lastX, e.getY() - lastY);
     lastX = e.getX();
     lastY = e.getY();
   } else {
     double x = Math.min(e.getX(), startX);
     double y = Math.min(e.getY(), startY);
     double width = Math.abs(e.getX() - startX);
     double height = Math.abs(e.getY() - startY);
     currentRect.setBounds(x, y, width, height);
   }
 }
Beispiel #2
0
 private GObject checkCorner(double x, double y) {
   GObject obj = getElementAt(x, y); // check the corner for GObject
   if (obj == paddle) {
     vy = -Math.abs(vy);
     PrecisionPaddle();
   } else if (obj != null && obj != lifeCount) { // check if the ball hits a brick
     remove(obj);
     vy = -1.05 * vy;
     vx = 1.05 * vx;
     brickCount--;
     AudioClip bounceClip = MediaTools.loadAudioClip("bounce.au");
     bounceClip.play();
   }
   return obj;
 }