Esempio n. 1
0
  public void update() {
    mFloor.update();
    mCat.update();

    mSadTicks--;

    if ((int) (Math.random() * 10) == 0) {
      mStars.add(new Star(this, (int) (Math.random() * mWidth), (int) (Math.random() * mHeight)));
    }

    for (int i = mStars.size() - 1; i >= 0; --i) {
      Star s = mStars.get(i);
      s.update();
      if (s.getX() < -35) {
        mStars.remove(i);
      }
    }
  }
Esempio n. 2
0
  public void draw(Canvas canvas) {
    mPaint.setColor(Color.rgb(0x0F, 0x4D, 0x8F));
    canvas.drawRect(0, 0, getWidth(), getHeight(), mPaint);

    for (Star s : mStars) {
      s.draw(canvas);
    }

    mFloor.draw(canvas);
    mCat.draw(canvas);

    mPaint.setTextSize(32);
    mPaint.setTextAlign(Paint.Align.LEFT);
    mPaint.setColor(Color.WHITE);

    canvas.drawText("" + mFloor.getDistance() + " nyans", 0, 32, mPaint);

    if (mSadTicks > 0) {
      mPaint.setTextSize(124);
      mPaint.setTextAlign(Paint.Align.CENTER);
      canvas.drawText(":(", mWidth / 2, mHeight / 2, mPaint);
    }
  }