示例#1
0
  public void moveScenario() {
    float height = getScreenSize().height() + m_spaceBetweenRectangles;
    float minBottom = 0;
    Barrier barrier;

    synchronized (m_barriers) {
      Iterator<Barrier> it = m_barriers.iterator();

      while (it.hasNext()) {
        barrier = it.next();
        barrier.goUp();

        if (barrier.isOut()) {
          it.remove();
          continue;
        }

        if (barrier.rect().bottom > minBottom) minBottom = barrier.rect().bottom;
      }
    }

    // cria novas barreiras
    if (Math.abs(height - minBottom) >= m_spaceBetweenRectangles) {

      synchronized (m_barriers) {
        m_barriers.add(new Barrier(this, height));
      }

      float bonus_release = (float) (0.1 * m_points);

      if (random.nextFloat() < bonus_release) {
        BonusBall bonusBall = null;
        float rand = random.nextFloat();
        float radius = m_spaceBetweenRectangles / 5;
        int cx = (int) (random.nextInt((int) (m_view.getWidth() - (radius + 1))));
        if (cx < radius + 1) cx = (int) radius + 1;
        int cy = (int) (height - radius);

        if (rand < 0.2) {
          bonusBall = new ColorBonusBall(this, cx, cy, radius);
        } else if (rand >= 0.2 && rand < 0.55) {
          bonusBall = new BombBonusBall(this, cx, cy, radius);
        } else if (rand >= 0.55 && rand < 0.95) {
          bonusBall = new TimeBonusBall(this, cx, cy, radius);
        } else if (rand >= 0.95) {
          bonusBall = new FailBonusball(this, cx, cy, radius);
        }

        if (bonusBall != null) {
          synchronized (m_bonusBalls) {
            m_bonusBalls.add(bonusBall);
          }
        }
      }
    }
  }
示例#2
0
  private void updateScorePoints() {
    Ball b;
    Barrier barrier;
    long score = 0;

    synchronized (m_newScorePoints) {
      Iterator<ScorePoint> it = m_newScorePoints.iterator();
      ScorePoint sp;
      while (it.hasNext()) {
        sp = it.next();
        sp.reduceAlpha();

        if (sp.getAlpha() <= 0) it.remove();
      }
    }

    synchronized (m_balls) {
      for (int i = 0; i < m_balls.size(); i++) {
        b = m_balls.get(i);
        synchronized (m_barriers) {
          for (int j = 0; j < m_barriers.size(); j++) {
            barrier = m_barriers.get(j);
            if (barrier.isPassed()) continue;
            if (b.center().y() >= barrier.rect().top) {
              addScore(b, m_points);
              barrier.setPassed(true);
              playSound("points");
              break;
            }
          }
        }
      }
    }

    score = m_score + mStartScore;

    // verifica nivel
    if (score > 700 && m_points == 2) {
      // m_sleep = m_sleep + 30;
      ScorePoint.color = Color.YELLOW;
      m_defaultSpeed = m_speed = 2;
      m_points = 3;
    } else if (score > 1400 && m_points == 3) {
      // m_sleep = m_sleep + 20;
      ScorePoint.color = Color.RED;
      m_defaultSpeed = m_speed = 3;
      m_points = 4;
    } else if (score > 2800 && m_points == 4) {
      ScorePoint.color = Color.DKGRAY;
      // m_sleep = m_sleep + 20;
      m_defaultSpeed = m_speed = 4;
      m_points = 5;
    } else if (score > 5600 && m_points == 5) {
      ScorePoint.color = Color.BLACK;
      // m_sleep = m_sleep + 10;
      m_defaultSpeed = m_speed = 5;
      m_points = 6;
    }
  }