Example #1
0
  public ObsBall(int x, int y, int Rad, int sideDiff, int type) {
    this.x = x;
    this.y = y;
    this.rad = Rad;
    this.sideDiff = sideDiff;
    this.type = type;

    // hero 위치에 이만큼을 더해서, 그 범위 내에서는 장애물 생성 안되게 막으려고
    offsetFromHero = Rad * 25;

    // 속도 조절
    speed[0] = MainActivity.unitSpeed * 4;
    speed[1] = (int) (MainActivity.unitSpeed * 8);
    speed[2] = (int) (MainActivity.unitSpeed * 12);

    idx_speed = 0;

    // vx 정하기.
    vx = speed[idx_speed];
    vy = speed[idx_speed];

    if (Rnd.nextInt(1) == 0) vx *= -1;
    if (Rnd.nextInt(1) == 0) vy *= -1;
    //

    inCirclePnt = new Paint();
    inCirclePnt.setAntiAlias(true);
    if (type == TYPE_OBSTACLE) { // 장애물 볼
      red[0] = 135;
      green[0] = 206;
      blue[0] = 235;
      red[1] = 28;
      green[1] = 160;
      blue[1] = 217;
      red[2] = 16;
      green[2] = 94;
      blue[2] = 126;
      inCirclePnt.setColor(Color.rgb(red[idx_color], green[idx_color], blue[idx_color]));

    } else if (type == TYPE_ENERGY) { // 노란색 볼
      inCirclePnt.setColor(Color.rgb(243, 218, 150));

    } else if (type == ICE_OBSTACLE) { // 얼음 볼
      inCirclePnt.setColor(Color.WHITE);
    }

    outCirclePnt = new Paint();
    outCirclePnt.setAntiAlias(true);
    outCirclePnt.setColor(Color.BLACK);
    outCirclePnt.setStyle(Paint.Style.STROKE);
    outCirclePnt.setStrokeWidth(rad / 5);
  }
Example #2
0
  // 충돌(장애물끼리 혹은 장애물 + 에너지볼)시 불러서 방향을 바꿔준다. 가속도도 약간 더해준다.
  // TYPE_OBSTACLE 일 때만 불려야 된다.
  public void afterCrashed(int type) {

    // 부딪혔을 때 중복으로 체크되서(불린 변수를 뒀음 -> 저에게 물어봐주세요)
    if (!isStateChagedByCrash) {
      // 방향 변경
      vx *= -1;
      vy *= -1;

      if (type == 0 /*장애물 끼리 충돌이라면*/ && idx_color < 2) {
        // 색 변경
        idx_color++;
        inCirclePnt.setColor(Color.rgb(red[idx_color], green[idx_color], blue[idx_color]));

        // 속도 상승
        idx_speed++;
        vx = speed[idx_speed];
        vx = speed[idx_speed];
      }

      // 모든 상태 변화에 대해서 . 최초 충돌 시에만 적용 되기 위해서.
      isStateChagedByCrash = true;
    }
  }
Example #3
0
 // 회복 됨
 public void dePoisoned() {
   inCirclePnt.setColor(Color.rgb(243, 218, 150));
   type = TYPE_ENERGY;
 }