Ejemplo n.º 1
0
  @Override
  public void mouseMoved(MouseEvent e) {

    mCurrentMouseLocation = e.getPoint();
    if (GameConfig.isGameStart && !GameConfig.isPutWhiteBall) {
      if (isImpact() || !canPutWhiteBall(SnookerServer.transformBallPoint(e.getPoint()))) {
        if (getCursor().getName() != GameConfig.HANDF_CURSOR_NAME) setCursor(ImageRes.handf_cursor);
        mWhiteBall.setmLocation(SnookerServer.transformBallPoint(e.getPoint()));
      } else {
        if (getCursor().getName() != GameConfig.HAND_CURSOR_NAME) {
          setCursor(ImageRes.hand_cursor);
        }
        mWhiteBall.setmLocation(SnookerServer.transformBallPoint(e.getPoint()));
      }
    }
    if (GameConfig.isGameStart && GameConfig.isPutWhiteBall) {
      if (getCursor().getName() != GameConfig.CROSS_CURSOR_NAME) setCursor(ImageRes.cross_cursor);
    }
  }
Ejemplo n.º 2
0
  /** 计算小球下一时刻的位置 */
  private void calcBallLocatopn() {

    for (int i = 0; i < mBalls.size(); i++) {
      for (int j = i + 1; j < mBalls.size(); j++) {
        if (mBalls.get(i).ismMove() || mBalls.get(j).ismMove())
          SnookerServer.impact(mBalls.get(i), mBalls.get(j));
      }
    }
    for (Ball ball : mBalls)
      if (ball.ismMove()) {
        ball.move(10);
        if (SnookerServer.isInHole(ball)) {
          ball.setmMove(false);
          ball.setmShow(false);
          ball.setmSpeed(new Speed(0, 0));
          ball.setmLocation(new BallLocation(100000, 1000000));
        }
      }
    if (allStop()) {
      GameConfig.isReady = false;
    }
  }
Ejemplo n.º 3
0
 @Override
 public void mouseReleased(MouseEvent e) {
   System.out.println(e.getPoint().toString());
   // TODO Auto-generated method stub
   if (GameConfig.isGameStart && !GameConfig.isPutWhiteBall) {
     if (getCursor().getName() == GameConfig.HANDF_CURSOR_NAME) return;
     if (getCursor().getName() == GameConfig.HAND_CURSOR_NAME) GameConfig.isPutWhiteBall = true;
     setCursor(ImageRes.cross_cursor);
     return;
   }
   if (GameConfig.isGameStart && GameConfig.isPutWhiteBall && !GameConfig.isReady) {
     GameConfig.isReady = true;
     mWhiteBall.setmSpeed(
         Speed.getOrigin(
             mWhiteBall.getmLocation(),
             SnookerServer.transformBallPoint(getTrueLocation(e.getPoint())),
             GameConfig.V));
   }
 }
Ejemplo n.º 4
0
 /**
  * 判断母球是否和其他球有碰撞,在白球是用到
  *
  * @return
  */
 private boolean isImpact() {
   for (int i = 1; i < mBalls.size(); i++) {
     if (SnookerServer.isImpact(mWhiteBall, mBalls.get(i))) return true;
   }
   return false;
 }